-
Notifications
You must be signed in to change notification settings - Fork 264
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
AAE-22947 Dropdown widget code should be refactored #9794
base: develop
Are you sure you want to change the base?
AAE-22947 Dropdown widget code should be refactored #9794
Conversation
This PR includes some code improvements, especially I decided to store directly {id: 'option_id', name: 'Option'} during option selection instead of keeping only 'option_id' and next finding corresponding option from options if needed. Indeed we had inconsistency between multiple and single mode. When selecting multiple we store array of objects e.g. [{id: 'option_id', name: 'Option'}, {id: 'option_id2', name: 'Option2'}] and in single only the id of selected value. I tried to simplify this code but I'm not sure whether I didn't change to much, so please try to review in detail. Note: We always save (before and now) entire object of the selected option e.g. {id: 'option_id', name: 'Option'} in the form lvl (instead of id) during save/complete. Hence we needed some magic every time we ware changing selected option in single mode. |
lib/core/src/lib/form/components/widgets/core/form-field-validator.spec.ts
Outdated
Show resolved
Hide resolved
lib/core/src/lib/form/components/widgets/core/form-field.model.ts
Outdated
Show resolved
Hide resolved
if (this.hasEmptyValue === undefined) { | ||
this.hasEmptyValue = json?.hasEmptyValue ?? !!emptyOption; | ||
} | ||
this.updateForm(); |
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.
was this already inside the get value? please test this code very well it could break several things
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.
Need more info, don't get it
} | ||
if (this.hasEmptyValue && value === null) { | ||
value = this.emptyValueOption; | ||
return value; |
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 do u return assign and return value instead of just returning this.emptyOption?
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.
Thx, forgot to change it
@@ -285,7 +294,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI | |||
} | |||
|
|||
private resetValue() { | |||
this.field.value = ''; | |||
this.field.value = null; |
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 sounds very scary. until now we were resetting the field value with an empty string ( so it will never be null ) and now u are passing null, why?
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 thought that since value is indeed of type FormFieldOption (not id - string as before) I can switch to null
8c2303b
to
c4d7f5c
Compare
779cd9a
to
6b4ad04
Compare
Quality Gate passedIssues Measures |
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x")
What is the current behaviour? (You can also link to an open issue here)
https://hyland.atlassian.net/browse/AAE-22947
What is the new behaviour?
Does this PR introduce a breaking change? (check one with "x")
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
Other information: