mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-34137 Fix for disabling complete button on the form after declining form confirmation dialog (#11766)
* AAE-34137 Reenable Save and Complete buttons if user rejects on Confirm dialog * Apply suggestion from Copilot, add takeUntilDestroy Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot
parent
430bd08fa9
commit
d526d31425
@@ -1026,7 +1026,7 @@ describe('FormCloudComponent', () => {
|
||||
expect(formComponent.form.selectedOutcomeId).toBe(outcomeId);
|
||||
});
|
||||
|
||||
it('should not confirm form if user rejects', () => {
|
||||
it('should not confirm form and reenable save and complete buttons if user rejects', () => {
|
||||
const outcome = 'complete';
|
||||
spyOn(matDialog, 'open').and.returnValue({ afterClosed: () => of(false) } as any);
|
||||
|
||||
@@ -1040,10 +1040,15 @@ describe('FormCloudComponent', () => {
|
||||
formComponent.form = formModel;
|
||||
spyOn(formComponent['formCloudService'], 'completeTaskForm');
|
||||
|
||||
formComponent.disableSaveButton = true;
|
||||
formComponent.disableCompleteButton = true;
|
||||
|
||||
formComponent.completeTaskForm(outcome);
|
||||
|
||||
expect(matDialog.open).toHaveBeenCalled();
|
||||
expect(formComponent['formCloudService'].completeTaskForm).not.toHaveBeenCalled();
|
||||
expect(formComponent.disableSaveButton).toBe(false);
|
||||
expect(formComponent.disableCompleteButton).toBe(false);
|
||||
});
|
||||
|
||||
it('should require json to parse form', () => {
|
||||
|
||||
@@ -419,11 +419,17 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
|
||||
minWidth: '450px'
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result === true) {
|
||||
this.completeForm(outcome, outcomeId);
|
||||
}
|
||||
});
|
||||
dialogRef
|
||||
.afterClosed()
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe((result) => {
|
||||
if (result === true) {
|
||||
this.completeForm(outcome, outcomeId);
|
||||
} else {
|
||||
this.disableSaveButton = false;
|
||||
this.disableCompleteButton = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.completeForm(outcome, outcomeId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user