From d867d5f4a9ef544bf717f80f29f85fefca2c203e Mon Sep 17 00:00:00 2001 From: siva kumar Date: Tue, 6 Mar 2018 19:29:25 +0530 Subject: [PATCH] [ADF-2412] Task List - refactoring. (#3034) * Removed initStream method. --- .../components/task-list.component.ts | 56 +++++++------------ 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/lib/process-services/task-list/components/task-list.component.ts b/lib/process-services/task-list/components/task-list.component.ts index 808dac9255..592a8c4e4a 100644 --- a/lib/process-services/task-list/components/task-list.component.ts +++ b/lib/process-services/task-list/components/task-list.component.ts @@ -39,7 +39,6 @@ import { EventEmitter, Input, OnChanges, - OnInit, Output, SimpleChanges } from '@angular/core'; @@ -56,7 +55,7 @@ import { TaskListService } from './../services/tasklist.service'; templateUrl: './task-list.component.html', styleUrls: ['./task-list.component.css'] }) -export class TaskListComponent implements OnChanges, OnInit, AfterContentInit, PaginatedComponent { +export class TaskListComponent implements OnChanges, AfterContentInit, PaginatedComponent { requestNode: TaskQueryRequestRepresentationModel; @@ -159,7 +158,6 @@ export class TaskListComponent implements OnChanges, OnInit, AfterContentInit, P * @memberOf TaskListComponent */ hasCustomDataSource: boolean = false; - isStreamLoaded = false; constructor(private taskListService: TaskListService, private appConfig: AppConfigService, @@ -176,39 +174,12 @@ export class TaskListComponent implements OnChanges, OnInit, AfterContentInit, P }); } - initStream() { - if (!this.isStreamLoaded) { - this.isStreamLoaded = true; - this.taskListService.tasksList$.subscribe( - (tasks) => { - let instancesRow = this.createDataRow(tasks.data); - this.renderInstances(instancesRow); - this.selectTask(this.landingTaskId); - this.success.emit(tasks); - this.isLoading = false; - this.pagination.next({ - count: tasks.data.length, - maxItems: this.size, - skipCount: this.page * this.size, - totalItems: tasks.total - }); - }, (error) => { - this.error.emit(error); - this.isLoading = false; - }); - } - } - - ngOnInit() { - if (this.data === undefined) { - this.data = new ObjectDataTableAdapter(); - } - this.initStream(); - } - ngAfterContentInit() { this.loadLayoutPresets(); this.setupSchema(); + if (this.appId) { + this.reload(); + } } /** @@ -225,7 +196,6 @@ export class TaskListComponent implements OnChanges, OnInit, AfterContentInit, P } ngOnChanges(changes: SimpleChanges) { - this.initStream(); if (this.isPropertyChanged(changes)) { this.reload(); } @@ -264,7 +234,23 @@ export class TaskListComponent implements OnChanges, OnInit, AfterContentInit, P private load(requestNode: TaskQueryRequestRepresentationModel) { this.isLoading = true; - this.loadTasksByState().subscribe(); + this.loadTasksByState().subscribe( + (tasks) => { + let instancesRow = this.createDataRow(tasks.data); + this.renderInstances(instancesRow); + this.selectTask(this.landingTaskId); + this.success.emit(tasks); + this.isLoading = false; + this.pagination.next({ + count: tasks.data.length, + maxItems: this.size, + skipCount: this.page * this.size, + totalItems: tasks.total + }); + }, (error) => { + this.error.emit(error); + this.isLoading = false; + }); } private loadTasksByState(): Observable {