TSK-1338: List now does not refresh after selection of a task

This commit is contained in:
Tristan Eisermann 2020-07-28 16:12:53 +02:00 committed by Tristan2357
parent beff8959a3
commit 418f37917d
5 changed files with 38 additions and 58 deletions

View File

@ -7,7 +7,7 @@ import { Sorting } from 'app/shared/models/sorting';
import { Filter } from 'app/shared/models/filter';
import { TaskanaType } from 'app/shared/models/taskana-type';
import { expandDown } from 'theme/animations/expand.animation';
import { ActivatedRoute, Router, NavigationExtras } from '@angular/router';
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
import { WorkplaceService } from 'app/workplace/services/workplace.service';
import { ObjectReference } from 'app/workplace/models/object-reference';
@ -15,6 +15,7 @@ export enum Search {
byWorkbasket = 'workbasket',
byTypeAndValue = 'type-and-value'
}
@Component({
selector: 'taskana-task-list-toolbar',
animations: [expandDown],
@ -94,7 +95,6 @@ export class TaskListToolbarComponent implements OnInit {
this.workplaceService.selectObjectReference(objectReference);
this.searched = true;
} else {
this.workplaceService.selectObjectReference();
if (this.workbaskets) {
this.workbaskets.forEach((workbasket) => {
if (workbasket.name === this.resultName) {
@ -141,5 +141,6 @@ export class TaskListToolbarComponent implements OnInit {
};
this.router.navigate([''], navigationExtras);
this.searchBasket();
}
}

View File

@ -23,7 +23,6 @@ export class TaskListComponent implements OnInit {
ngOnInit() {}
selectTask(taskId: string) {
this.workplaceService.selectObjectReference();
this.selectedId = taskId;
this.selectedIdChange.emit(taskId);
this.router.navigate([{ outlets: { detail: `taskdetail/${this.selectedId}` } }], { relativeTo: this.route });

View File

@ -39,7 +39,6 @@ export class TaskMasterComponent implements OnInit, OnDestroy {
});
requestInProgress = false;
objectReference: ObjectReference;
selectedSearchType: Search = Search.byWorkbasket;
destroy$ = new Subject();
@ -55,19 +54,18 @@ export class TaskMasterComponent implements OnInit, OnDestroy {
) {}
ngOnInit() {
this.taskService
.getSelectedTask()
.pipe(takeUntil(this.destroy$))
.subscribe((task: Task) => {
if (!this.currentBasket) {
this.selectedId = task.taskId;
this.currentBasket = task.workbasketSummary;
this.getTasks();
}
if (!task) {
this.selectedId = '';
}
});
this.taskService.taskSelectedStream.pipe(takeUntil(this.destroy$)).subscribe((task: Task) => {
this.selectedId = task ? task.taskId : '';
if (!this.tasks) {
this.currentBasket = task.workbasketSummary;
this.getTasks();
}
});
this.taskService.taskChangedStream.pipe(takeUntil(this.destroy$)).subscribe((task) => {
this.currentBasket = task.workbasketSummary;
this.getTasks();
});
this.orientationService
.getOrientation()
@ -76,11 +74,6 @@ export class TaskMasterComponent implements OnInit, OnDestroy {
this.refreshWorkbasketList();
});
this.taskService.taskChangedStream.pipe(takeUntil(this.destroy$)).subscribe((task) => {
this.getTasks();
this.selectedId = task ? task.taskId : '';
});
this.workplaceService.workbasketSelectedStream.pipe(takeUntil(this.destroy$)).subscribe((workbasket) => {
this.currentBasket = workbasket;
if (this.selectedSearchType === Search.byWorkbasket) {
@ -89,10 +82,9 @@ export class TaskMasterComponent implements OnInit, OnDestroy {
});
this.workplaceService.objectReferenceSelectedStream.pipe(takeUntil(this.destroy$)).subscribe((objectReference) => {
this.objectReference = objectReference;
delete this.currentBasket;
if (objectReference) {
this.getTasks();
delete this.currentBasket;
this.getTasks(objectReference);
}
});
}
@ -134,9 +126,9 @@ export class TaskMasterComponent implements OnInit, OnDestroy {
}
}
private getTasks(): void {
private getTasks(objectReference?: ObjectReference): void {
this.requestInProgress = true;
if (!this.currentBasket && !this.objectReference) {
if (!this.currentBasket && !objectReference) {
this.requestInProgress = false;
this.tasks = [];
} else {
@ -150,8 +142,8 @@ export class TaskMasterComponent implements OnInit, OnDestroy {
this.filterBy.filterParams.owner,
this.filterBy.filterParams.priority,
this.filterBy.filterParams.state,
this.objectReference ? this.objectReference.type : '',
this.objectReference ? this.objectReference.value : ''
objectReference ? objectReference.type : '',
objectReference ? objectReference.value : ''
)
.pipe(takeUntil(this.destroy$))
.subscribe((taskResource) => {

View File

@ -43,6 +43,7 @@ export class TaskComponent implements OnInit, OnDestroy {
async getTask(id: string) {
this.requestInProgress = true;
this.task = await this.taskService.getTask(id).toPromise();
this.taskService.selectTask(this.task);
const classification = await this.classificationService
.getClassification(this.task.classificationSummary.classificationId)
.toPromise();

View File

@ -6,22 +6,20 @@ import { environment } from 'environments/environment';
import { TaskResource } from 'app/workplace/models/task-resource';
import { Direction } from 'app/shared/models/sorting';
import { TaskanaQueryParameters } from 'app/shared/util/query-parameters';
import { TaskanaDate } from 'app/shared/util/taskana.date';
import { map } from 'rxjs/operators';
import { QueryParameters } from 'app/shared/models/query-parameters';
@Injectable()
export class TaskService {
url = `${environment.taskanaRestUrl}/v1/tasks`;
taskChangedSource = new Subject<Task>();
private taskChangedSource = new Subject<Task>();
taskChangedStream = this.taskChangedSource.asObservable();
taskSelectedSource = new Subject<Task>();
private taskSelectedSource = new Subject<Task>();
taskSelectedStream = this.taskSelectedSource.asObservable();
constructor(private httpClient: HttpClient) {}
publishUpdatedTask(task: Task = new Task('empty')) {
publishUpdatedTask(task?: Task) {
this.taskChangedSource.next(task);
}
@ -46,7 +44,7 @@ export class TaskService {
allPages: boolean = false
): Observable<TaskResource> {
const url = `${this.url}${TaskanaQueryParameters.getQueryParameters(
this.accessIdsParameters(
TaskService.accessIdsParameters(
basketId,
sortBy,
sortDirection,
@ -70,16 +68,17 @@ export class TaskService {
return this.httpClient.post<Task>(`${this.url}/${id}/complete`, '');
}
claimTask(id: string): Observable<Task> {
// currently unused
/* claimTask(id: string): Observable<Task> {
return this.httpClient.post<Task>(`${this.url}/${id}/claim`, 'test');
}
} */
transferTask(taskId: string, workbasketId: string): Observable<Task> {
return this.httpClient.post<Task>(`${this.url}/${taskId}/transfer/${workbasketId}`, '');
}
updateTask(task: Task): Observable<Task> {
const taskConv = this.convertTasksDatesToGMT(task);
const taskConv = TaskService.convertTasksDatesToGMT(task);
return this.httpClient.put<Task>(`${this.url}/${task.taskId}`, taskConv);
}
@ -91,29 +90,17 @@ export class TaskService {
return this.httpClient.post<Task>(this.url, task);
}
private convertTasksDatesToGMT(task: Task): Task {
if (task.created) {
task.created = new Date(task.created).toISOString();
}
if (task.claimed) {
task.claimed = new Date(task.claimed).toISOString();
}
if (task.completed) {
task.completed = new Date(task.completed).toISOString();
}
if (task.modified) {
task.modified = new Date(task.modified).toISOString();
}
if (task.planned) {
task.planned = new Date(task.planned).toISOString();
}
if (task.due) {
task.due = new Date(task.due).toISOString();
}
private static convertTasksDatesToGMT(task: Task): Task {
const timeAttributes = ['created', 'claimed', 'completed', 'modified', 'planned', 'due'];
timeAttributes.forEach((attributeName) => {
if (task[attributeName]) {
task[attributeName] = new Date(task[attributeName]).toISOString();
}
});
return task;
}
private accessIdsParameters(
private static accessIdsParameters(
basketId: string,
sortBy = 'priority',
sortDirection: string = Direction.ASC,