Merge pull request #824 from Alfresco/dev-mvitale-807

Comment and Checklist diplayed are not for the correct task
This commit is contained in:
Denys Vuika 2016-09-27 15:46:23 +01:00 committed by GitHub
commit be36bc98d8
5 changed files with 38 additions and 31 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -159,14 +159,6 @@ export class ActivitiTaskDetails implements OnInit, OnChanges {
this.taskPeople.push(new User(user)); 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 { } else {