mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
[ADF-2412] Task List - refactoring. (#3034)
* Removed initStream method.
This commit is contained in:
parent
43ce4a195a
commit
d867d5f4a9
@ -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<TaskListModel> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user