Skip to content

Commit

Permalink
feat(ui): use new all tasks filter for both admin and non admin (#243)
Browse files Browse the repository at this point in the history
Signed-off-by: richardlt <[email protected]>
  • Loading branch information
richardlt authored Feb 25, 2021
1 parent 3d48577 commit cab9622
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,26 +268,10 @@ export class TasksListComponent implements OnInit, OnDestroy, OnChanges, AfterVi
}

loadTasks(paramLast: string = ''): Observable<Array<Task>> {
// Trick to get both own and resolvable task for non admin user
// We ignore the last param for resolvable tasks so we will only get the first ones
if (this.params.type === TaskType.both) {
return forkJoin({
resolvable: this._api.task.list({
...this.params,
type: TaskType.resolvable
}),
own: this._api.task.list({
...this.params,
type: TaskType.own,
last: paramLast
})
}).pipe(map(r => r.own.body.concat(r.resolvable.body)));
} else {
return this._api.task.list({
...this.params,
last: paramLast
}).pipe(map(res => res.body));
}
return this._api.task.list({
...this.params,
last: paramLast
}).pipe(map(res => res.body));
}

clickShowMore(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class ResolutionStep {
export enum TaskType {
all = 'all',
own = 'own',
both = 'both',
resolvable = 'resolvable'
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ export class TasksComponent implements OnInit {
const params = new ParamsListTasks();
const pageSize = parseInt(queryParams.page_size, 10)
params.page_size = pageSize && 10 <= pageSize && pageSize <= 1000 ? pageSize : 10;
const defaultType = this.meta.user_is_admin ? TaskType.all : TaskType.both;
params.type = queryParams.type || defaultType;
params.type = queryParams.type || TaskType.all;
params.last = '';
params.state = queryParams.state || '';
params.template = queryParams.template || '';
params.template = queryParams.template || '';
params.tag = queryParams.tag ? JSON.parse(queryParams.tag) : [];
return params;
}
Expand Down

0 comments on commit cab9622

Please sign in to comment.