From 2083050a102f9548201eb58542a6ec2db24fc4b2 Mon Sep 17 00:00:00 2001 From: Will Abson Date: Wed, 14 Dec 2016 09:55:34 +0000 Subject: [PATCH] Remove start process dialog Refs #1253 --- .../ng2-activiti-processlist/index.ts | 5 +- ...ctiviti-start-process-dialog.component.css | 12 -- ...tiviti-start-process-dialog.component.html | 12 -- ...iti-start-process-dialog.component.spec.ts | 171 ------------------ ...activiti-start-process-dialog.component.ts | 78 -------- 5 files changed, 1 insertion(+), 277 deletions(-) delete mode 100644 ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.css delete mode 100644 ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.html delete mode 100644 ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.spec.ts delete mode 100644 ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.ts diff --git a/ng2-components/ng2-activiti-processlist/index.ts b/ng2-components/ng2-activiti-processlist/index.ts index 5f7bc642bc..7643a48bca 100644 --- a/ng2-components/ng2-activiti-processlist/index.ts +++ b/ng2-components/ng2-activiti-processlist/index.ts @@ -29,7 +29,6 @@ import { ActivitiProcessInstanceVariables } from './src/components/activiti-proc import { ActivitiComments } from './src/components/activiti-comments.component'; import { ActivitiProcessInstanceDetails } from './src/components/activiti-process-instance-details.component'; import { ActivitiStartProcessInstance } from './src/components/activiti-start-process.component'; -import { ActivitiStartProcessInstanceDialog } from './src/components/activiti-start-process-dialog.component'; import { ActivitiProcessService } from './src/services/activiti-process.service'; // components @@ -37,7 +36,6 @@ export * from './src/components/activiti-processlist.component'; export * from './src/components/activiti-filters.component'; export * from './src/components/activiti-process-instance-details.component'; export * from './src/components/activiti-start-process.component'; -export * from './src/components/activiti-start-process-dialog.component'; // models export * from './src/models/index'; @@ -53,8 +51,7 @@ export const ACTIVITI_PROCESSLIST_DIRECTIVES: [any] = [ ActivitiProcessInstanceTasks, ActivitiProcessInstanceVariables, ActivitiComments, - ActivitiStartProcessInstance, - ActivitiStartProcessInstanceDialog + ActivitiStartProcessInstance ]; export const ACTIVITI_PROCESSLIST_PROVIDERS: [any] = [ diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.css b/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.css deleted file mode 100644 index 04ff1685d2..0000000000 --- a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.css +++ /dev/null @@ -1,12 +0,0 @@ -:host { - width: 100%; -} - -.mdl-dialog { - width: 400px; - width: -moz-fit-content; - width: -webkit-fit-content; - width: -ms-fit-content; - width: -o-fit-content; - width: fit-content; -} diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.html b/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.html deleted file mode 100644 index d0271c5284..0000000000 --- a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.html +++ /dev/null @@ -1,12 +0,0 @@ - - - -

{{'START_PROCESS.DIALOG.TITLE'|translate}}

