Skip to content

Commit

Permalink
enable all groups recursively in map-tools/compare
Browse files Browse the repository at this point in the history
  • Loading branch information
viatkinviatkin committed Aug 8, 2023
1 parent 5bae1aa commit 6124e1f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
29 changes: 20 additions & 9 deletions addon/components/flexberry-maplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ let FlexberryMaplayerComponent = Ember.Component.extend(

// When enabling a layer, enable all groups recursively
if (this.get('layer.visibility')) {
this.sendAction('changeGroupVisibility');
this.sendAction('enableGroupVisibility');
}
},

Expand Down Expand Up @@ -906,23 +906,34 @@ let FlexberryMaplayerComponent = Ember.Component.extend(
/**
Processes the visibility of a group layer when the visibility of inner layers is changed
@method actions.changeGroupVisibility
@method actions.enableGroupVisibility
*/
changeGroupVisibility() {
if (!this.get('layer')) {
console.error('layer is not defined', )
enableGroupVisibility() {
let layer = this.get('layer');

if (!layer) {
console.error('layer is not defined');
return;
};
}

if (!this.get('isGroup')) {
return;
}

if (!this.get('layer.visibility')) {
Ember.set(this.get('layer'), 'visibility', true);
if (this.get('compare.compareLayersEnabled')) {
let side = this.get('compare.side');
let compareSettings = this.get(`compare.compareState.${side}`);
let sideGroupLayers = compareSettings.groupLayersEnabled;
let isGroupVisibleInCompareTree = !!sideGroupLayers.find(id => id === layer.get('id'));

if (!isGroupVisibleInCompareTree) {
this.setGroupLayerBySide(layer, this.get('compare.side'), this.get('leafletMap'));
}
} else {
Ember.set(layer, 'visibility', true);
}

this.sendAction('changeGroupVisibility');
this.sendAction('enableGroupVisibility');
},

/**
Expand Down
4 changes: 2 additions & 2 deletions addon/components/flexberry-maplayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ let FlexberryMaplayersComponent = Ember.Component.extend(
this.sendAction(actionName, layer);
},

changeGroupVisibility() {
this.sendAction('changeGroupVisibility');
enableGroupVisibility() {
this.sendAction('enableGroupVisibility');
},

onAllLayerVisibilityChanged(e) {
Expand Down
3 changes: 3 additions & 0 deletions addon/mixins/compare-layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export default Ember.Mixin.create({
Ember.set(settings, 'groupLayersEnabled', [...sideGroupLayers]);
let layersToEnable = sideChildLayers.filter(l => l.parentIds.includes(layer.get('id')) && this.parentLayersVisible(l.parentIds, side));
layersToEnable.forEach((l) => this.setLayerBySide(l.layer, side, map));

this.sendAction('enableGroupVisibility');
}
},

Expand Down Expand Up @@ -124,6 +126,7 @@ export default Ember.Mixin.create({
if (this.parentLayersVisible(parentIds, side)) {
this.setLayerBySide(layer, side, map);
}
this.sendAction('enableGroupVisibility');
}
},

Expand Down
2 changes: 1 addition & 1 deletion addon/templates/components/flexberry-maplayer.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
sideBySide=sideBySide
leftLayer=leftLayer
rightLayer=rightLayer
changeGroupVisibility=(action 'changeGroupVisibility')
enableGroupVisibility=(action 'enableGroupVisibility')
isGroup=isGroup
backgroundLayers=backgroundLayers
ignoreCompareMode=ignoreCompareMode
Expand Down
2 changes: 1 addition & 1 deletion addon/templates/components/flexberry-maplayers.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
rightLayer=rightLayer
closeOtherCalendar = (action "closeOtherCalendar")
layerTimeChanged=(action "onLayerTimeChanged")
changeGroupVisibility=(action 'changeGroupVisibility')
enableGroupVisibility=(action 'enableGroupVisibility')
dynamicButtons=dynamicButtons
external=(action 'external')
backgroundLayers=backgroundLayers
Expand Down

0 comments on commit 6124e1f

Please sign in to comment.