Skip to content

Commit

Permalink
Fix: Listen for changes in highlighting to display them instantly in …
Browse files Browse the repository at this point in the history
…the WP card view
  • Loading branch information
HDinger committed Aug 5, 2019
1 parent 64cf61e commit 6bc240f
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions frontend/src/app/components/wp-grid/wp-grid.component.ts
Expand Up @@ -26,18 +26,21 @@
// 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 {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 {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({
selector: 'wp-grid',
template: `
<wp-card-view [dragOutOfHandler]="canDragOutOf"
[dragInto]="true"
[cardsRemovable]="false"
[highlightingMode]="highlightingMode()"
[highlightingMode]="highlightingMode"
[showStatusButton]="false"
[orientation]="gridOrientation"
(onMoved)="switchToManualSorting()">
Expand All @@ -48,16 +51,33 @@ import {WorkPackageTableSortByService} from "core-components/wp-fast-table/state
export class WorkPackagesGridComponent {
public canDragOutOf = () => { return true; };
public gridOrientation:CardViewOrientation = 'horizontal';
public highlightingMode:HighlightingMode = 'none';

constructor(readonly wpTableHighlight:WorkPackageTableHighlightingService,
readonly wpTableSortBy:WorkPackageTableSortByService) {
readonly wpTableSortBy:WorkPackageTableSortByService,
readonly querySpace:IsolatedQuerySpace,
readonly cdRef:ChangeDetectorRef) {
}

public switchToManualSorting() {
this.wpTableSortBy.switchToManualSorting();
ngOnInit() {
this.wpTableHighlight
.updates$()
.pipe(
takeUntil(this.querySpace.stopAllSubscriptions),
distinctUntilChanged()
)
.subscribe(() => {
this.highlightingMode = this.wpTableHighlight.current.mode;
this.cdRef.detectChanges();
});

}

public highlightingMode() {
return this.wpTableHighlight.current.mode;
ngOnDestroy():void {
// Nothing to do
}

public switchToManualSorting() {
this.wpTableSortBy.switchToManualSorting();
}
}

0 comments on commit 6bc240f

Please sign in to comment.