-
Notifications
You must be signed in to change notification settings - Fork 269
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-23521 Fix improve dropdown reactive form #10040
AAE-23521 Fix improve dropdown reactive form #10040
Conversation
does the https://github.com/Alfresco/alfresco-ng2-components/tree/develop/lib/process-services/src/lib/form/widgets/dropdown needs any change with this modify? |
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.
added some notes and small suggestions
lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.html
Outdated
Show resolved
Hide resolved
*ngIf="isRequired()">*</span> | ||
<div | ||
class="adf-dropdown-widget {{field.className}}" | ||
[class.adf-invalid]="dropdownControl.invalid && dropdownControl.touched" |
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.
maybe we can also replate it by getter?
something like
[class.adf-invalid]="dropdownControl.invalid && dropdownControl.touched" | |
get isDropdownInvalidAndTouched(): boolean { | |
return this.dropdownControl.invalid && this.dropdownControl.touched; | |
} |
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 it's not needed here - no additional code
MatSelectModule, | ||
ErrorWidgetComponent, | ||
TranslateModule, | ||
CardViewModule // imported for adf-select-filter-input |
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 this comment is not needed
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 left it here because I hope that soon we will modify the adf-select-filter-input to be standalone and then this import can be removed
lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts
Outdated
Show resolved
Hide resolved
lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts
Outdated
Show resolved
Hide resolved
this.dropdownControl.disable({ emitEvent: false }); | ||
} | ||
|
||
this.dropdownControl.valueChanges |
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.
maybe we can move this subscriptions to separate method? what do you think?
class="adf-dropdown-failed-message" | ||
*ngIf="variableOptionsFailed" | ||
required="{{ 'FORM.FIELD.VARIABLE_DROPDOWN_OPTIONS_FAILED' | translate }}" | ||
></error-widget> |
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 we can display errors using only one error-widget (by assign errors to the validationSummary property), but its something optional, in the future i believe we will replace this by mat-error (we have ticket for it)
so its just a suggestion
@@ -51,22 +50,6 @@ export class RequiredFieldValidator implements FormFieldValidator { | |||
|
|||
validate(field: FormFieldModel): boolean { | |||
if (this.isSupported(field) && field.isVisible) { | |||
if (field.type === FormFieldTypes.DROPDOWN) { | |||
if (field.hasMultipleValues) { |
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.
just a note, please make sure we still have a correct behaviour of form validity as a whole, like disable 'Complete' button where field.hasMultipleValues
and Array.isArray(field.value) && !!field.value.length
return false
lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts
Outdated
Show resolved
Hide resolved
lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts
Outdated
Show resolved
Hide resolved
That's right, I modified the dropdown widget as well |
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 job
} | ||
|
||
isReadOnlyType(): boolean { | ||
return this.field.type === 'readonly'; | ||
private initFormControl() { |
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.
private initFormControl() { | |
private initFormControl(): void { |
} | ||
|
||
showRequiredMessage(): boolean { | ||
return (this.isInvalidFieldRequired() || this.field.value === 'empty') && this.isTouched(); | ||
private handleErrors() { |
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.
private handleErrors() { | |
private handleErrors(): void { |
} | ||
|
||
get isReadOnlyField(): boolean { | ||
return this.field.readOnly; | ||
private setOptionValue(option: string | FormFieldOption, field: FormFieldModel) { |
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.
private setOptionValue(option: string | FormFieldOption, field: FormFieldModel) { | |
private setOptionValue(option: string | FormFieldOption, field: FormFieldModel): void { |
} | ||
|
||
private isReadOnlyForm(): boolean { | ||
return !!this.field?.form?.readOnly; | ||
private getOptionValue(value?: string | FormFieldOption) { |
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.
private getOptionValue(value?: string | FormFieldOption) { | |
private getOptionValue(value?: string | FormFieldOption): FormFieldOption | undefined { |
</mat-option> | ||
<mat-option id="readonlyOption" *ngIf="isReadOnlyType()" [value]="field.value">{{field.value}}</mat-option> | ||
<mat-select class="adf-select" [id]="field.id" [formControl]="dropdownControl"> | ||
<mat-option *ngFor="let opt of field.options" [value]="opt" [id]="opt.id">{{opt.name}} </mat-option> |
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.
<mat-option *ngFor="let opt of field.options" [value]="opt" [id]="opt.id">{{opt.name}} </mat-option> | |
<mat-option *ngFor="let opt of field.options" [value]="opt" [id]="opt.id">{{opt.name}}</mat-option> |
:D
@@ -1,5 +1,6 @@ | |||
.adf-error { | |||
display: flex; | |||
align-items: center; |
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.
is this expected? the error under each field should be centered, not left-aligned?
Quality Gate failedFailed conditions |
* Revert "AAE-23521 Fix improve dropdown reactive form (#10040)" This reverts commit f88ff10. * Revert "AAE-24371 Fix invalid endpoint is called when process with form is st… (#10052)" This reverts commit d38e782. * Revert "Revert "AAE-24371 Fix invalid endpoint is called when process with form is st… (#10052)"" This reverts commit 125ada7.
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)
AAE-23521
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: