mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
AAE-2824: Managed to trigger executeOutcome when clicking on custom outcome buttons (#7873)
This commit is contained in:
@@ -191,7 +191,6 @@ export abstract class FormBaseComponent {
|
|||||||
} else {
|
} else {
|
||||||
// Note: Activiti is using NAME field rather than ID for outcomes
|
// Note: Activiti is using NAME field rather than ID for outcomes
|
||||||
if (outcome.name) {
|
if (outcome.name) {
|
||||||
this.onTaskSaved(this.form);
|
|
||||||
this.completeTaskForm(outcome.name);
|
this.completeTaskForm(outcome.name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -480,7 +480,7 @@ describe('FormCloudComponent', () => {
|
|||||||
|
|
||||||
const result = formComponent.onOutcomeClicked(outcome);
|
const result = formComponent.onOutcomeClicked(outcome);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
expect(saved).toBeTruthy();
|
expect(saved).toBeFalse();
|
||||||
expect(formComponent.completeTaskForm).toHaveBeenCalledWith(outcomeName);
|
expect(formComponent.completeTaskForm).toHaveBeenCalledWith(outcomeName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -14,7 +14,8 @@
|
|||||||
(formCompleted)="onFormCompleted($event)"
|
(formCompleted)="onFormCompleted($event)"
|
||||||
(formError)="onError($event)"
|
(formError)="onError($event)"
|
||||||
(error)="onError($event)"
|
(error)="onError($event)"
|
||||||
(formContentClicked)="onFormContentClicked($event)">
|
(formContentClicked)="onFormContentClicked($event)"
|
||||||
|
(executeOutcome)="onFormExecuteOutcome($event)">
|
||||||
<adf-cloud-form-custom-outcomes>
|
<adf-cloud-form-custom-outcomes>
|
||||||
<ng-template [ngTemplateOutlet]="taskFormCloudButtons">
|
<ng-template [ngTemplateOutlet]="taskFormCloudButtons">
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
@@ -19,7 +19,7 @@ import { DebugElement, SimpleChange } from '@angular/core';
|
|||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { setupTestBed } from '@alfresco/adf-core';
|
import { FormModel, FormOutcomeEvent, FormOutcomeModel, setupTestBed } from '@alfresco/adf-core';
|
||||||
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
|
||||||
import { TaskFormCloudComponent } from './task-form-cloud.component';
|
import { TaskFormCloudComponent } from './task-form-cloud.component';
|
||||||
import {
|
import {
|
||||||
@@ -400,6 +400,14 @@ describe('TaskFormCloudComponent', () => {
|
|||||||
|
|
||||||
expect(loadingTemplate).toBeNull();
|
expect(loadingTemplate).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should emit an executeOutcome event when form outcome executed', () => {
|
||||||
|
const executeOutcomeSpy: jasmine.Spy = spyOn(component.executeOutcome, 'emit');
|
||||||
|
|
||||||
|
component.onFormExecuteOutcome(new FormOutcomeEvent(new FormOutcomeModel(new FormModel())));
|
||||||
|
|
||||||
|
expect(executeOutcomeSpy).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display task name as title on no form template if showTitle is true', () => {
|
it('should display task name as title on no form template if showTitle is true', () => {
|
||||||
|
@@ -21,7 +21,7 @@ import {
|
|||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model';
|
import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model';
|
||||||
import { TaskCloudService } from '../../services/task-cloud.service';
|
import { TaskCloudService } from '../../services/task-cloud.service';
|
||||||
import { FormRenderingService, FormModel, ContentLinkModel } from '@alfresco/adf-core';
|
import { FormRenderingService, FormModel, ContentLinkModel, FormOutcomeEvent } from '@alfresco/adf-core';
|
||||||
import { AttachFileCloudWidgetComponent } from '../../../form/components/widgets/attach-file/attach-file-cloud-widget.component';
|
import { AttachFileCloudWidgetComponent } from '../../../form/components/widgets/attach-file/attach-file-cloud-widget.component';
|
||||||
import { DropdownCloudWidgetComponent } from '../../../form/components/widgets/dropdown/dropdown-cloud.widget';
|
import { DropdownCloudWidgetComponent } from '../../../form/components/widgets/dropdown/dropdown-cloud.widget';
|
||||||
import { DateCloudWidgetComponent } from '../../../form/components/widgets/date/date-cloud.widget';
|
import { DateCloudWidgetComponent } from '../../../form/components/widgets/date/date-cloud.widget';
|
||||||
@@ -98,6 +98,12 @@ export class TaskFormCloudComponent implements OnInit, OnChanges {
|
|||||||
@Output()
|
@Output()
|
||||||
formContentClicked: EventEmitter<ContentLinkModel> = new EventEmitter();
|
formContentClicked: EventEmitter<ContentLinkModel> = new EventEmitter();
|
||||||
|
|
||||||
|
/** Emitted when any outcome is executed. Default behaviour can be prevented
|
||||||
|
* via `event.preventDefault()`.
|
||||||
|
*/
|
||||||
|
@Output()
|
||||||
|
executeOutcome = new EventEmitter<FormOutcomeEvent>();
|
||||||
|
|
||||||
taskDetails: TaskDetailsCloudModel;
|
taskDetails: TaskDetailsCloudModel;
|
||||||
|
|
||||||
candidateUsers: string[] = [];
|
candidateUsers: string[] = [];
|
||||||
@@ -219,4 +225,8 @@ export class TaskFormCloudComponent implements OnInit, OnChanges {
|
|||||||
onFormContentClicked(content: ContentLinkModel) {
|
onFormContentClicked(content: ContentLinkModel) {
|
||||||
this.formContentClicked.emit(content);
|
this.formContentClicked.emit(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onFormExecuteOutcome(outcome: FormOutcomeEvent) {
|
||||||
|
this.executeOutcome.emit(outcome);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -378,7 +378,7 @@ describe('FormComponent', () => {
|
|||||||
|
|
||||||
const result = formComponent.onOutcomeClicked(outcome);
|
const result = formComponent.onOutcomeClicked(outcome);
|
||||||
expect(result).toBeTruthy();
|
expect(result).toBeTruthy();
|
||||||
expect(saved).toBeTruthy();
|
expect(saved).toBeFalse();
|
||||||
expect(formComponent.completeTaskForm).toHaveBeenCalledWith(outcomeName);
|
expect(formComponent.completeTaskForm).toHaveBeenCalledWith(outcomeName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user