mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
* #1432 - Added system outcome for start process * 1432 - improved condition for system outcome check * #1432 - fix test for start process system outcome
This commit is contained in:
parent
0fa87bb17d
commit
fcdc628d35
@ -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 })
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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', () => {
|
||||
|
@ -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]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user