diff --git a/ng2-components/ng2-activiti-form/src/components/activiti-form.component.ts b/ng2-components/ng2-activiti-form/src/components/activiti-form.component.ts index 1e14a6846c..ca97208d71 100644 --- a/ng2-components/ng2-activiti-form/src/components/activiti-form.component.ts +++ b/ng2-components/ng2-activiti-form/src/components/activiti-form.component.ts @@ -15,7 +15,16 @@ * limitations under the License. */ -import { Component, OnInit, AfterViewChecked, OnChanges, SimpleChanges, Input, Output, EventEmitter } from '@angular/core'; +import { + Component, + OnInit, + AfterViewChecked, + OnChanges, + SimpleChanges, + Input, + Output, + EventEmitter +} from '@angular/core'; import { LogService } from 'ng2-alfresco-core'; import { EcmModelService } from './../services/ecm-model.service'; import { FormService } from './../services/form.service'; @@ -79,6 +88,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges { static SAVE_OUTCOME_ID: string = '$save'; static COMPLETE_OUTCOME_ID: string = '$complete'; + static START_PROCESS_OUTCOME_ID: string = '$startProcess'; static CUSTOM_OUTCOME_ID: string = '$custom'; @Input() @@ -185,6 +195,9 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges { if (outcome.name === FormOutcomeModel.SAVE_ACTION) { return this.showSaveButton; } + if (outcome.name === FormOutcomeModel.START_PROCESS_ACTION) { + return false; + } return true; } return false; @@ -247,6 +260,11 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges { return true; } + if (outcome.id === ActivitiForm.START_PROCESS_OUTCOME_ID) { + this.completeTaskForm(); + return true; + } + if (outcome.id === ActivitiForm.CUSTOM_OUTCOME_ID) { this.formSaved.emit(this.form); this.storeFormAsMetadata(); @@ -421,7 +439,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges { */ getFormDefinitionOutcomes(form: FormModel): FormOutcomeModel[] { return [ - new FormOutcomeModel(form, {id: '$custom', name: FormOutcomeModel.SAVE_ACTION, isSystem: true}) + new FormOutcomeModel(form, { id: '$custom', name: FormOutcomeModel.SAVE_ACTION, isSystem: true }) ]; } diff --git a/ng2-components/ng2-activiti-form/src/components/activiti-start-form.component.ts b/ng2-components/ng2-activiti-form/src/components/activiti-start-form.component.ts index 72e2028223..6800e87fc1 100644 --- a/ng2-components/ng2-activiti-form/src/components/activiti-start-form.component.ts +++ b/ng2-components/ng2-activiti-form/src/components/activiti-start-form.component.ts @@ -15,7 +15,17 @@ * limitations under the License. */ -import { Component, AfterViewChecked, OnChanges, SimpleChanges, Input, ViewChild, ElementRef, Output, EventEmitter } from '@angular/core'; +import { + Component, + AfterViewChecked, + OnChanges, + SimpleChanges, + Input, + ViewChild, + ElementRef, + Output, + EventEmitter +} from '@angular/core'; import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core'; import { ActivitiForm } from './activiti-form.component'; import { FormService } from './../services/form.service'; @@ -124,8 +134,11 @@ export class ActivitiStartForm extends ActivitiForm implements AfterViewChecked, /** @override */ isOutcomeButtonVisible(outcome: FormOutcomeModel): boolean { - if (outcome && outcome.name === FormOutcomeModel.SAVE_ACTION) { + if (outcome && outcome.isSystem && ( outcome.name === FormOutcomeModel.SAVE_ACTION || + outcome.name === FormOutcomeModel.COMPLETE_ACTION )) { return false; + } else if (outcome && outcome.name === FormOutcomeModel.START_PROCESS_ACTION) { + return true; } return super.isOutcomeButtonVisible(outcome); } diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/core/form-outcome.model.ts b/ng2-components/ng2-activiti-form/src/components/widgets/core/form-outcome.model.ts index 219ddb7a41..2e0baed29b 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/core/form-outcome.model.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/core/form-outcome.model.ts @@ -22,6 +22,7 @@ export class FormOutcomeModel extends FormWidgetModel { static SAVE_ACTION: string = 'Save'; // Activiti 'Save' action name static COMPLETE_ACTION: string = 'Complete'; // Activiti 'Complete' action name + static START_PROCESS_ACTION: string = 'Start Process'; // Activiti 'Start Process' action name isSystem: boolean = false; diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/core/form.model.spec.ts b/ng2-components/ng2-activiti-form/src/components/widgets/core/form.model.spec.ts index f61ab81c1c..c48bfad2e7 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/core/form.model.spec.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/core/form.model.spec.ts @@ -270,13 +270,16 @@ describe('FormModel', () => { }; let form = new FormModel(json); - expect(form.outcomes.length).toBe(2); + expect(form.outcomes.length).toBe(3); expect(form.outcomes[0].id).toBe(FormModel.SAVE_OUTCOME); expect(form.outcomes[0].isSystem).toBeTruthy(); expect(form.outcomes[1].id).toBe(FormModel.COMPLETE_OUTCOME); expect(form.outcomes[1].isSystem).toBeTruthy(); + + expect(form.outcomes[2].id).toBe(FormModel.START_PROCESS_OUTCOME); + expect(form.outcomes[2].isSystem).toBeTruthy(); }); it('should create outcomes only when fields available', () => { diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/core/form.model.ts b/ng2-components/ng2-activiti-form/src/components/widgets/core/form.model.ts index 73938624fb..d28fcc7e3d 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/core/form.model.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/core/form.model.ts @@ -29,6 +29,7 @@ export class FormModel { static UNSET_TASK_NAME: string = 'Nameless task'; static SAVE_OUTCOME: string = '$save'; static COMPLETE_OUTCOME: string = '$complete'; + static START_PROCESS_OUTCOME: string = '$startProcess'; readonly id: string; readonly name: string; @@ -103,11 +104,12 @@ export class FormModel { if (json.fields) { let saveOutcome = new FormOutcomeModel(this, { id: FormModel.SAVE_OUTCOME, name: 'Save', isSystem: true }); let completeOutcome = new FormOutcomeModel(this, {id: FormModel.COMPLETE_OUTCOME, name: 'Complete', isSystem: true }); + let startProcessOutcome = new FormOutcomeModel(this, { id: FormModel.START_PROCESS_OUTCOME, name: 'Start Process', isSystem: true }); let customOutcomes = (json.outcomes || []).map(obj => new FormOutcomeModel(this, obj)); this.outcomes = [saveOutcome].concat( - customOutcomes.length > 0 ? customOutcomes : [completeOutcome] + customOutcomes.length > 0 ? customOutcomes : [completeOutcome, startProcessOutcome] ); } }