Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added person-assign-to-me #672

Merged
merged 6 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions column-samples/person-assign-to-me/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Assign to Me

## Summary

This sample demonstrates the use of the `setValue` action of `customRowAction` to set the current logged-in user in the Person column.

![screenshot of the sample](./assets/screenshot.gif)

> **Note**
> If you use this sample, you need to set the `actionInput` to the internal name of the Person column to be updated.

## View requirements
- This format can be applied to a Person column.

## Sample

Solution|Author(s)
--------|---------
person-assign-to-me-single.json | [Tetsuya Kawahara](https://github.com/tecchan1107) ([@techan_k](https://twitter.com/techan_k))
person-assign-to-me-multi.json | [Tetsuya Kawahara](https://github.com/tecchan1107) ([@techan_k](https://twitter.com/techan_k))

## Version history

Version |Date |Comments
--------|-------------|--------
1.0 |May 11, 2023 |Initial release

## Disclaimer
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

<img src="https://pnptelemetry.azurewebsites.net/list-formatting/column-samples/person-assign-to-me" />
79 changes: 79 additions & 0 deletions column-samples/person-assign-to-me/assets/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[
{
"name": "pnp-list-formatting-person-assign-to-me",
"reponame": "person-assign-to-me",
"source": "pnp",
"title": "Assign to Me",
"shortDescription": "This sample demonstrates the use of the setValue action of customRowAction to set the current logged-in user in the Person column.",
"url": "https://github.com/pnp/List-Formatting/tree/master/column-samples/person-assign-to-me",
"longDescription": [
"This sample demonstrates the use of the setValue action of customRowAction to set the current logged-in user in the Person column."
],
"creationDateTime": "2023-05-11T00:00:00.000Z",
"updateDateTime": "2023-05-11T00:00:00.000Z",
"products": [
"SharePoint",
"Microsoft Lists"
],
"metadata": [
{
"key": "LIST-SAMPLE-TYPE",
"value": "Column"
},
{
"key": "SHAREPOINT-COMPATIBILITY",
"value": "SharePoint Online"
},
{
"key": "SAMPLE-CATEGORIES",
"value": ""
},
{
"key": "LIST-COLUMN-TYPE",
"value": "Person, Multi-Person"
},
{
"key": "FORMATTING-TOKENS",
"value": ""
},
{
"key": "FORMATTING-OPERATORS",
"value": "getUserImage, appendTo, indexOf"
},
{
"key": "FORMATTING-ACTIONS",
"value": "setValue"
},
{
"key": "FORMATTING-FEATURES",
"value": "forEach, defaultHoverField"
},
{
"key": "CLASSES",
"value": "ms-Link, ms-fontColor-themePrimary, ms-fontColor-neutralPrimary, ms-bgColor-neutralLight"
}
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "https://raw.githubusercontent.com/pnp/List-Formatting/master/column-samples/person-assign-to-me/assets/screenshot.gif",
"alt": "screenshot"
}
],
"authors": [
{
"gitHubAccount": "tecchan1107",
"pictureUrl": "https://github.com/tecchan1107.png",
"name": "Tetsuya Kawahara"
}
],
"references": [
{
"name": "Use column formatting to customize SharePoint",
"description": "You can use column formatting to customize how fields in SharePoint lists and libraries are displayed. To do this, you construct a JSON object that describes the elements that are displayed when a field is included in a list view, and the styles to be applied to those elements. The column formatting does not change the data in the list item or file; it only changes how its displayed to users who browse the list.",
"url": "https://docs.microsoft.com/sharepoint/dev/declarative-customization/column-formatting"
}
]
}
]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions column-samples/person-assign-to-me/person-assign-to-me-multi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "div",
"style": {
"display": "flex",
"flex-direction": "column"
},
"children": [
{
"elmType": "div",
"children": [
{
"elmType": "div",
"style": {
"display": "flex",
"flex-wrap": "wrap"
},
"children": [
{
"elmType": "div",
"forEach": "person in @currentField",
"style": {
"display": "=if(@currentField,'flex','none')",
"flex-direction": "row",
"align-items": "center",
"white-space": "nowrap",
"border-radius": "13px",
"margin": "4px"
},
"attributes": {
"class": "ms-bgColor-neutralLight"
},
"defaultHoverField": "[$person]",
"children": [
{
"elmType": "img",
"style": {
"width": "28px",
"height": "28px",
"border-radius": "50%"
},
"attributes": {
"src": "=getUserImage([$person.email], 'small')"
}
},
{
"elmType": "div",
"txtContent": "[$person.title]",
"style": {
"padding-left": "6px",
"padding-right": "10px"
},
"attributes": {
"class": "ms-fontColor-neutralPrimary"
}
}
]
}
]
}
]
},
{
"elmType": "div",
"style": {
"display": "=if(indexOf(@currentField.email , @me)>-1,'none','flex')",
"align-items": "center",
"margin": "3px"
},
"attributes": {
"class": "ms-Link ms-fontColor-themePrimary"
},
"customRowAction": {
"action": "setValue",
"actionInput": {
"InternalNameOfPersonColumn": "=appendTo(@currentField.email , @me)"
}
},
"children": [
{
"elmType": "span",
"attributes": {
"iconName": "Add"
}
},
{
"elmType": "span",
"txtContent": "Assign to Me",
"style": {
"margin-left": "4px"
}
}
]
}
]
}
]
}
85 changes: 85 additions & 0 deletions column-samples/person-assign-to-me/person-assign-to-me-single.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "div",
"style": {
"display": "flex",
"flex-direction": "column"
},
"children": [
{
"elmType": "div",
"style": {
"display": "=if(@currentField,'flex','none')",
"flex-direction": "row",
"align-items": "center",
"white-space": "nowrap",
"border-radius": "13px"
},
"attributes": {
"class": "ms-bgColor-neutralLight"
},
"defaultHoverField": "@currentField",
"children": [
{
"elmType": "img",
"style": {
"width": "28px",
"height": "28px",
"border-radius": "50%"
},
"attributes": {
"src": "=getUserImage(@currentField.email, 'small')"
}
},
{
"elmType": "div",
"txtContent": "@currentField.title",
"style": {
"padding-left": "6px",
"padding-right": "10px"
},
"attributes": {
"class": "ms-fontColor-neutralPrimary"
}
}
]
},
{
"elmType": "div",
"style": {
"display": "=if(@currentField,'none','flex')",
"align-items": "center",
"margin": "3px"
},
"attributes": {
"class": "ms-Link ms-fontColor-themePrimary"
},
"customRowAction": {
"action": "setValue",
"actionInput": {
"InternalNameOfPersonColumn": "@me"
}
},
"children": [
{
"elmType": "span",
"attributes": {
"iconName": "Add"
}
},
{
"elmType": "span",
"txtContent": "Assign to Me",
"style": {
"margin-left": "4px"
}
}
]
}
]
}
]
}