Fix taskId parameter to getTaskComment

This commit is contained in:
mauriziovitale84 2016-09-27 14:14:57 +01:00
parent d39913491f
commit 6d8cc05f68
5 changed files with 38 additions and 31 deletions

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { Component, Input, OnInit, ViewChild, OnChanges, SimpleChanges } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { ActivitiProcessService } from './../services/activiti-process.service';
import { Comment } from '../models/comment.model';
@ -29,9 +29,10 @@ declare let __moduleName: string;
selector: 'activiti-process-instance-comments',
moduleId: __moduleName,
templateUrl: './activiti-comments.component.html',
styleUrls: ['./activiti-comments.component.css']
styleUrls: ['./activiti-comments.component.css'],
providers: [ActivitiProcessService]
})
export class ActivitiComments implements OnInit {
export class ActivitiComments implements OnInit, OnChanges {
@Input()
processInstanceId: string;
@ -46,6 +47,11 @@ export class ActivitiComments implements OnInit {
message: string;
/**
* Constructor
* @param auth
* @param translate
*/
constructor(private translate: AlfrescoTranslationService,
private activitiProcess: ActivitiProcessService) {
@ -61,16 +67,20 @@ export class ActivitiComments implements OnInit {
this.comment$.subscribe((comment: Comment) => {
this.comments.push(comment);
});
}
if (this.processInstanceId) {
this.load(this.processInstanceId);
ngOnChanges(changes: SimpleChanges) {
let processInstanceId = changes['processInstanceId'];
if (processInstanceId && processInstanceId.currentValue) {
this.getProcessComments(processInstanceId.currentValue);
return;
}
}
public load(taskId: string) {
public getProcessComments(processInstanceId: string) {
this.comments = [];
if (this.processInstanceId) {
this.activitiProcess.getProcessInstanceComments(this.processInstanceId).subscribe(
if (processInstanceId) {
this.activitiProcess.getProcessInstanceComments(processInstanceId).subscribe(
(res: Comment[]) => {
res.forEach((comment) => {
this.commentObserver.next(comment);

View File

@ -106,9 +106,6 @@ export class ActivitiProcessInstanceDetails implements OnInit, OnChanges {
(res: ProcessInstance) => {
this.processInstanceDetails = res;
if (this.processInstanceDetails) {
if (this.commentsList) {
this.commentsList.load(this.processInstanceDetails.id);
}
if (this.tasksList) {
this.tasksList.load(this.processInstanceDetails.id);
}

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { Component, Input, OnInit, ViewChild, OnChanges, SimpleChanges } from '@angular/core';
import { AlfrescoTranslationService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { TaskDetailsModel } from '../models/task-details.model';
@ -32,7 +32,7 @@ declare let __moduleName: string;
styleUrls: ['./activiti-checklist.component.css'],
providers: [ActivitiTaskListService]
})
export class ActivitiChecklist implements OnInit {
export class ActivitiChecklist implements OnInit, OnChanges {
@Input()
taskId: string;
@ -66,13 +66,17 @@ export class ActivitiChecklist implements OnInit {
this.task$.subscribe((task: TaskDetailsModel) => {
this.checklist.push(task);
});
}
if (this.taskId) {
this.load(this.taskId);
ngOnChanges(changes: SimpleChanges) {
let taskId = changes['taskId'];
if (taskId && taskId.currentValue) {
this.getTaskChecklist(taskId.currentValue);
return;
}
}
public load(taskId: string) {
public getTaskChecklist(taskId: string) {
this.checklist = [];
if (this.taskId) {
this.activitiTaskList.getTaskChecklist(this.taskId).subscribe(

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { Component, Input, OnInit, ViewChild, OnChanges, SimpleChanges } from '@angular/core';
import { AlfrescoTranslationService, AlfrescoAuthenticationService } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { Comment } from '../models/comment.model';
@ -32,7 +32,7 @@ declare let __moduleName: string;
styleUrls: ['./activiti-comments.component.css'],
providers: [ActivitiTaskListService]
})
export class ActivitiComments implements OnInit {
export class ActivitiComments implements OnInit, OnChanges {
@Input()
taskId: string;
@ -68,16 +68,20 @@ export class ActivitiComments implements OnInit {
this.comment$.subscribe((comment: Comment) => {
this.comments.push(comment);
});
}
if (this.taskId) {
this.load(this.taskId);
ngOnChanges(changes: SimpleChanges) {
let taskId = changes['taskId'];
if (taskId && taskId.currentValue) {
this.getTaskComments(taskId.currentValue);
return;
}
}
public load(taskId: string) {
public getTaskComments(taskId: string) {
this.comments = [];
if (this.taskId) {
this.activitiTaskList.getTaskComments(this.taskId).subscribe(
if (taskId) {
this.activitiTaskList.getTaskComments(taskId).subscribe(
(res: Comment[]) => {
res.forEach((comment) => {
this.commentObserver.next(comment);

View File

@ -159,14 +159,6 @@ export class ActivitiTaskDetails implements OnInit, OnChanges {
this.taskPeople.push(new User(user));
});
}
if (this.activiticomments) {
this.activiticomments.load(this.taskDetails.id);
}
if (this.activitichecklist) {
this.activitichecklist.load(this.taskDetails.id);
}
}
);
} else {