diff --git a/samples/react-directory/src/SPServices/spservices.ts b/samples/react-directory/src/SPServices/spservices.ts index 0962c9a19..3ece572b9 100755 --- a/samples/react-directory/src/SPServices/spservices.ts +++ b/samples/react-directory/src/SPServices/spservices.ts @@ -53,7 +53,6 @@ export class spservices implements ISPServices { } public async searchUsersNew(searchString: string, srchQry: string, isInitialSearch: boolean, pageNumber?: number): Promise { - //const _search = !isInitialSearch ? srchQry : `FirstName:${searchString}*`; let qrytext: string = ''; if (isInitialSearch) qrytext = `FirstName:${searchString}* OR LastName:${searchString}*`; else { @@ -63,7 +62,6 @@ export class spservices implements ISPServices { } if (qrytext.length <= 0) qrytext = `*`; } - console.log(qrytext); const searchProperties: string[] = ["FirstName", "LastName", "PreferredName", "WorkEmail", "OfficeNumber", "PictureURL", "WorkPhone", "MobilePhone", "JobTitle", "Department", "Skills", "PastProjects", "BaseOfficeLocation", "SPS-UserType", "GroupId"]; try { let users = await sp.search({ @@ -74,7 +72,6 @@ export class spservices implements ISPServices { SourceId: 'b09a7990-05ea-4af9-81ef-edfab16c4e31', SortList: [{ "Property": "LastName", "Direction": SortDirection.Ascending }], }); - console.log(users); if (users && users.PrimarySearchResults.length > 0) { for (let index = 0; index < users.PrimarySearchResults.length; index++) { let user: any = users.PrimarySearchResults[index]; diff --git a/samples/react-directory/src/webparts/directory/DirectoryWebPart.manifest.json b/samples/react-directory/src/webparts/directory/DirectoryWebPart.manifest.json index e9440e229..66e0435d7 100755 --- a/samples/react-directory/src/webparts/directory/DirectoryWebPart.manifest.json +++ b/samples/react-directory/src/webparts/directory/DirectoryWebPart.manifest.json @@ -23,7 +23,7 @@ "properties": { "title": "Directory", "searchFirstName": 0, - "searchProps": "FirstName,LastName,WorkEmail,Department", + "searchProps": "FirstName,LastName,PreferredName,WorkEmail,Department", "pageSize": 10 } }] diff --git a/samples/react-directory/src/webparts/directory/components/DirectoryHook.tsx b/samples/react-directory/src/webparts/directory/components/DirectoryHook.tsx index c619cab2c..edf2367c7 100644 --- a/samples/react-directory/src/webparts/directory/components/DirectoryHook.tsx +++ b/samples/react-directory/src/webparts/directory/components/DirectoryHook.tsx @@ -124,23 +124,22 @@ const DirectoryHook: React.FC = (props) => { }; let _searchUsers = async (searchText: string) => { - try { - console.log("Search Users: ", searchText); + try { setstate({ ...state, searchText: searchText, isLoading: true }); if (searchText.length > 0) { let searchProps: string[] = props.searchProps && props.searchProps.length > 0 ? props.searchProps.split(',') : ['FirstName', 'LastName', 'WorkEmail', 'Department']; let qryText: string = ''; + let finalSearchText: string = searchText ? searchText.replace(/ /g, '+') : searchText; searchProps.map((srchprop, index) => { if (index == searchProps.length - 1) - qryText += `${srchprop}:${searchText}*`; - else qryText += `${srchprop}:${searchText}* OR `; + qryText += `${srchprop}:${finalSearchText}*`; + else qryText += `${srchprop}:${finalSearchText}* OR `; }); const users = await _services.searchUsersNew('', qryText, false); setstate({ ...state, searchText: searchText, - //indexSelectedKey: (searchText.length > 0) ? searchText.substring(0, 1).toLocaleUpperCase() : 'A', indexSelectedKey: '0', users: users && users.PrimarySearchResults