mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
Merge pull request #1330 from Alfresco/dev-mvitale-1308
Start process - custom outcome
This commit is contained in:
commit
636fa770b4
@ -102,7 +102,7 @@ describe('ActivitiStartForm', () => {
|
||||
component.ngOnInit();
|
||||
});
|
||||
|
||||
it('should not show outcome buttons by default', () => {
|
||||
it('should show outcome buttons by default', () => {
|
||||
getStartFormSpy.and.returnValue(Observable.of({
|
||||
id: '1',
|
||||
processDefinitionName: 'my:process',
|
||||
@ -114,7 +114,7 @@ describe('ActivitiStartForm', () => {
|
||||
component.processDefinitionId = exampleId1;
|
||||
component.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
expect(component.outcomesContainer).not.toBeTruthy();
|
||||
expect(component.outcomesContainer).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should show outcome buttons if showOutcomeButtons is true', () => {
|
||||
|
@ -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';
|
||||
@ -37,8 +39,7 @@ import { WidgetVisibilityService } from './../services/widget-visibility.servic
|
||||
*
|
||||
* @Input
|
||||
* {processDefinitionId} string: The process definition ID
|
||||
* {showOutcomeButtons} boolean: Whether form outcome buttons should be shown, as yet these don't do anything so this
|
||||
* is false by default
|
||||
* {showOutcomeButtons} boolean: Whether form outcome buttons should be shown, this is now always active to show form outcomes
|
||||
* @Output
|
||||
* {formLoaded} EventEmitter - This event is fired when the form is loaded, it pass all the value in the form.
|
||||
* {formSaved} EventEmitter - This event is fired when the form is saved, it pass all the value in the form.
|
||||
@ -61,11 +62,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 +149,6 @@ export class ActivitiStartForm extends ActivitiForm implements OnInit, AfterView
|
||||
}
|
||||
|
||||
completeTaskForm(outcome?: string) {
|
||||
this.outcomeClick.emit(outcome);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -171,7 +171,7 @@ describe('ActivitiStartProcessInstance', () => {
|
||||
component.onProcessDefChange('my:process1');
|
||||
component.startProcess();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(startProcessSpy).toHaveBeenCalledWith('my:process1', 'My new process', undefined);
|
||||
expect(startProcessSpy).toHaveBeenCalledWith('my:process1', 'My new process', undefined, undefined);
|
||||
});
|
||||
}));
|
||||
|
||||
@ -262,10 +262,10 @@ describe('ActivitiStartProcessInstance', () => {
|
||||
expect(getStartFormDefinitionSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should leave start button disabled when mandatory fields not filled out', async(() => {
|
||||
it('should not show the start process button', async(() => {
|
||||
component.name = 'My new process';
|
||||
fixture.detectChanges();
|
||||
expect(startBtn.properties['disabled']).toBe(true);
|
||||
expect(startBtn).toBeNull();
|
||||
}));
|
||||
|
||||
});
|
||||
|
@ -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 = '';
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user