-
Notifications
You must be signed in to change notification settings - Fork 399
Fix #1721 #1722
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
Fix #1721 #1722
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the first contribution to this project.
Hi @nsoeth, Thanks for this PR! Regarding the addition of $top query operation, I'd suggest to make it available as optional because it depends on use case and maybe it would not fit for everyone to load 5000 items at once. Since the DynamicForm lookup field relies on
Like this, the developer will be free to set the number of items he wants to get 🙂 A suggestion of prop name could be Let me know if something's not clear or if you need help. |
Hi @michaelmaillot , Kind regards, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nsoeth , I've submitted a fews changes to be done, let me know if you want any kind of help 🙂
Edit: as a guidance, I suggest you to run the solution locally: you'll be able to test the DynamicForm through the included ControlsTests
webpart. Or you can test it on your consuming solution with npm link
command. Feel free to reach out if you need assistance.
src/services/SPService.ts
Outdated
@@ -221,7 +221,8 @@ export default class SPService implements ISPService { | |||
filterString?: string, | |||
substringSearch: boolean = false, | |||
orderBy?: string, | |||
cacheInterval: number = 1): Promise<any[]> { // eslint-disable-line @typescript-eslint/no-explicit-any | |||
cacheInterval: number = ICON_GENERIC_16, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this should be:
cacheInterval: number = 1,
src/services/SPService.ts
Outdated
@@ -259,7 +260,7 @@ export default class SPService implements ISPService { | |||
return filteredItems; | |||
} | |||
|
|||
apiUrl = `${webAbsoluteUrl}/_api/web/lists('${listId}')/items?$select=${keyInternalColumnName || 'Id'},${internalColumnName},FieldValuesAsText/${internalColumnName}&$expand=FieldValuesAsText&$orderby=${orderBy}${filterString ? '&$filter=' + filterString : ''}`; | |||
apiUrl = `${webAbsoluteUrl}/_api/web/lists('${listId}')/items?$select=${keyInternalColumnName || 'Id'},${internalColumnName},FieldValuesAsText/${internalColumnName}&$expand=FieldValuesAsText&$orderby=${orderBy}${filterString ? '&$filter=' + filterString : ''}${top ? `&$top=${top}` : ''}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a missing backtick (`) at the end of this line, which raises errors on this file during the build.
The top
prop shouldn't be placed here but here.
src/services/SPService.ts
Outdated
return [{ key: result[fieldName].ID, name: result[fieldName][lookupFieldName || 'Title'] }]; | ||
let value = result[fieldName][lookupFieldName || 'Title']; | ||
const dateVal = Date.parse(value); | ||
if (dateVal !== NaN) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to update this line because the getLookupValue
is not used and should be deleted.
src/services/SPService.ts
Outdated
lookups.push({ key: singleItem.ID, name: singleItem[lookupFieldName || 'Title'] }); | ||
let value = singleItem[fieldName][lookupFieldName || 'Title']; | ||
const dateVal = Date.parse(value); | ||
if (dateVal !== NaN) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to compare with the type function:
if (!Number.isNaN(dateVal))
src/services/SPService.ts
Outdated
@@ -221,7 +221,8 @@ export default class SPService implements ISPService { | |||
filterString?: string, | |||
substringSearch: boolean = false, | |||
orderBy?: string, | |||
cacheInterval: number = 1): Promise<any[]> { // eslint-disable-line @typescript-eslint/no-explicit-any | |||
cacheInterval: number = ICON_GENERIC_16, | |||
top?: number): Promise<any[]> { // eslint-disable-line @typescript-eslint/no-explicit-any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
top
property should be placed before cacheInterval
as this one has a default value. Otherwise, there will be a confusion if itemitemsQueryCountLimit
prop is filled.
src/services/SPService.ts
Outdated
}); | ||
} | ||
//single select lookups are objects | ||
else { | ||
const singleItem = result[fieldName]; | ||
lookups.push({ key: singleItem.ID, name: singleItem[lookupFieldName || 'Title'] }); | ||
let value = singleItem[fieldName][lookupFieldName || 'Title']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be singleItem[lookupFieldName || 'Title']
because you've already iterate into the fieldName
data.
src/services/SPService.ts
Outdated
result[fieldName].forEach(element => { | ||
lookups.push({ key: element.ID, name: element[lookupFieldName || 'Title'] }); | ||
result[fieldName].forEach(element => { | ||
let value = element[fieldName][lookupFieldName || 'Title']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be element[lookupFieldName || 'Title']
because you've already iterate into the fieldName
data.
3.18.0 Release
Hi @nsoeth, Are you still working on this one? Do you need any kind of help? |
Hi @michaelmaillot |
Merged manually, thank you! |
What's in this Pull Request?
This PR will fix #1721
Guidance