Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(layer-list): fix selection mode #635

Merged
merged 1 commit into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,11 @@ export class LayerItemComponent implements OnInit, OnDestroy {
this._selectAll = value;
if (value === true) {
this.layerCheck = true;
} else {
this.layerCheck = false;
}
}
private _selectAll = false;

public layerCheck;
@Input() layerCheck;

private resolution$$: Subscription;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
[toggleLegendOnVisibilityChange]="toggleLegendOnVisibilityChange"
[selectionMode]="selection"
[selectAll]="selectAllCheck"
[layerCheck]="layer.options.check"
(action)="toggleLayerTool($event)"
(checkbox)="layersCheck($event)">
</igo-layer-item>
</ng-template>
</igo-list>

<igo-panel *ngIf="layerTool && activeLayer" class="igo-layer-actions-container" [title]="activeLayer.title">
<igo-panel *ngIf="!selection && layerTool && activeLayer" class="igo-layer-actions-container" [title]="activeLayer.title">
<div class="igo-layer-button-group">
<ng-container igoLayerItemToolbar
[ngTemplateOutlet]="templateLayerToolbar"
Expand Down
17 changes: 17 additions & 0 deletions packages/geo/src/lib/layer/layer-list/layer-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,19 @@ export class LayerListComponent implements OnInit, OnDestroy {
}

layersCheck(event: {layer: Layer; check: boolean}) {
event.layer.options.check = event.check;
if (event.check === true) {
const eventMapIndex = this.layers.findIndex(layer => event.layer.id === layer.id);
for (const layer of this.layersChecked) {
const mapIndex = this.layers.findIndex(lay => layer.id === lay.id);
if (eventMapIndex < mapIndex) {
this.layersChecked.splice(this.layersChecked.findIndex(lay => layer.id === lay.id), 0, event.layer);

if (this.layersChecked.length === this.layers.filter(lay => lay.baseLayer !== true).length) {
this.selectAllCheck = true;
} else {
this.selectAllCheck = false;
}
return;
}
}
Expand All @@ -425,6 +432,12 @@ export class LayerListComponent implements OnInit, OnDestroy {
const index = this.layersChecked.findIndex(layer => event.layer.id === layer.id);
this.layersChecked.splice(index, 1);
}

if (this.layersChecked.length === this.layers.filter(layer => layer.baseLayer !== true).length) {
this.selectAllCheck = true;
} else {
this.selectAllCheck = false;
}
}

toggleSelectionMode(value: boolean) {
Expand All @@ -450,12 +463,16 @@ export class LayerListComponent implements OnInit, OnDestroy {
selectAll() {
if (!this.selectAllCheck) {
for (const layer of this.layers) {
layer.options.check = true;
if (!layer.baseLayer) {
this.layersChecked.push(layer);
}
}
this.selectAllCheck$.next(true);
} else {
for (const layer of this.layers) {
layer.options.check = false;
}
this.layersChecked = [];
this.selectAllCheck$.next(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface LayerOptions {
tooltip?: TooltipContent;
_internal?: { [key: string]: string };
active?: boolean;
check?: boolean;
}

export interface GroupLayers {
Expand Down