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
This commit is contained in:
commit
4af74071bc
@ -108,7 +108,7 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="mat-padding" fxLayout="row" fxLayoutAlign="end center"
|
||||
*ngIf="entityDetected && settings.showActionButtons">
|
||||
[fxShow]="entityDetected && settings.showActionButtons">
|
||||
<button mat-button color="primary" type="button"
|
||||
(click)="discardAll()" style="max-height: 50px; margin-right:20px;"
|
||||
[disabled]="!multipleInputFormGroup.dirty">
|
||||
|
||||
@ -109,6 +109,7 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni
|
||||
private datasources: Array<Datasource>;
|
||||
private destroy$ = new Subject();
|
||||
public sources: Array<MultipleInputWidgetSource> = [];
|
||||
private isSavingInProgress = false;
|
||||
|
||||
isVerticalAlignment: boolean;
|
||||
inputWidthSettings: string;
|
||||
@ -468,7 +469,8 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni
|
||||
}
|
||||
|
||||
public inputChanged(source: MultipleInputWidgetSource, key: MultipleInputWidgetDataKey) {
|
||||
if (!this.settings.showActionButtons) {
|
||||
if (!this.settings.showActionButtons && !this.isSavingInProgress) {
|
||||
this.isSavingInProgress = true;
|
||||
const currentValue = this.multipleInputFormGroup.get(key.formId).value;
|
||||
if (!key.settings.required || (key.settings.required && isDefined(currentValue))) {
|
||||
const dataToSave: MultipleInputWidgetSource = {
|
||||
@ -481,7 +483,8 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni
|
||||
}
|
||||
|
||||
public save(dataToSave?: MultipleInputWidgetSource) {
|
||||
if (document && document.activeElement) {
|
||||
if (document?.activeElement && !this.isSavingInProgress) {
|
||||
this.isSavingInProgress = true;
|
||||
(document.activeElement as HTMLElement).blur();
|
||||
}
|
||||
const config: RequestConfig = {
|
||||
@ -571,12 +574,14 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni
|
||||
() => {
|
||||
this.multipleInputFormGroup.markAsPristine();
|
||||
this.ctx.detectChanges();
|
||||
this.isSavingInProgress = false;
|
||||
if (this.settings.showResultMessage) {
|
||||
this.ctx.showSuccessToast(this.translate.instant('widgets.input-widgets.update-successful'),
|
||||
1000, 'bottom', 'left', this.toastTargetId);
|
||||
}
|
||||
},
|
||||
() => {
|
||||
this.isSavingInProgress = false;
|
||||
if (this.settings.showResultMessage) {
|
||||
this.ctx.showErrorToast(this.translate.instant('widgets.input-widgets.update-failed'),
|
||||
'bottom', 'left', this.toastTargetId);
|
||||
@ -585,6 +590,7 @@ export class MultipleInputWidgetComponent extends PageComponent implements OnIni
|
||||
} else {
|
||||
this.multipleInputFormGroup.markAsPristine();
|
||||
this.ctx.detectChanges();
|
||||
this.isSavingInProgress = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user