mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
Merge pull request #1162 from Alfresco/dev-valbano-1143-fix
#1143 - Fix double element on start process
This commit is contained in:
commit
eed6902428
@ -72,12 +72,6 @@ describe('ActivitiProcessInstanceDetails', () => {
|
||||
window['componentHandler'] = componentHandler;
|
||||
});
|
||||
|
||||
it('should load task details when processInstanceId specified', () => {
|
||||
component.processInstanceId = '123';
|
||||
fixture.detectChanges();
|
||||
expect(getProcessSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not load task details when no processInstanceId is specified', () => {
|
||||
fixture.detectChanges();
|
||||
expect(getProcessSpy).not.toHaveBeenCalled();
|
||||
@ -89,8 +83,8 @@ describe('ActivitiProcessInstanceDetails', () => {
|
||||
});
|
||||
|
||||
it('should display a header when the processInstanceId is provided', async(() => {
|
||||
component.processInstanceId = '123';
|
||||
fixture.detectChanges();
|
||||
component.ngOnChanges({ 'processInstanceId': new SimpleChange(null, '123') });
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let headerEl: DebugElement = fixture.debugElement.query(By.css('h2'));
|
||||
@ -118,11 +112,6 @@ describe('ActivitiProcessInstanceDetails', () => {
|
||||
expect(getProcessSpy).toHaveBeenCalledWith('456');
|
||||
});
|
||||
|
||||
it('should reload tasks list when processInstanceId changed', () => {
|
||||
component.ngOnChanges({ 'processInstanceId': change });
|
||||
expect(component.tasksList.load).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should NOT fetch new process details when empty changeset made', () => {
|
||||
component.ngOnChanges({});
|
||||
expect(getProcessSpy).not.toHaveBeenCalled();
|
||||
|
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, ViewChild, Output, EventEmitter, OnInit, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { Component, Input, ViewChild, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||
import { ActivitiProcessService } from './../services/activiti-process.service';
|
||||
import { ActivitiProcessInstanceHeader } from './activiti-process-instance-header.component';
|
||||
@ -31,7 +31,7 @@ declare let componentHandler: any;
|
||||
templateUrl: './activiti-process-instance-details.component.html',
|
||||
styleUrls: ['./activiti-process-instance-details.component.css']
|
||||
})
|
||||
export class ActivitiProcessInstanceDetails implements OnInit, OnChanges {
|
||||
export class ActivitiProcessInstanceDetails implements OnChanges {
|
||||
|
||||
@Input()
|
||||
processInstanceId: string;
|
||||
@ -72,12 +72,6 @@ export class ActivitiProcessInstanceDetails implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.processInstanceId) {
|
||||
this.load(this.processInstanceId);
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
let processInstanceId = changes['processInstanceId'];
|
||||
if (processInstanceId && !processInstanceId.currentValue) {
|
||||
@ -102,11 +96,6 @@ export class ActivitiProcessInstanceDetails implements OnInit, OnChanges {
|
||||
this.activitiProcess.getProcess(processId).subscribe(
|
||||
(res: ProcessInstance) => {
|
||||
this.processInstanceDetails = res;
|
||||
if (this.processInstanceDetails) {
|
||||
if (this.tasksList) {
|
||||
this.tasksList.load(this.processInstanceDetails.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { DebugElement, NO_ERRORS_SCHEMA, SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
@ -52,7 +52,7 @@ describe('ActivitiProcessInstanceTasks', () => {
|
||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock },
|
||||
ActivitiProcessService
|
||||
],
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
@ -103,16 +103,13 @@ describe('ActivitiProcessInstanceTasks', () => {
|
||||
expect(listEl).toBeNull();
|
||||
});
|
||||
|
||||
it('should call service to get tasks on init', () => {
|
||||
component.processInstanceDetails = exampleProcessInstance;
|
||||
fixture.detectChanges();
|
||||
expect(getProcessTasksSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should display active tasks', () => {
|
||||
component.processInstanceDetails = exampleProcessInstance;
|
||||
let change = new SimpleChange(null, exampleProcessInstance);
|
||||
fixture.detectChanges();
|
||||
component.ngOnChanges({ 'processInstanceDetails': change });
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
component.ngOnChanges({ 'processInstanceDetails': change });
|
||||
let listEl = fixture.debugElement.query(By.css('[data-automation-id="active-tasks"]'));
|
||||
expect(listEl).not.toBeNull();
|
||||
expect(listEl.queryAll(By.css('li')).length).toBe(1);
|
||||
@ -120,9 +117,11 @@ describe('ActivitiProcessInstanceTasks', () => {
|
||||
});
|
||||
|
||||
it('should display completed tasks', () => {
|
||||
component.processInstanceDetails = exampleProcessInstance;
|
||||
let change = new SimpleChange(null, exampleProcessInstance);
|
||||
fixture.detectChanges();
|
||||
component.ngOnChanges({ 'processInstanceDetails': change });
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let listEl = fixture.debugElement.query(By.css('[data-automation-id="completed-tasks"]'));
|
||||
expect(listEl).not.toBeNull();
|
||||
expect(listEl.queryAll(By.css('li')).length).toBe(1);
|
||||
|
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnInit, ViewChild, Output, EventEmitter } from '@angular/core';
|
||||
import { Component, Input, OnInit, ViewChild, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||
import { ActivitiProcessService } from './../services/activiti-process.service';
|
||||
import { TaskDetailsModel } from 'ng2-activiti-tasklist';
|
||||
@ -32,7 +32,7 @@ declare let dialogPolyfill: any;
|
||||
templateUrl: './activiti-process-instance-tasks.component.html',
|
||||
styleUrls: ['./activiti-process-instance-tasks.component.css']
|
||||
})
|
||||
export class ActivitiProcessInstanceTasks implements OnInit {
|
||||
export class ActivitiProcessInstanceTasks implements OnInit, OnChanges {
|
||||
|
||||
@Input()
|
||||
processInstanceDetails: ProcessInstance;
|
||||
@ -84,9 +84,12 @@ export class ActivitiProcessInstanceTasks implements OnInit {
|
||||
this.completedTask$.subscribe((task: TaskDetailsModel) => {
|
||||
this.completedTasks.push(task);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.processInstanceDetails && this.processInstanceDetails.id) {
|
||||
this.load(this.processInstanceDetails.id);
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
let processInstanceDetails = changes['processInstanceDetails'];
|
||||
if (processInstanceDetails && processInstanceDetails.currentValue) {
|
||||
this.load(processInstanceDetails.currentValue.id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,7 +154,6 @@ export class ActivitiProcessInstanceTasks implements OnInit {
|
||||
|
||||
public clickTask($event: any, task: TaskDetailsModel) {
|
||||
this.selectedTaskId = task.id;
|
||||
this.taskdetails.loadDetails(task.id);
|
||||
this.showDialog();
|
||||
}
|
||||
|
||||
@ -189,6 +191,7 @@ export class ActivitiProcessInstanceTasks implements OnInit {
|
||||
if (this.dialog) {
|
||||
this.dialog.nativeElement.close();
|
||||
}
|
||||
this.selectedTaskId = null;
|
||||
}
|
||||
|
||||
public onTaskFormCompleted() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user