Skip to content
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

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

wiktord2000
Copy link
Contributor

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (check one with "x")

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation
  • Other... Please describe:

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")

  • Yes
  • No ?

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:

@wiktord2000
Copy link
Contributor Author

wiktord2000 commented Jun 11, 2024

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.

if (this.hasEmptyValue === undefined) {
this.hasEmptyValue = json?.hasEmptyValue ?? !!emptyOption;
}
this.updateForm();
Copy link
Contributor

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

Copy link
Contributor Author

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

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?

Copy link
Contributor Author

@wiktord2000 wiktord2000 Jun 11, 2024

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

@wiktord2000 wiktord2000 force-pushed the fix/AAE-22947-readonly-dropdown-should-not-display-errors branch 2 times, most recently from 8c2303b to c4d7f5c Compare June 11, 2024 13:51
@wiktord2000 wiktord2000 changed the title AAE-22947 Dropdown should not display errors / call apis when it's in readOnly state AAE-22947 Dropdown should not display errors / call apis when it's in readOnly state [with refactor] Jun 11, 2024
@wiktord2000 wiktord2000 marked this pull request as draft June 21, 2024 08:03
@wiktord2000 wiktord2000 changed the title AAE-22947 Dropdown should not display errors / call apis when it's in readOnly state [with refactor] AAE-22947 Dropdown widget code should be refactored Jun 21, 2024
@wiktord2000 wiktord2000 force-pushed the fix/AAE-22947-readonly-dropdown-should-not-display-errors branch from 779cd9a to 6b4ad04 Compare July 1, 2024 09:16
Copy link

sonarcloud bot commented Jul 1, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants