Show filter button only on pages with a list on it

pull/8073/head
Henriette Dinger 5 years ago
parent 2bca7ebe6a
commit 636f506468
  1. 3
      frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.html
  2. 27
      frontend/src/app/modules/ifc_models/pages/viewer/ifc-viewer-page.component.ts

@ -5,7 +5,8 @@
</h2>
</div>
<ul class="toolbar-items">
<li class="toolbar-item">
<li class="toolbar-item"
*ngIf="filterAllowed">
<wp-filter-button>
</wp-filter-button>
</li>

@ -3,12 +3,17 @@ import {PathHelperService} from "core-app/modules/common/path-helper/path-helper
import {GonService} from "core-app/modules/common/gon/gon.service";
import {WorkPackagesViewBase} from "core-app/modules/work_packages/routing/wp-view-base/work-packages-view.base";
const listStateName:string = 'list';
const viewerStateName:string = 'viewer';
const splitStateName:string = 'split';
@Component({
templateUrl: './ifc-viewer-page.component.html',
styleUrls: ['./ifc-viewer-page.component.sass'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IFCViewerPageComponent extends WorkPackagesViewBase {
text = {
title: this.I18n.t('js.ifc_models.models.default'),
manage: this.I18n.t('js.ifc_models.models.manage'),
@ -25,13 +30,7 @@ export class IFCViewerPageComponent extends WorkPackagesViewBase {
@HostBinding('class')
get gridTemplateAreas() {
if (this.$state.includes('bim.space.list')) {
return '-list';
} else if (this.$state.includes('bim.space.*.model')) {
return '-viewer';
} else {
return '-split';
}
return '-' + this.currentViewerState();
}
public get title() {
@ -50,6 +49,10 @@ export class IFCViewerPageComponent extends WorkPackagesViewBase {
return this.gonIFC.permissions.manage;
}
public get filterAllowed():boolean {
return this.currentViewerState() !== viewerStateName;
}
private get gonIFC() {
return (this.gon.get('ifc_models') as any);
}
@ -63,4 +66,14 @@ export class IFCViewerPageComponent extends WorkPackagesViewBase {
return this.loadingIndicator =
this.wpListService.loadCurrentQueryFromParams(this.projectIdentifier);
}
private currentViewerState() {
if (this.$state.includes('bim.space.list')) {
return listStateName;
} else if (this.$state.includes('bim.space.*.model')) {
return viewerStateName;
} else {
return splitStateName;
}
}
}

Loading…
Cancel
Save