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);
|
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';
|
const outcome = 'complete';
|
||||||
spyOn(matDialog, 'open').and.returnValue({ afterClosed: () => of(false) } as any);
|
spyOn(matDialog, 'open').and.returnValue({ afterClosed: () => of(false) } as any);
|
||||||
|
|
||||||
@@ -1040,10 +1040,15 @@ describe('FormCloudComponent', () => {
|
|||||||
formComponent.form = formModel;
|
formComponent.form = formModel;
|
||||||
spyOn(formComponent['formCloudService'], 'completeTaskForm');
|
spyOn(formComponent['formCloudService'], 'completeTaskForm');
|
||||||
|
|
||||||
|
formComponent.disableSaveButton = true;
|
||||||
|
formComponent.disableCompleteButton = true;
|
||||||
|
|
||||||
formComponent.completeTaskForm(outcome);
|
formComponent.completeTaskForm(outcome);
|
||||||
|
|
||||||
expect(matDialog.open).toHaveBeenCalled();
|
expect(matDialog.open).toHaveBeenCalled();
|
||||||
expect(formComponent['formCloudService'].completeTaskForm).not.toHaveBeenCalled();
|
expect(formComponent['formCloudService'].completeTaskForm).not.toHaveBeenCalled();
|
||||||
|
expect(formComponent.disableSaveButton).toBe(false);
|
||||||
|
expect(formComponent.disableCompleteButton).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should require json to parse form', () => {
|
it('should require json to parse form', () => {
|
||||||
|
|||||||
@@ -419,9 +419,15 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
|
|||||||
minWidth: '450px'
|
minWidth: '450px'
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogRef.afterClosed().subscribe((result) => {
|
dialogRef
|
||||||
|
.afterClosed()
|
||||||
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||||
|
.subscribe((result) => {
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
this.completeForm(outcome, outcomeId);
|
this.completeForm(outcome, outcomeId);
|
||||||
|
} else {
|
||||||
|
this.disableSaveButton = false;
|
||||||
|
this.disableCompleteButton = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user