Fix: Listen for changes in highlighting to display them instantly in the WP card view

pull/7505/head
Henriette Dinger 5 years ago
parent 64cf61eeda
commit 6bc240f301
  1. 34
      frontend/src/app/components/wp-grid/wp-grid.component.ts

@ -26,10 +26,13 @@
// See doc/COPYRIGHT.rdoc for more details. // See doc/COPYRIGHT.rdoc for more details.
// ++ // ++
import {ChangeDetectionStrategy, Component} from "@angular/core"; import {ChangeDetectionStrategy, ChangeDetectorRef, Component} from "@angular/core";
import {WorkPackageTableHighlightingService} from "core-components/wp-fast-table/state/wp-table-highlighting.service"; import {WorkPackageTableHighlightingService} from "core-components/wp-fast-table/state/wp-table-highlighting.service";
import {CardViewOrientation} from "core-components/wp-card-view/wp-card-view.component"; import {CardViewOrientation} from "core-components/wp-card-view/wp-card-view.component";
import {WorkPackageTableSortByService} from "core-components/wp-fast-table/state/wp-table-sort-by.service"; import {WorkPackageTableSortByService} from "core-components/wp-fast-table/state/wp-table-sort-by.service";
import {distinctUntilChanged, takeUntil} from "rxjs/operators";
import {HighlightingMode} from "core-components/wp-fast-table/builders/highlighting/highlighting-mode.const";
import {IsolatedQuerySpace} from "core-app/modules/work_packages/query-space/isolated-query-space";
@Component({ @Component({
selector: 'wp-grid', selector: 'wp-grid',
@ -37,7 +40,7 @@ import {WorkPackageTableSortByService} from "core-components/wp-fast-table/state
<wp-card-view [dragOutOfHandler]="canDragOutOf" <wp-card-view [dragOutOfHandler]="canDragOutOf"
[dragInto]="true" [dragInto]="true"
[cardsRemovable]="false" [cardsRemovable]="false"
[highlightingMode]="highlightingMode()" [highlightingMode]="highlightingMode"
[showStatusButton]="false" [showStatusButton]="false"
[orientation]="gridOrientation" [orientation]="gridOrientation"
(onMoved)="switchToManualSorting()"> (onMoved)="switchToManualSorting()">
@ -48,16 +51,33 @@ import {WorkPackageTableSortByService} from "core-components/wp-fast-table/state
export class WorkPackagesGridComponent { export class WorkPackagesGridComponent {
public canDragOutOf = () => { return true; }; public canDragOutOf = () => { return true; };
public gridOrientation:CardViewOrientation = 'horizontal'; public gridOrientation:CardViewOrientation = 'horizontal';
public highlightingMode:HighlightingMode = 'none';
constructor(readonly wpTableHighlight:WorkPackageTableHighlightingService, constructor(readonly wpTableHighlight:WorkPackageTableHighlightingService,
readonly wpTableSortBy:WorkPackageTableSortByService) { readonly wpTableSortBy:WorkPackageTableSortByService,
readonly querySpace:IsolatedQuerySpace,
readonly cdRef:ChangeDetectorRef) {
} }
public switchToManualSorting() { ngOnInit() {
this.wpTableSortBy.switchToManualSorting(); this.wpTableHighlight
.updates$()
.pipe(
takeUntil(this.querySpace.stopAllSubscriptions),
distinctUntilChanged()
)
.subscribe(() => {
this.highlightingMode = this.wpTableHighlight.current.mode;
this.cdRef.detectChanges();
});
} }
public highlightingMode() { ngOnDestroy():void {
return this.wpTableHighlight.current.mode; // Nothing to do
}
public switchToManualSorting() {
this.wpTableSortBy.switchToManualSorting();
} }
} }

Loading…
Cancel
Save