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();
|
component.ngOnInit();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not show outcome buttons by default', () => {
|
it('should show outcome buttons by default', () => {
|
||||||
getStartFormSpy.and.returnValue(Observable.of({
|
getStartFormSpy.and.returnValue(Observable.of({
|
||||||
id: '1',
|
id: '1',
|
||||||
processDefinitionName: 'my:process',
|
processDefinitionName: 'my:process',
|
||||||
@ -114,7 +114,7 @@ describe('ActivitiStartForm', () => {
|
|||||||
component.processDefinitionId = exampleId1;
|
component.processDefinitionId = exampleId1;
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(component.outcomesContainer).not.toBeTruthy();
|
expect(component.outcomesContainer).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show outcome buttons if showOutcomeButtons is true', () => {
|
it('should show outcome buttons if showOutcomeButtons is true', () => {
|
||||||
|
@ -21,7 +21,9 @@ import {
|
|||||||
SimpleChanges,
|
SimpleChanges,
|
||||||
Input,
|
Input,
|
||||||
ViewChild,
|
ViewChild,
|
||||||
ElementRef
|
ElementRef,
|
||||||
|
Output,
|
||||||
|
EventEmitter
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||||
import { ActivitiForm } from './activiti-form.component';
|
import { ActivitiForm } from './activiti-form.component';
|
||||||
@ -37,8 +39,7 @@ import { WidgetVisibilityService } from './../services/widget-visibility.servic
|
|||||||
*
|
*
|
||||||
* @Input
|
* @Input
|
||||||
* {processDefinitionId} string: The process definition ID
|
* {processDefinitionId} string: The process definition ID
|
||||||
* {showOutcomeButtons} boolean: Whether form outcome buttons should be shown, as yet these don't do anything so this
|
* {showOutcomeButtons} boolean: Whether form outcome buttons should be shown, this is now always active to show form outcomes
|
||||||
* is false by default
|
|
||||||
* @Output
|
* @Output
|
||||||
* {formLoaded} EventEmitter - This event is fired when the form is loaded, it pass all the value in the form.
|
* {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.
|
* {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;
|
processId: string;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
showOutcomeButtons: boolean = false;
|
showOutcomeButtons: boolean = true;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
showRefreshButton: boolean = true;
|
showRefreshButton: boolean = true;
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
outcomeClick: EventEmitter<any> = new EventEmitter<any>();
|
||||||
|
|
||||||
@ViewChild('outcomesContainer', {})
|
@ViewChild('outcomesContainer', {})
|
||||||
outcomesContainer: ElementRef = null;
|
outcomesContainer: ElementRef = null;
|
||||||
|
|
||||||
@ -145,5 +149,6 @@ export class ActivitiStartForm extends ActivitiForm implements OnInit, AfterView
|
|||||||
}
|
}
|
||||||
|
|
||||||
completeTaskForm(outcome?: string) {
|
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);
|
this.form.values[this.id] = this.enableFractions ? parseFloat(this.value) : parseInt(this.value, 10);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!FormFieldTypes.isReadOnlyType(this.type)) {
|
if (!FormFieldTypes.isReadOnlyType(this.type) && !this.isInvalidFieldType(this.type)) {
|
||||||
this.form.values[this.id] = this.value;
|
this.form.values[this.id] = this.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.form.onFormFieldChanged(this);
|
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>
|
<label class="mdl-textfield__label" for="processName">{{'START_PROCESS.DIALOG.LABEL.NAME'|translate}}</label>
|
||||||
</div>
|
</div>
|
||||||
<activiti-start-form *ngIf="hasStartForm()" [processDefinitionId]="currentProcessDef.id"
|
<activiti-start-form *ngIf="hasStartForm()" [processDefinitionId]="currentProcessDef.id"
|
||||||
(formSaved)="onFormSaved($event)"
|
(outcomeClick)="onOutcomeClick($event)">
|
||||||
(formCompleted)="onFormCompleted($event)"
|
|
||||||
(formLoaded)="onFormLoaded($event)"
|
|
||||||
(onError)="onFormError($event)">
|
|
||||||
</activiti-start-form>
|
</activiti-start-form>
|
||||||
</div>
|
</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>
|
<button type="button" [disabled]="!validateForm()" (click)="startProcess()" class="mdl-button" data-automation-id="btn-start">{{'START_PROCESS.DIALOG.ACTION.START'|translate}}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -171,7 +171,7 @@ describe('ActivitiStartProcessInstance', () => {
|
|||||||
component.onProcessDefChange('my:process1');
|
component.onProcessDefChange('my:process1');
|
||||||
component.startProcess();
|
component.startProcess();
|
||||||
fixture.whenStable().then(() => {
|
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();
|
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';
|
component.name = 'My new process';
|
||||||
fixture.detectChanges();
|
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) {
|
if (this.currentProcessDef.id && this.name) {
|
||||||
this.resetErrorMessage();
|
this.resetErrorMessage();
|
||||||
let formValues = this.startForm ? this.startForm.form.values : undefined;
|
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) => {
|
(res) => {
|
||||||
this.name = '';
|
this.name = '';
|
||||||
this.start.emit(res);
|
this.start.emit(res);
|
||||||
@ -134,6 +134,10 @@ export class ActivitiStartProcessInstance implements OnInit, OnChanges {
|
|||||||
this.errorMessageId = '';
|
this.errorMessageId = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public onOutcomeClick(outcome: string) {
|
||||||
|
this.startProcess(outcome);
|
||||||
|
}
|
||||||
|
|
||||||
public reset() {
|
public reset() {
|
||||||
this.resetSelectedProcessDefinition();
|
this.resetSelectedProcessDefinition();
|
||||||
this.name = '';
|
this.name = '';
|
||||||
|
@ -202,7 +202,7 @@ describe('ActivitiProcessService', () => {
|
|||||||
type: 'ford',
|
type: 'ford',
|
||||||
color: 'red'
|
color: 'red'
|
||||||
};
|
};
|
||||||
service.startProcess(processDefId, processName, formParams);
|
service.startProcess(processDefId, processName, null, formParams);
|
||||||
expect(startNewProcessInstance).toHaveBeenCalledWith({
|
expect(startNewProcessInstance).toHaveBeenCalledWith({
|
||||||
name: processName,
|
name: processName,
|
||||||
processDefinitionId: processDefId,
|
processDefinitionId: processDefId,
|
||||||
|
@ -231,11 +231,14 @@ export class ActivitiProcessService {
|
|||||||
.catch(this.handleError);
|
.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 = {
|
let startRequest: any = {
|
||||||
name: name,
|
name: name,
|
||||||
processDefinitionId: processDefinitionId
|
processDefinitionId: processDefinitionId
|
||||||
};
|
};
|
||||||
|
if (outcome) {
|
||||||
|
startRequest.outcome = outcome;
|
||||||
|
}
|
||||||
if (startFormValues) {
|
if (startFormValues) {
|
||||||
startRequest.values = startFormValues;
|
startRequest.values = startFormValues;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user