#fix custom outcome

This commit is contained in:
mauriziovitale84
2016-12-19 17:36:30 +00:00
parent b9c7b60fb6
commit 8e707e7d9b
6 changed files with 34 additions and 12 deletions

View File

@@ -21,7 +21,9 @@ import {
SimpleChanges,
Input,
ViewChild,
ElementRef
ElementRef,
Output,
EventEmitter
} from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { ActivitiForm } from './activiti-form.component';
@@ -61,11 +63,14 @@ export class ActivitiStartForm extends ActivitiForm implements OnInit, AfterView
processId: string;
@Input()
showOutcomeButtons: boolean = false;
showOutcomeButtons: boolean = true;
@Input()
showRefreshButton: boolean = true;
@Output()
outcomeClick: EventEmitter<any> = new EventEmitter<any>();
@ViewChild('outcomesContainer', {})
outcomesContainer: ElementRef = null;
@@ -145,5 +150,6 @@ export class ActivitiStartForm extends ActivitiForm implements OnInit, AfterView
}
completeTaskForm(outcome?: string) {
this.outcomeClick.emit(outcome);
}
}

View File

@@ -317,11 +317,23 @@ export class FormFieldModel extends FormWidgetModel {
this.form.values[this.id] = this.enableFractions ? parseFloat(this.value) : parseInt(this.value, 10);
break;
default:
if (!FormFieldTypes.isReadOnlyType(this.type)) {
if (!FormFieldTypes.isReadOnlyType(this.type) && !this.isInvalidFieldType(this.type)) {
this.form.values[this.id] = this.value;
}
}
this.form.onFormFieldChanged(this);
}
/**
* Skip the invalid field type
* @param type
*/
isInvalidFieldType(type: string) {
if (type === 'container') {
return true;
} else {
return false;
}
}
}

View File

@@ -18,13 +18,10 @@
<label class="mdl-textfield__label" for="processName">{{'START_PROCESS.DIALOG.LABEL.NAME'|translate}}</label>
</div>
<activiti-start-form *ngIf="hasStartForm()" [processDefinitionId]="currentProcessDef.id"
(formSaved)="onFormSaved($event)"
(formCompleted)="onFormCompleted($event)"
(formLoaded)="onFormLoaded($event)"
(onError)="onFormError($event)">
(outcomeClick)="onOutcomeClick($event)">
</activiti-start-form>
</div>
<div class="mdl-card__actions mdl-card--border" *ngIf="showStartButton">
<div class="mdl-card__actions mdl-card--border" *ngIf="!hasStartForm()">
<button type="button" [disabled]="!validateForm()" (click)="startProcess()" class="mdl-button" data-automation-id="btn-start">{{'START_PROCESS.DIALOG.ACTION.START'|translate}}</button>
</div>
</div>

View File

@@ -86,11 +86,11 @@ export class ActivitiStartProcessInstance implements OnInit, OnChanges {
);
}
public startProcess() {
public startProcess(outcome?: string) {
if (this.currentProcessDef.id && this.name) {
this.resetErrorMessage();
let formValues = this.startForm ? this.startForm.form.values : undefined;
this.activitiProcess.startProcess(this.currentProcessDef.id, this.name, formValues).subscribe(
this.activitiProcess.startProcess(this.currentProcessDef.id, this.name, outcome, formValues).subscribe(
(res) => {
this.name = '';
this.start.emit(res);
@@ -134,6 +134,10 @@ export class ActivitiStartProcessInstance implements OnInit, OnChanges {
this.errorMessageId = '';
}
public onOutcomeClick(outcome: string) {
this.startProcess(outcome);
}
public reset() {
this.resetSelectedProcessDefinition();
this.name = '';

View File

@@ -202,7 +202,7 @@ describe('ActivitiProcessService', () => {
type: 'ford',
color: 'red'
};
service.startProcess(processDefId, processName, formParams);
service.startProcess(processDefId, processName, null, formParams);
expect(startNewProcessInstance).toHaveBeenCalledWith({
name: processName,
processDefinitionId: processDefId,

View File

@@ -231,11 +231,14 @@ export class ActivitiProcessService {
.catch(this.handleError);
}
startProcess(processDefinitionId: string, name: string, startFormValues?: any): Observable<ProcessInstance> {
startProcess(processDefinitionId: string, name: string, outcome?: string, startFormValues?: any): Observable<ProcessInstance> {
let startRequest: any = {
name: name,
processDefinitionId: processDefinitionId
};
if (outcome) {
startRequest.outcome = outcome;
}
if (startFormValues) {
startRequest.values = startFormValues;
}