Commit 4af74071bc802391fe8dd07d3a1832f99b6bbd0f
Committed by
GitHub
Merge pull request #5257 from ArtemDzhereleiko/bug-fix/input-widget/enter-key-press
[3.2.2] Fixed multiple input widget sending double requests and saving required input by Enter keypress
Showing
2 changed files
with
9 additions
and
3 deletions
... | ... | @@ -108,7 +108,7 @@ |
108 | 108 | </div> |
109 | 109 | </fieldset> |
110 | 110 | <div class="mat-padding" fxLayout="row" fxLayoutAlign="end center" |
111 | - *ngIf="entityDetected && settings.showActionButtons"> | |
111 | + [fxShow]="entityDetected && settings.showActionButtons"> | |
112 | 112 | <button mat-button color="primary" type="button" |
113 | 113 | (click)="discardAll()" style="max-height: 50px; margin-right:20px;" |
114 | 114 | [disabled]="!multipleInputFormGroup.dirty"> | ... | ... |
... | ... | @@ -109,6 +109,7 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni |
109 | 109 | private datasources: Array<Datasource>; |
110 | 110 | private destroy$ = new Subject(); |
111 | 111 | public sources: Array<MultipleInputWidgetSource> = []; |
112 | + private isSavingInProgress = false; | |
112 | 113 | |
113 | 114 | isVerticalAlignment: boolean; |
114 | 115 | inputWidthSettings: string; |
... | ... | @@ -468,7 +469,8 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni |
468 | 469 | } |
469 | 470 | |
470 | 471 | public inputChanged(source: MultipleInputWidgetSource, key: MultipleInputWidgetDataKey) { |
471 | - if (!this.settings.showActionButtons) { | |
472 | + if (!this.settings.showActionButtons && !this.isSavingInProgress) { | |
473 | + this.isSavingInProgress = true; | |
472 | 474 | const currentValue = this.multipleInputFormGroup.get(key.formId).value; |
473 | 475 | if (!key.settings.required || (key.settings.required && isDefined(currentValue))) { |
474 | 476 | const dataToSave: MultipleInputWidgetSource = { |
... | ... | @@ -481,7 +483,8 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni |
481 | 483 | } |
482 | 484 | |
483 | 485 | public save(dataToSave?: MultipleInputWidgetSource) { |
484 | - if (document && document.activeElement) { | |
486 | + if (document?.activeElement && !this.isSavingInProgress) { | |
487 | + this.isSavingInProgress = true; | |
485 | 488 | (document.activeElement as HTMLElement).blur(); |
486 | 489 | } |
487 | 490 | const config: RequestConfig = { |
... | ... | @@ -571,12 +574,14 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni |
571 | 574 | () => { |
572 | 575 | this.multipleInputFormGroup.markAsPristine(); |
573 | 576 | this.ctx.detectChanges(); |
577 | + this.isSavingInProgress = false; | |
574 | 578 | if (this.settings.showResultMessage) { |
575 | 579 | this.ctx.showSuccessToast(this.translate.instant('widgets.input-widgets.update-successful'), |
576 | 580 | 1000, 'bottom', 'left', this.toastTargetId); |
577 | 581 | } |
578 | 582 | }, |
579 | 583 | () => { |
584 | + this.isSavingInProgress = false; | |
580 | 585 | if (this.settings.showResultMessage) { |
581 | 586 | this.ctx.showErrorToast(this.translate.instant('widgets.input-widgets.update-failed'), |
582 | 587 | 'bottom', 'left', this.toastTargetId); |
... | ... | @@ -585,6 +590,7 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni |
585 | 590 | } else { |
586 | 591 | this.multipleInputFormGroup.markAsPristine(); |
587 | 592 | this.ctx.detectChanges(); |
593 | + this.isSavingInProgress = false; | |
588 | 594 | } |
589 | 595 | } |
590 | 596 | ... | ... |