+
+
{{errorMessageId|translate}}
@@ -21,15 +18,13 @@
+ (formSaved)='onFormSaved($event)'
+ (formCompleted)='onFormCompleted($event)'
+ (formLoaded)='onFormLoaded($event)'
+ (onError)='onFormError($event)'>
-
+
-
-
+
diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.spec.ts b/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.spec.ts
index 9dc1b5dee9..b6b833e34d 100644
--- a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.spec.ts
+++ b/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.spec.ts
@@ -24,14 +24,14 @@ import { ActivitiFormModule, FormService } from 'ng2-activiti-form';
import { TranslationMock } from './../assets/translation.service.mock';
import { newProcess, fakeProcessDefs, fakeProcessDefWithForm, taskFormMock } from './../assets/activiti-start-process.component.mock';
-import { ActivitiStartProcessButton } from './activiti-start-process.component';
+import { ActivitiStartProcessInstance } from './activiti-start-process.component';
import { ActivitiProcessService } from '../services/activiti-process.service';
-describe('ActivitiStartProcessButton', () => {
+describe('ActivitiStartProcessInstance', () => {
let componentHandler: any;
- let component: ActivitiStartProcessButton;
- let fixture: ComponentFixture
;
+ let component: ActivitiStartProcessInstance;
+ let fixture: ComponentFixture;
let processService: ActivitiProcessService;
let formService: FormService;
let getDefinitionsSpy: jasmine.Spy;
@@ -43,7 +43,7 @@ describe('ActivitiStartProcessButton', () => {
TestBed.configureTestingModule({
imports: [ CoreModule, ActivitiFormModule ],
declarations: [
- ActivitiStartProcessButton
+ ActivitiStartProcessInstance
],
providers: [
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
@@ -55,7 +55,7 @@ describe('ActivitiStartProcessButton', () => {
beforeEach(() => {
- fixture = TestBed.createComponent(ActivitiStartProcessButton);
+ fixture = TestBed.createComponent(ActivitiStartProcessInstance);
component = fixture.componentInstance;
debugElement = fixture.debugElement;
processService = fixture.debugElement.injector.get(ActivitiProcessService);
@@ -148,7 +148,6 @@ describe('ActivitiStartProcessButton', () => {
beforeEach(() => {
component.name = 'My new process';
- component.showDialog();
fixture.detectChanges();
});
@@ -218,7 +217,6 @@ describe('ActivitiStartProcessButton', () => {
beforeEach(async(() => {
component.name = 'My new process';
- component.showDialog();
fixture.detectChanges();
component.onProcessDefChange('my:process1');
fixture.whenStable();
@@ -248,7 +246,6 @@ describe('ActivitiStartProcessButton', () => {
beforeEach(() => {
getDefinitionsSpy.and.returnValue(Observable.of(fakeProcessDefWithForm));
- component.showDialog();
fixture.detectChanges();
component.onProcessDefChange('my:process1');
fixture.detectChanges();
@@ -275,67 +272,4 @@ describe('ActivitiStartProcessButton', () => {
});
- describe('cancel dialog', () => {
-
- let dialogPolyfill: any;
-
- let setupDialog = (definitions?: any) => {
- if (definitions) {
- getDefinitionsSpy.and.returnValue(Observable.of(definitions));
- }
- component.showDialog();
- fixture.detectChanges();
- component.onProcessDefChange('my:process1');
- fixture.detectChanges();
- };
-
- let clickCancelButton = () => {
- let closeButton: DebugElement = debugElement.query(By.css('[data-automation-id="btn-close"]'));
- closeButton.triggerEventHandler('click', null);
- };
-
- beforeEach(() => {
- dialogPolyfill = { registerDialog: (widget) => widget.showModal = () => {} };
- dialogPolyfill.registerDialog = spyOn(dialogPolyfill, 'registerDialog').and.callThrough();
- window['dialogPolyfill'] = dialogPolyfill;
- });
-
- it('should close dialog when cancel button clicked', async(() => {
- let closeSpy = spyOn(component.dialog.nativeElement, 'close');
- component.showDialog();
- fixture.detectChanges();
- clickCancelButton();
- expect(closeSpy).toHaveBeenCalled();
- }));
-
- it('should clear processId and name when dialog cancelled', async(() => {
- setupDialog();
- clickCancelButton();
- expect(component.currentProcessDef.id).toBeNull();
- expect(component.name).toBe('');
- }));
-
- it('should clear form values when dialog cancelled', async(() => {
- setupDialog(fakeProcessDefWithForm);
- fixture.whenStable().then(() => {
- component.startForm.data = {
- language: 'fr',
- upload: {}
- };
- fixture.detectChanges();
- clickCancelButton();
- expect(component.startForm.data['language']).toBeUndefined();
- expect(component.startForm.data['upload']).toBeUndefined();
- });
- }));
-
- it('should register dialog via polyfill', () => {
- fixture.detectChanges();
- component.dialog.nativeElement.showModal = null;
- component.showDialog();
- expect(dialogPolyfill.registerDialog).toHaveBeenCalledWith(component.dialog.nativeElement);
- });
-
- });
-
});
diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.ts b/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.ts
index 7a87a6b6be..6ccd4b936e 100644
--- a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.ts
+++ b/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process.component.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { Component, EventEmitter, Input, Output, OnInit, ViewChild, DebugElement, OnChanges, SimpleChanges } from '@angular/core';
+import { Component, EventEmitter, Input, Output, OnInit, ViewChild, OnChanges, SimpleChanges } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { ActivitiStartForm } from 'ng2-activiti-form';
import { ProcessInstance } from './../models/process-instance.model';
@@ -26,23 +26,23 @@ declare let componentHandler: any;
declare let dialogPolyfill: any;
@Component({
- selector: 'activiti-start-process-instance',
+ selector: 'activiti-start-process',
moduleId: module.id,
templateUrl: './activiti-start-process.component.html',
styleUrls: ['./activiti-start-process.component.css']
})
-export class ActivitiStartProcessButton implements OnInit, OnChanges {
+export class ActivitiStartProcessInstance implements OnInit, OnChanges {
@Input()
appId: string;
+ @Input()
+ showStartButton: boolean = true;
+
@Output()
start: EventEmitter = new EventEmitter();
- @ViewChild('dialog')
- dialog: DebugElement;
-
- @ViewChild('startForm')
+ @ViewChild(ActivitiStartForm)
startForm: ActivitiStartForm;
processDefinitions: ProcessDefinitionRepresentation[] = [];
@@ -86,13 +86,6 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
);
}
- public showDialog() {
- if (!this.dialog.nativeElement.showModal) {
- dialogPolyfill.registerDialog(this.dialog.nativeElement);
- }
- this.dialog.nativeElement.showModal();
- }
-
public startProcess() {
if (this.currentProcessDef.id && this.name) {
this.resetErrorMessage();
@@ -101,7 +94,6 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
(res) => {
this.name = '';
this.start.emit(res);
- this.cancel();
},
(err) => {
this.errorMessageId = 'START_PROCESS.ERROR.START';
@@ -111,11 +103,6 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
}
}
- public cancel() {
- this.reset();
- this.dialog.nativeElement.close();
- }
-
onProcessDefChange(processDefinitionId) {
let processDef = this.processDefinitions.find((processDefinition) => {
return processDefinition.id === processDefinitionId;
@@ -147,7 +134,7 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
this.errorMessageId = '';
}
- private reset() {
+ public reset() {
this.resetSelectedProcessDefinition();
this.name = '';
if (this.startForm) {