Skip to content

Commit

Permalink
Corrections demandées pour le pull request 714
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-darras authored and Marc-André Barbeau committed Sep 8, 2020
1 parent 3fbd615 commit 6417b60
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
('igo.geo.layer.subsetLayersListOnlyVisible' | translate)" matTooltipShowDelay="500">
<button mat-icon-button [disabled]="layersAreAllVisible && !onlyVisible"
[color]="onlyVisible ? 'warn' : 'primary'" (click)="toggleOnlyVisible()">
<mat-icon [svgIcon]="onlyVisible ? 'sort-variant-remove' : 'eye'"></mat-icon>
<mat-icon [svgIcon]="onlyVisible ? 'sort-variant-remove' : 'filter'"></mat-icon>
</button>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,14 @@

<button
mat-icon-button
color="primary"
[color]="(hideSelectedLayers?'primary':'default')"
tooltip-position="below"
matTooltipShowDelay="500"
[disabled]="layersChecked.length === 0"
[matTooltip]="'igo.geo.layer.hideSelectedLayers' | translate"
[matTooltip]="statusSelectedLayersCheck === 'ALL_VISIBLE' ? ('igo.geo.layer.hideSelectedLayers' | translate) : ('igo.geo.layer.showSelectedLayers' | translate) "
(click)="toggleVisibility( layersChecked )">
<mat-icon [svgIcon]="hideSelectedLayers ? 'eye-off' : 'eye'"></mat-icon>
<mat-icon [matBadge]="(statusSelectedLayersCheck === 'MIXED') ? 'i' : ''" matBadgeColor="warn" matBadgeSize="medium"
[svgIcon]="(statusSelectedLayersCheck === 'ALL_VISIBLE') ? 'eye-off' : 'eye'"></mat-icon>
</button>

<button
Expand Down
50 changes: 45 additions & 5 deletions packages/geo/src/lib/layer/layer-list/layer-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import {
OnDestroy,
Output,
EventEmitter,
ElementRef
ElementRef,
ChangeDetectorRef
} from '@angular/core';
import type { TemplateRef } from '@angular/core';

import { FloatLabelType } from '@angular/material/form-field';
import { Layer } from '../shared';
import { LayerListControlsEnum } from './layer-list.enum';
import { LayerListiSelectVisibleEnum } from './layer-list.enum';
import {
BehaviorSubject,
ReplaySubject,
Expand Down Expand Up @@ -49,6 +51,8 @@ export class LayerListComponent implements OnInit, OnDestroy {
public layerTool: boolean;

public hideSelectedLayers: boolean = false ;
private statusSelectedLayers: LayerListiSelectVisibleEnum = LayerListiSelectVisibleEnum.NULL;
private statusPrevSelectedLayers: LayerListiSelectVisibleEnum = LayerListiSelectVisibleEnum.NULL;

activeLayer$: BehaviorSubject<Layer> = new BehaviorSubject(undefined);

Expand Down Expand Up @@ -214,7 +218,9 @@ export class LayerListComponent implements OnInit, OnDestroy {
selectAllCheck$$: Subscription;
public selectAllCheck;

constructor(private elRef: ElementRef) {}
constructor(
private elRef: ElementRef ,private cdRef: ChangeDetectorRef ,
) {}

/**
* Subscribe to the search term stream and trigger researches
Expand Down Expand Up @@ -607,18 +613,50 @@ export class LayerListComponent implements OnInit, OnDestroy {
return;
}


//=====================================
toggleVisibility( layers?: Layer[] ) {
if (layers && layers.length > 0) {
for (const layer of layers) {
layer.visible = this.hideSelectedLayers ;
}

}
this.hideSelectedLayers = ! this.hideSelectedLayers ;
this.cdRef.detectChanges();
return;
}

get statusSelectedLayersCheck() :LayerListiSelectVisibleEnum
{
let findTrue :boolean = false;
let findFalse :boolean = false;
this.statusPrevSelectedLayers = this.statusSelectedLayers;

if(this.layersChecked.length === 0)
{
this.statusSelectedLayers = LayerListiSelectVisibleEnum.NULL;

} else {
this.statusSelectedLayers = LayerListiSelectVisibleEnum.MIXED;
this.hideSelectedLayers = true ;

for (const layer2 of this.layersChecked) {
if( layer2.visible===true )findTrue = true;
if( layer2.visible===false)findFalse = true;
}
if( findTrue===true && findFalse===false)
{
this.statusSelectedLayers = LayerListiSelectVisibleEnum.ALL_VISIBLE;
this.hideSelectedLayers = false ;
}
if( findTrue===false && findFalse===true)
{
this.statusSelectedLayers = LayerListiSelectVisibleEnum.ALL_HIDDEN;
}
}

return this.statusSelectedLayers;
}


layersCheck(event: {layer: Layer; check: boolean}) {
event.layer.options.check = event.check;
if (event.check === true) {
Expand Down Expand Up @@ -686,6 +724,7 @@ export class LayerListComponent implements OnInit, OnDestroy {
this.selectAllCheck = false;
}
}

}

toggleSelectionMode(value: boolean) {
Expand Down Expand Up @@ -736,6 +775,7 @@ export class LayerListComponent implements OnInit, OnDestroy {
this.layersChecked = [];
this.selectAllCheck$.next(false);
}

}

isScrolledIntoView(elemSource, elem) {
Expand Down
6 changes: 6 additions & 0 deletions packages/geo/src/lib/layer/layer-list/layer-list.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ export enum LayerListControlsEnum {
never = 'never',
default = 'default'
}
export enum LayerListiSelectVisibleEnum{
ALL_VISIBLE = 'ALL_VISIBLE',
ALL_HIDDEN = 'ALL_HIDDEN',
MIXED = 'MIXED',
NULL = 'NULL'
}

0 comments on commit 6417b60

Please sign in to comment.