Skip to content

Commit c5f9603

Browse files
committed
Code cleanup to PeoplePicker
1 parent a7105ac commit c5f9603

File tree

7 files changed

+269
-217
lines changed

7 files changed

+269
-217
lines changed

docs/documentation/docs/controls/PeoplePicker.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# People Picker
22

3-
This control renders a People picker field which can be used to select one or many users from a SharePoint group, or filter from all users in a SharePoint site. You could also set the control as mandatory and show a custom error message if field is empty.
3+
This control renders a People picker field which can be used to select one or more users from a SharePoint group or site. The control can be configured as mandatory. It will show a custom error message if field is empty.
44

55
**Empty People Picker control with error message and tooltip**
66

@@ -20,30 +20,29 @@ This control renders a People picker field which can be used to select one or ma
2020
- Check that you installed the `@pnp/spfx-controls-react` dependency. Check out the [getting started](../#getting-started) page for more information about installing the dependency.
2121
- Import the following modules to your component:
2222

23-
```TypeScript
23+
```typescript
2424
import { PeoplePicker } from "@pnp/spfx-controls-react/lib/PeoplePicker";
2525
```
2626

2727
- Use the `PeoplePicker` control in your code as follows:
2828

29-
```TypeScript
29+
```typescript
3030
<PeoplePicker
3131
context={this.props.context}
3232
titleText="People Picker"
3333
personSelectionLimit={3}
34-
groupName = {"Team Site Owners"} //leave this blank in case you want to filter from all users
35-
showtooltip = {true}
36-
isRequired = {true}
37-
selectedItems = {this._getPeoplePickerItems}
38-
/>
34+
groupName={"Team Site Owners"} // Leave this blank in case you want to filter from all users
35+
showtooltip={true}
36+
isRequired={true}
37+
selectedItems={this._getPeoplePickerItems} />
3938
```
4039

4140
- With the `selectedItems` property you can get the selected People in the Peoplepicker :
4241

4342
```typescript
4443
private _getPeoplePickerItems(items: any[]) {
45-
console.log('Items:', items);
46-
}
44+
console.log('Items:', items);
45+
}
4746
```
4847

4948
## Implementation
@@ -53,8 +52,8 @@ The People picker control can be configured with the following properties:
5352
| Property | Type | Required | Description |
5453
| ---- | ---- | ---- | ---- |
5554
| context | WebPartContext | yes | Context of the current web part. |
56-
| groupName | string | yes | group from which users are fetched. Leave it blank if need to filter all users |
5755
| titleText | string | yes | Text to be displayed on the control |
56+
| groupName | string | no | group from which users are fetched. Leave it blank if need to filter all users |
5857
| personSelectionLimit | number | no | Defines the limit of people that can be selected in the control|
5958
| isRequired | boolean | no | Set if the control is required or not |
6059
| errorMessage | string | no | Specify the error message to display |

src/controls/peoplepicker/IPeoplePicker.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ export interface IPeoplePickerProps {
1111
*/
1212
context: WebPartContext;
1313
/**
14-
* Name of SharePoint Group
15-
*/
16-
groupName: string;
17-
/**
18-
* Text of the Control
14+
* Text of the Control
1915
*/
2016
titleText: string;
17+
/**
18+
* Name of SharePoint Group
19+
*/
20+
groupName?: string;
2121
/**
2222
* Selection Limit of Control
2323
*/
@@ -37,7 +37,7 @@ export interface IPeoplePickerProps {
3737
/**
3838
* Method to check value of People Picker text
3939
*/
40-
selectedItems?: (items: any[]) => void;
40+
selectedItems?: (items: any[]) => void;
4141
/**
4242
* Tooltip Message
4343
*/

src/controls/peoplepicker/IUsers.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export interface IUsers {
2+
'@odata.context': string;
3+
value: Value[];
4+
}
5+
6+
export interface Value {
7+
'@odata.type': string;
8+
'@odata.id': string;
9+
'@odata.editLink': string;
10+
Id: number;
11+
IsHiddenInUI: boolean;
12+
LoginName: string;
13+
Title: string;
14+
PrincipalType: number;
15+
Email: string;
16+
IsEmailAuthenticationGuestUser: boolean;
17+
IsShareByEmailGuestUser: boolean;
18+
IsSiteAdmin: boolean;
19+
UserId?: UserId;
20+
}
21+
22+
export interface UserId {
23+
NameId: string;
24+
NameIdIssuer: string;
25+
}

0 commit comments

Comments
 (0)