mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
@@ -20,6 +20,17 @@
|
|||||||
top: 4px;
|
top: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mdl-card {
|
||||||
|
width: 100%;
|
||||||
|
min-height: initial;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mdl-card .mdl-dialog__content {
|
||||||
|
width: 100%;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.mdl-dialog {
|
.mdl-dialog {
|
||||||
width: -moz-fit-content;
|
width: -moz-fit-content;
|
||||||
width: -webkit-fit-content;
|
width: -webkit-fit-content;
|
||||||
|
@@ -3,6 +3,9 @@
|
|||||||
<dialog class="mdl-dialog" #dialog>
|
<dialog class="mdl-dialog" #dialog>
|
||||||
<h4 class="mdl-dialog__title">{{'START_PROCESS.DIALOG.TITLE'|translate}}</h4>
|
<h4 class="mdl-dialog__title">{{'START_PROCESS.DIALOG.TITLE'|translate}}</h4>
|
||||||
<div class="mdl-dialog__content">
|
<div class="mdl-dialog__content">
|
||||||
|
<div class="mdl-card mdl-shadow--2dp error-message" *ngIf="errorMessageId">
|
||||||
|
<div class="mdl-card__supporting-text">{{errorMessageId|translate}}</div>
|
||||||
|
</div>
|
||||||
<div class="mdl-textfield mdl-js-textfield alf-mdl-selectfield">
|
<div class="mdl-textfield mdl-js-textfield alf-mdl-selectfield">
|
||||||
<select name="processDefinition" [(ngModel)]="currentProcessDef.id" (ngModelChange)="onProcessDefChange($event)" id="processDefinition" required>
|
<select name="processDefinition" [(ngModel)]="currentProcessDef.id" (ngModelChange)="onProcessDefChange($event)" id="processDefinition" required>
|
||||||
<option value="" selected="selected">{{'START_PROCESS.DIALOG.TYPE_PLACEHOLDER'|translate}}</option>
|
<option value="" selected="selected">{{'START_PROCESS.DIALOG.TYPE_PLACEHOLDER'|translate}}</option>
|
||||||
|
@@ -102,6 +102,16 @@ describe('ActivitiStartProcessButton', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should indicate an error to the user if process defs cannot be loaded', async(() => {
|
||||||
|
getDefinitionsSpy = getDefinitionsSpy.and.returnValue(Observable.throw({}));
|
||||||
|
fixture.detectChanges();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
let errorEl: DebugElement = debugElement.query(By.css('.error-message'));
|
||||||
|
expect(errorEl).not.toBeNull('Expected error message to be present');
|
||||||
|
expect(errorEl.nativeElement.innerText).toBe('START_PROCESS.ERROR.LOAD_PROCESS_DEFS');
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('input changes', () => {
|
describe('input changes', () => {
|
||||||
@@ -176,6 +186,29 @@ describe('ActivitiStartProcessButton', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should throw start event error when process cannot be started', async(() => {
|
||||||
|
let errorSpy = spyOn(component.start, 'error');
|
||||||
|
let error = { message: 'My error' };
|
||||||
|
startProcessSpy = startProcessSpy.and.returnValue(Observable.throw(error));
|
||||||
|
component.onProcessDefChange('my:process1');
|
||||||
|
component.startProcess();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
expect(errorSpy).toHaveBeenCalledWith(error);
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should indicate an error to the user if process cannot be started', async(() => {
|
||||||
|
startProcessSpy = startProcessSpy.and.returnValue(Observable.throw({}));
|
||||||
|
component.onProcessDefChange('my:process1');
|
||||||
|
component.startProcess();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
|
let errorEl: DebugElement = debugElement.query(By.css('.error-message'));
|
||||||
|
expect(errorEl).not.toBeNull();
|
||||||
|
expect(errorEl.nativeElement.innerText).toBe('START_PROCESS.ERROR.START');
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('start forms', () => {
|
describe('start forms', () => {
|
||||||
|
@@ -51,6 +51,8 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
|||||||
|
|
||||||
currentProcessDef: ProcessDefinitionRepresentation = new ProcessDefinitionRepresentation();
|
currentProcessDef: ProcessDefinitionRepresentation = new ProcessDefinitionRepresentation();
|
||||||
|
|
||||||
|
errorMessageId: string = '';
|
||||||
|
|
||||||
constructor(private translate: AlfrescoTranslationService,
|
constructor(private translate: AlfrescoTranslationService,
|
||||||
private activitiProcess: ActivitiProcessService) {
|
private activitiProcess: ActivitiProcessService) {
|
||||||
|
|
||||||
@@ -73,12 +75,13 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
|||||||
|
|
||||||
public load(appId: string) {
|
public load(appId: string) {
|
||||||
this.resetSelectedProcessDefinition();
|
this.resetSelectedProcessDefinition();
|
||||||
|
this.resetErrorMessage();
|
||||||
this.activitiProcess.getProcessDefinitions(appId).subscribe(
|
this.activitiProcess.getProcessDefinitions(appId).subscribe(
|
||||||
(res) => {
|
(res) => {
|
||||||
this.processDefinitions = res;
|
this.processDefinitions = res;
|
||||||
},
|
},
|
||||||
(err) => {
|
() => {
|
||||||
console.log(err);
|
this.errorMessageId = 'START_PROCESS.ERROR.LOAD_PROCESS_DEFS';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -92,6 +95,7 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
|||||||
|
|
||||||
public startProcess() {
|
public startProcess() {
|
||||||
if (this.currentProcessDef.id && this.name) {
|
if (this.currentProcessDef.id && this.name) {
|
||||||
|
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, formValues).subscribe(
|
||||||
(res) => {
|
(res) => {
|
||||||
@@ -100,7 +104,8 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
|||||||
this.cancel();
|
this.cancel();
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
console.log(err);
|
this.errorMessageId = 'START_PROCESS.ERROR.START';
|
||||||
|
this.start.error(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -135,11 +140,16 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
|||||||
this.currentProcessDef = new ProcessDefinitionRepresentation();
|
this.currentProcessDef = new ProcessDefinitionRepresentation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private resetErrorMessage(): void {
|
||||||
|
this.errorMessageId = '';
|
||||||
|
}
|
||||||
|
|
||||||
private reset() {
|
private reset() {
|
||||||
this.resetSelectedProcessDefinition();
|
this.resetSelectedProcessDefinition();
|
||||||
this.name = '';
|
this.name = '';
|
||||||
if (this.startForm) {
|
if (this.startForm) {
|
||||||
this.startForm.data = {};
|
this.startForm.data = {};
|
||||||
}
|
}
|
||||||
|
this.resetErrorMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -52,6 +52,10 @@
|
|||||||
"START": "Start",
|
"START": "Start",
|
||||||
"CANCEL": "Cancel"
|
"CANCEL": "Cancel"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"ERROR": {
|
||||||
|
"LOAD_PROCESS_DEFS": "Could not load process definitions, please check you have access.",
|
||||||
|
"START": "Could start new process instance, please check you have permission."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user