-
Notifications
You must be signed in to change notification settings - Fork 2
Support field type conversion for Multi Choice fields #1927
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?
Conversation
| if (!isMultiField && !isValidTextChoiceValue(value)) return; | ||
|
|
||
| const values: string[] = []; | ||
| if (isMultiField && Array.isArray(value)) { | ||
| values.push(...value); | ||
| hasMultiValue = hasMultiValue || value.length > 1; | ||
| } else { | ||
| values.push(value); | ||
| } | ||
|
|
||
| const rowLocked = row.IsLocked.value === 1; | ||
| const rowCount = row.RowCount.value; | ||
|
|
||
| values.forEach(val => { | ||
| if (!useCount[val]) { | ||
| useCount[val] = { count: 0, locked: false }; | ||
| } | ||
| useCount[val].count += rowCount; | ||
| useCount[val].locked = useCount[val].locked || rowLocked; | ||
| }); |
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 code block looks to be almost an exact duplicate of the code above for the if statement. Can this be factored out to be shared by both?
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.
Yep, done
| ); | ||
| expect(document.body).toHaveTextContent( | ||
| 'This change will convert the values in the field from dateTime to date. This will cause the Time portion of the value to be removed.' | ||
| 'Confirm Data Type ChangeThis change will convert the values in the field from Text Choice (single select) to Text Choice (multiple select). Filters in saved views might not function as expected and any conditional formatting configured for this field will be removed.' |
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.
minor but when I look at this in the UI the "Single Select" and "Multiple Select" text is capitalized. Does that matter for this test case?
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.
Good catch. I don't think it matters in this case.
| if ( | ||
| shouldShowConfirmDataTypeChange( | ||
| field.original.rangeURI ?? field.original.conceptURI, | ||
| typeConvertingTo.rangeURI ?? typeConvertingTo.conceptURI |
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 was thinking the same thing as copilot here. Should the conceptURI take precedence over the rangeURI? won't all fields have a rangeURI, which means it will never fall back to the conceptURI?
| showFilePropertyType: boolean, | ||
| showStudyPropertyTypes: boolean | ||
| ): boolean { | ||
| if (type.hideFromDomainRow) return false; |
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.
why add this new hideFromDomainRow property when we already have type specific checks below? can't we just say "if type is multi choice text, return false"?
| import { DomainField } from './models'; | ||
| import { MULTI_CHOICE_RANGE_URI } from './constants'; | ||
|
|
||
| describe('TextChoiceOptions', () => { |
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.
Hurray for another spec file converted! Just curious, did you convert this manually or did you use AI in some capacity? just want to see what others are doing / using.
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.
Yep this was converted using AI. I first tried Junie but it wasn't successful. But using copilot (Gemini 3) it was a very smooth convert.
| type="checkbox" | ||
| /> | ||
| <span | ||
| 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.
will this span title be discoverable by the users? or should this be a ? tooltip type of display?
Oh, is this just for the disabled checkbox case?
| return Filter.create(fieldKey, [], oldFilter.getFilterType()); | ||
| if (allValues && newCheckedValues.length >= allValues.length) { | ||
| return Filter.create(fieldKey, allValues.filter(v => v !== ALL_VALUE_DISPLAY), oldFilter.getFilterType()); | ||
| } |
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 don't know much about this change, but should there be a related jest test for this?
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.
jest tests added
Rationale
Instead of two separate data types, this PR modifies TextChoice so multi choice is no longer an explicit option in designer, but rather, can be enabled to checking a "multi" check box after selecting text choice option.
Related Pull Requests
Changes