mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ADF-1175] Start Process and Start Task Forms don't close when Cancel button is clicked (#2133)
* [ADF-1175] Start Process and Start Task Forms don't close when Cancel button is clicked. * Added Start task/process cancel emitter handler to redirect when user clicks on cancel start/process . * [ADF-1175] Start Process and Start Task Forms don't close when Cancel button is clicked. * Changed activiti-start-task to adf-start-task * Changed onSuccess to success and Updated document. * [ADF-1175] Start Process and Start Task Forms don't close when Cancel button is clicked * Refactored start task component unit testcases
This commit is contained in:
parent
2b92e03a1c
commit
54779cb38c
@ -83,10 +83,11 @@
|
||||
</md-card>
|
||||
</div>
|
||||
<div class="mdl-cell mdl-cell--10-col task-column mdl-shadow--2dp" *ngIf="isStartTaskMode()">
|
||||
<activiti-start-task
|
||||
<adf-start-task
|
||||
[appId]="appId"
|
||||
(onSuccess)="onStartTaskSuccess($event)">
|
||||
</activiti-start-task>
|
||||
(success)="onStartTaskSuccess($event)"
|
||||
(cancel)="onCancelStartTask()">
|
||||
</adf-start-task>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -158,7 +159,11 @@
|
||||
</md-card>
|
||||
</div>
|
||||
<div class="mdl-cell mdl-cell--10-col task-column mdl-shadow--2dp" *ngIf="isStartProcessMode()">
|
||||
<activiti-start-process [appId]="appId" (start)="onStartProcessInstance($event)"></activiti-start-process>
|
||||
<adf-start-process
|
||||
[appId]="appId"
|
||||
(start)="onStartProcessInstance($event)"
|
||||
(cancel)="onCancelProcessInstance()">
|
||||
</adf-start-process>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -192,6 +192,11 @@ export class ActivitiDemoComponent implements AfterViewInit, OnDestroy, OnInit {
|
||||
this.currentTaskId = event.id;
|
||||
}
|
||||
|
||||
onCancelStartTask() {
|
||||
this.currentTaskId = null;
|
||||
this.reloadTaskFilters();
|
||||
}
|
||||
|
||||
onSuccessTaskList(event: FilterRepresentationModel) {
|
||||
this.currentTaskId = this.taskList.getCurrentId();
|
||||
}
|
||||
@ -248,6 +253,11 @@ export class ActivitiDemoComponent implements AfterViewInit, OnDestroy, OnInit {
|
||||
this.resetProcessFilters();
|
||||
}
|
||||
|
||||
onCancelProcessInstance() {
|
||||
this.currentProcessInstanceId = null;
|
||||
this.reloadProcessFilters();
|
||||
}
|
||||
|
||||
isStartProcessMode(): boolean {
|
||||
return this.currentProcessInstanceId === currentProcessIdNew;
|
||||
}
|
||||
@ -334,11 +344,11 @@ export class ActivitiDemoComponent implements AfterViewInit, OnDestroy, OnInit {
|
||||
}
|
||||
|
||||
private reloadProcessFilters(): void {
|
||||
this.activitiprocessfilter.selectFilter(null);
|
||||
this.activitiprocessfilter.selectFilter(this.activitiprocessfilter.getCurrentFilter());
|
||||
}
|
||||
|
||||
private reloadTaskFilters(): void {
|
||||
this.activitifilter.selectFilter(null);
|
||||
this.activitifilter.selectFilter(this.activitifilter.getCurrentFilter());
|
||||
}
|
||||
|
||||
onRowClick(event): void {
|
||||
|
@ -514,7 +514,7 @@ This component Creates/Starts new task for the specified app
|
||||
|
||||
| Name | Description |
|
||||
| --- | --- |
|
||||
| onSuccess | Raised when the task is successfully created |
|
||||
| success | Raised when the task is successfully created |
|
||||
| cancel | Raised when the cancel button is pressed by the user |
|
||||
| error | Raised if there is an error during task creation |
|
||||
|
||||
|
@ -133,7 +133,7 @@ describe('StartTaskComponent', () => {
|
||||
});
|
||||
|
||||
it('should create new task when start is clicked', async(() => {
|
||||
activitiStartTaskComponent.onSuccess.subscribe((res) => {
|
||||
activitiStartTaskComponent.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
});
|
||||
activitiStartTaskComponent.appId = 'fakeAppId';
|
||||
@ -144,8 +144,8 @@ describe('StartTaskComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should send on onSuccess event when the task is started', async(() => {
|
||||
activitiStartTaskComponent.onSuccess.subscribe((res) => {
|
||||
it('should send on success event when the task is started', async(() => {
|
||||
activitiStartTaskComponent.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res.id).toBe(91);
|
||||
expect(res.name).toBe('fakeName');
|
||||
@ -175,8 +175,8 @@ describe('StartTaskComponent', () => {
|
||||
});
|
||||
}));
|
||||
|
||||
it('should send on onSuccess event when only name is given', async(() => {
|
||||
activitiStartTaskComponent.onSuccess.subscribe((res) => {
|
||||
it('should send on success event when only name is given', async(() => {
|
||||
activitiStartTaskComponent.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
});
|
||||
activitiStartTaskComponent.appId = 'fakeAppId';
|
||||
@ -191,7 +191,7 @@ describe('StartTaskComponent', () => {
|
||||
}));
|
||||
|
||||
it('should attach a task when a form id selected', () => {
|
||||
activitiStartTaskComponent.onSuccess.subscribe((res) => {
|
||||
activitiStartTaskComponent.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res.formKey).toBe('4');
|
||||
});
|
||||
@ -201,13 +201,13 @@ describe('StartTaskComponent', () => {
|
||||
expect(getcreateNewTaskSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not emit onSuccess event when data not present', async(() => {
|
||||
let onSuccessSpy: jasmine.Spy = spyOn(activitiStartTaskComponent.onSuccess, 'emit');
|
||||
it('should not emit success event when data not present', async(() => {
|
||||
let successSpy: jasmine.Spy = spyOn(activitiStartTaskComponent.success, 'emit');
|
||||
activitiStartTaskComponent.startTaskmodel = new StartTaskModel(null);
|
||||
activitiStartTaskComponent.start();
|
||||
fixture.detectChanges();
|
||||
expect(getcreateNewTaskSpy).not.toHaveBeenCalled();
|
||||
expect(onSuccessSpy).not.toHaveBeenCalled();
|
||||
expect(successSpy).not.toHaveBeenCalled();
|
||||
}));
|
||||
});
|
||||
|
||||
|
@ -35,7 +35,7 @@ export class StartTaskComponent implements OnInit {
|
||||
appId: string;
|
||||
|
||||
@Output()
|
||||
onSuccess: EventEmitter<any> = new EventEmitter<any>();
|
||||
success: EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
@Output()
|
||||
cancel: EventEmitter<void> = new EventEmitter<void>();
|
||||
@ -75,7 +75,7 @@ export class StartTaskComponent implements OnInit {
|
||||
this.startTaskmodel.category = this.appId;
|
||||
this.taskService.createNewTask(new TaskDetailsModel(this.startTaskmodel)).subscribe(
|
||||
(res: any) => {
|
||||
this.onSuccess.emit(res);
|
||||
this.success.emit(res);
|
||||
this.attachForm(res.id);
|
||||
this.resetForm();
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user