Map: diosplay of layers in the tree with viewableRole

This commit is contained in:
phil 2024-03-20 12:49:32 +05:30
parent 4eb4c0d0dd
commit 21f6e27c7f
3 changed files with 11 additions and 7 deletions

View file

@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core' import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'
import { FormControl } from '@angular/forms' import { FormControl } from '@angular/forms'
import { MatSnackBar } from '@angular/material/snack-bar' import { MatSnackBar } from '@angular/material/snack-bar'
@ -18,6 +18,7 @@ import { BaseMapWithStores } from '../../openapi'
selector: 'gisaf-map-controls', selector: 'gisaf-map-controls',
templateUrl: './map-controls.component.html', templateUrl: './map-controls.component.html',
styleUrls: ['./map-controls.component.css'], styleUrls: ['./map-controls.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class MapControlsComponent implements OnInit { export class MapControlsComponent implements OnInit {
baseUrl: string = '/gj/' baseUrl: string = '/gj/'

View file

@ -6,7 +6,7 @@
matTooltip="{{ node.description || node.title || node.name }} ({{ node.gisType }}, {{ node.count }})" matTooltip="{{ node.description || node.title || node.name }} ({{ node.gisType }}, {{ node.count }})"
matTooltipPosition="right" matTooltipPosition="right"
[class.hasPlugins]="!!node.tagPlugins" [class.hasPlugins]="!!node.tagPlugins"
[hidden]='isHidden()' [hidden]='isHidden() | async'
> >
<div class="gisaf-intext" <div class="gisaf-intext"
[matMenuTriggerFor]="layerNodeMenu" [matMenuTriggerFor]="layerNodeMenu"

View file

@ -4,6 +4,7 @@ import { Component, OnInit, Input, Output, EventEmitter,
import { AuthenticationService } from '../../_services/authentication.service' import { AuthenticationService } from '../../_services/authentication.service'
import { Node, LayerNode } from '../models' import { Node, LayerNode } from '../models'
import { MapControlService } from '../map-control.service' import { MapControlService } from '../map-control.service'
import { Observable, map, of } from 'rxjs'
@Component({ @Component({
selector: 'gisaf-tree-layer-item', selector: 'gisaf-tree-layer-item',
@ -35,13 +36,15 @@ export class TreeLayerItemComponent implements OnInit {
} }
} }
isHidden(): boolean { isHidden(): Observable<boolean> {
let node = <LayerNode>this.node let role: string = (<LayerNode>this.node).viewableRole
if (!node.viewableRole) { if (!role) {
return false return of(false)
} }
else { else {
return !this.authenticationService.isAuthorized([node.viewableRole]) return this.authenticationService.isAuthorized([role]).pipe(map(
a => !a
))
} }
} }