-
- -
-
- - -
-
diff --git a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.spec.ts b/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.spec.ts deleted file mode 100644 index 6fd482a8a0..0000000000 --- a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.spec.ts +++ /dev/null @@ -1,171 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { ComponentFixture, TestBed, async } from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; -import { DebugElement } from '@angular/core'; -import { Observable } from 'rxjs/Rx'; -import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core'; -import { ActivitiFormModule, FormService } from 'ng2-activiti-form'; - -import { TranslationMock } from './../assets/translation.service.mock'; -import { newProcess, fakeProcessDefs, taskFormMock } from './../assets/activiti-start-process.component.mock'; -import { ActivitiStartProcessInstance } from './activiti-start-process.component'; -import { ActivitiStartProcessInstanceDialog } from './activiti-start-process-dialog.component'; -import { ActivitiProcessService } from '../services/activiti-process.service'; - -describe('ActivitiStartProcessInstanceDialog', () => { - - let componentHandler: any; - let component: ActivitiStartProcessInstanceDialog; - let fixture: ComponentFixture; - let processService: ActivitiProcessService; - let formService: FormService; - let getDefinitionsSpy: jasmine.Spy; - let getStartFormDefinitionSpy: jasmine.Spy; - let startProcessSpy: jasmine.Spy; - let debugElement: DebugElement; - - const showBtnSelector = '[data-automation-id="btn-show"]'; - const startBtnSelector = '[data-automation-id="btn-start"]'; - const closeBtnSelector = '[data-automation-id="btn-close"]'; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ CoreModule, ActivitiFormModule ], - declarations: [ - ActivitiStartProcessInstance, - ActivitiStartProcessInstanceDialog - ], - providers: [ - { provide: AlfrescoTranslationService, useClass: TranslationMock }, - ActivitiProcessService - ] - }).compileComponents(); - })); - - beforeEach(() => { - - fixture = TestBed.createComponent(ActivitiStartProcessInstanceDialog); - component = fixture.componentInstance; - debugElement = fixture.debugElement; - processService = fixture.debugElement.injector.get(ActivitiProcessService); - formService = fixture.debugElement.injector.get(FormService); - - getDefinitionsSpy = spyOn(processService, 'getProcessDefinitions').and.returnValue(Observable.of(fakeProcessDefs)); - startProcessSpy = spyOn(processService, 'startProcess').and.returnValue(Observable.of(newProcess)); - getStartFormDefinitionSpy = spyOn(formService, 'getStartFormDefinition').and.returnValue(Observable.of(taskFormMock)); - - componentHandler = jasmine.createSpyObj('componentHandler', [ - 'upgradeAllRegistered', - 'upgradeElement' - ]); - window['componentHandler'] = componentHandler; - }); - - describe('render dialog', () => { - - let buttonEl: DebugElement; - - it('should render a Start Process button by default', () => { - fixture.detectChanges(); - buttonEl = debugElement.query(By.css(showBtnSelector)); - expect(buttonEl).not.toBeNull(); - }); - - it('should not render the Start Process button when configured not to', () => { - component.showButton = false; - fixture.detectChanges(); - buttonEl = debugElement.query(By.css(showBtnSelector)); - expect(buttonEl).toBeNull(); - }); - - }); - - describe('open dialog', () => { - - it('should open dialog when button clicked', () => { - fixture.detectChanges(); - let showModalSpy = spyOn(component.dialog.nativeElement, 'showModal'); - let showButton: DebugElement = debugElement.query(By.css(showBtnSelector)); - showButton.triggerEventHandler('click', null); - expect(showModalSpy).toHaveBeenCalled(); - }); - - }); - - describe('start process', () => { - - it('should output start event when process started from inside inner component', () => { - let emitSpy = spyOn(component.start, 'emit'); - component.startProcessComponent.start.emit(newProcess); - expect(emitSpy).toHaveBeenCalledWith(newProcess); - }); - - it('should call inner component to start process when dialog Start button clicked', () => { - let startSpy = spyOn(component.startProcessComponent, 'startProcess').and.returnValue(null); - let closeButton: DebugElement = debugElement.query(By.css(startBtnSelector)); - closeButton.triggerEventHandler('click', null); - expect(startSpy).toHaveBeenCalled(); - }); - - }); - - describe('close dialog', () => { - - let dialogPolyfill: any; - - let setupDialog = () => { - component.showDialog(); - fixture.detectChanges(); - }; - - let clickCancelButton = () => { - let closeButton: DebugElement = debugElement.query(By.css(closeBtnSelector)); - 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 close button clicked', async(() => { - let closeSpy = spyOn(component.dialog.nativeElement, 'close'); - setupDialog(); - clickCancelButton(); - expect(closeSpy).toHaveBeenCalled(); - })); - - it('should reset embedded component when dialog cancelled', async(() => { - let resetSpy = spyOn(component.startProcessComponent, 'reset'); - setupDialog(); - clickCancelButton(); - expect(resetSpy).toHaveBeenCalled(); - })); - - 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-dialog.component.ts b/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.ts deleted file mode 100644 index 03cbc8df82..0000000000 --- a/ng2-components/ng2-activiti-processlist/src/components/activiti-start-process-dialog.component.ts +++ /dev/null @@ -1,78 +0,0 @@ -/*! - * @license - * Copyright 2016 Alfresco Software, Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Component, EventEmitter, Input, Output, ViewChild, DebugElement } from '@angular/core'; -import { AlfrescoTranslationService } from 'ng2-alfresco-core'; -import { ActivitiStartProcessInstance } from './activiti-start-process.component'; -import { ProcessInstance } from './../models/process-instance.model'; - -declare let componentHandler: any; -declare let dialogPolyfill: any; - -@Component({ - selector: 'activiti-start-process-dialog', - moduleId: module.id, - templateUrl: './activiti-start-process-dialog.component.html', - styleUrls: ['./activiti-start-process-dialog.component.css'] -}) -export class ActivitiStartProcessInstanceDialog { - - @Input() - appId: string; - - @Input() - showButton: boolean = true; - - @Output() - start: EventEmitter = new EventEmitter(); - - @ViewChild('dialog') - dialog: DebugElement; - - @ViewChild(ActivitiStartProcessInstance) - startProcessComponent: ActivitiStartProcessInstance; - - constructor(private translate: AlfrescoTranslationService) { - if (translate) { - translate.addTranslationFolder('node_modules/ng2-activiti-processlist/src'); - } - } - - public showDialog() { - if (!this.dialog.nativeElement.showModal) { - dialogPolyfill.registerDialog(this.dialog.nativeElement); - } - this.dialog.nativeElement.showModal(); - } - - validateForm() { - return this.startProcessComponent.validateForm(); - } - - public startProcess() { - this.startProcessComponent.startProcess(); - } - - public closeDialog() { - this.startProcessComponent.reset(); - this.dialog.nativeElement.close(); - } - - onStartProcessInstance(processInstance: ProcessInstance) { - this.start.emit(processInstance); - } -}