-
Notifications
You must be signed in to change notification settings - Fork 2
GitHub Issue 928, 951, 966, 970 & 987 #1969
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
base: develop
Are you sure you want to change the base?
Changes from all commits
a05726e
5ac7f01
5403178
f65331a
4e450dd
7567cc9
2e443e7
2e3677f
fb67b17
84f6243
5bbbdf0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -508,6 +508,12 @@ async function convertRowToEditorModelData( | |
| } | ||
| } else if (col.isMultiChoice && Array.isArray(data)) { | ||
| const values = data.filter(item => !!item).map(item => ({ raw: item, display: item })); | ||
| if (values.length > 10) { | ||
| // GitHub Issue 970 | ||
| message = { | ||
| message: 'Too many values. Maximum allowed is 10.', | ||
| } | ||
| } | ||
| valueDescriptors.push(...values); | ||
| } else { | ||
| let display = data; | ||
|
|
@@ -535,8 +541,7 @@ async function prepareInsertRowDataFromBulkForm( | |
| const col = insertColumns[colIdx]; | ||
| const { message, valueDescriptors } = await convertRowToEditorModelData(data, col, containerPath); | ||
| values = values.push(valueDescriptors); | ||
|
|
||
| if (message) messages = messages.push(message); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curious why this if statement was removed? wouldn't we want to check if the message existed before adding it to the list of messages? or is this so that we keep the list items in order between the values and the messages variables?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, this is removed so we keep values and messages aligned with actual cell. The old behavior results in message being shifted to different cells. |
||
| messages = messages.push(message); | ||
| } | ||
|
|
||
| return { | ||
|
|
@@ -1592,6 +1597,11 @@ async function insertPastedData( | |
| unmatched.push(vt); | ||
| }); | ||
|
|
||
| if (values.length > 10) { | ||
| // GitHub Issue 970 | ||
| msg = { message: 'Too many values. Maximum allowed is 10.' }; | ||
| } | ||
|
|
||
| if (unmatched.length) { | ||
| const valueStr = unmatched | ||
| .slice(0, 4) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ interface ValidatedValue { | |
| export const getValidatedEditableGridValue = (origValue: any, col: QueryColumn): ValidatedValue => { | ||
| // col ?? {} so it's safe to destructure | ||
| const { caption, isDateOnlyColumn, jsonType, required, scale, validValues } = col ?? {}; | ||
| const isMultiChoice = col?.isMultiChoice; | ||
| const isDateTimeType = jsonType === 'date'; | ||
| const isDateType = isDateTimeType && isDateOnlyColumn; | ||
| let message; | ||
|
|
@@ -50,6 +51,30 @@ export const getValidatedEditableGridValue = (origValue: any, col: QueryColumn): | |
| message = `Invalid ${noun}, use format ${dateFormat}`; | ||
| } | ||
| value = dateStrVal ?? origValue; | ||
| } else if (isMultiChoice && Array.isArray(origValue)) { | ||
| if (origValue.length > 10) { | ||
| // GitHub Issue 970 | ||
| message = 'Too many values. Maximum allowed is 10.'; | ||
| } | ||
| else if (validValues) { | ||
| const seen = new Set(); | ||
| origValue.forEach(val => { | ||
| if (message) | ||
| return; | ||
|
|
||
| const trimmed = val.display?.toString().trim(); | ||
| if (seen.has(trimmed)) { | ||
| message = `Duplicate values not allowed: ${trimmed}.` | ||
| } | ||
| else { | ||
| seen.add(trimmed); | ||
| if (validValues.indexOf(trimmed) === -1) { | ||
| message = `'${trimmed}' is not a valid choice`; | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor but if a value is both a duplicate and invalid, the invalid message will override the duplicate. I assume this is fine and intentional but might be worth changing to an if invalid / else if duplicate to make the logic clear. |
||
| }) | ||
| } | ||
|
|
||
| } else if (value != null && value !== '' && !col?.isPublicLookup()) { | ||
| if (validValues) { | ||
| const trimmed = origValue?.toString().trim(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,7 +108,10 @@ const OptionRenderer: FC<OptionRendererProps> = props => { | |
| if (item !== undefined) { | ||
| let text = resolveDetailFieldLabel(item.get(column.name)); | ||
| if (!Utils.isString(text)) { | ||
| text = text != null ? text.toString() : ''; | ||
| if (text == null) | ||
| text = ''; | ||
| else if (Array.isArray(text)) | ||
| text = text.join(', '); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need the else here to retain the part about
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's safe to drop that. text is either string | string[] or null(ish), the logic should have covered all cases. |
||
| } | ||
|
|
||
| return ( | ||
|
|
||
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.
should add the github issue number as a comment here as well (as done below)