diff --git a/addon/components/flexberry-maplayer.js b/addon/components/flexberry-maplayer.js index 76cb4a0e7..02d1a6585 100644 --- a/addon/components/flexberry-maplayer.js +++ b/addon/components/flexberry-maplayer.js @@ -825,6 +825,16 @@ let FlexberryMaplayerComponent = Ember.Component.extend( */ onVisibilityCheckboxChange(...args) { this.sendAction('changeVisibility', ...args); + + if (!this.get('layer')) { + console.error('layer is not defined'); + return; + } + + // When enabling a layer, enable all groups recursively + if (this.get('layer.visibility')) { + this.sendAction('enableGroupVisibility'); + } }, /** @@ -893,6 +903,39 @@ let FlexberryMaplayerComponent = Ember.Component.extend( this.set('_addDialogIsVisible', true); }, + /** + Processes the visibility of a group layer when the visibility of inner layers is changed + + @method actions.enableGroupVisibility + */ + enableGroupVisibility() { + let layer = this.get('layer'); + + if (!layer) { + console.error('layer is not defined'); + return; + } + + if (!this.get('isGroup')) { + return; + } + + if (this.get('compare.compareLayersEnabled') && !this.get('ignoreCompareMode')) { + 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('enableGroupVisibility'); + }, + /** Handles add dialog's 'approve' action. Invokes component's {{#crossLink "FlexberryMaplayerComponent/sendingActions.add:method"}}'add'{{/crossLink}} action. diff --git a/addon/components/flexberry-maplayers.js b/addon/components/flexberry-maplayers.js index 07dd61f9c..a86c3355d 100644 --- a/addon/components/flexberry-maplayers.js +++ b/addon/components/flexberry-maplayers.js @@ -517,6 +517,10 @@ let FlexberryMaplayersComponent = Ember.Component.extend( this.sendAction(actionName, layer); }, + enableGroupVisibility() { + this.sendAction('enableGroupVisibility'); + }, + onAllLayerVisibilityChanged(e) { this.set('allLayerVisible', !this.get('allLayerVisible')); let visibility = this.get('allLayerVisible'); diff --git a/addon/mixins/compare-layers.js b/addon/mixins/compare-layers.js index 643491b4d..41c1c5c6c 100644 --- a/addon/mixins/compare-layers.js +++ b/addon/mixins/compare-layers.js @@ -84,14 +84,16 @@ export default Ember.Mixin.create({ const isEnabled = !!sideGroupLayers.find(id => id === layer.get('id')); if (isEnabled) { sideGroupLayers = sideGroupLayers.filter(id => id !== layer.get('id')); + let disableLayers = sideChildLayers.filter(l => l.parentIds.includes(layer.get('id')) && this.parentLayersVisible(l.parentIds, side)); Ember.set(settings, 'groupLayersEnabled', [...sideGroupLayers]); - let disableLayers = sideChildLayers.filter(l => l.parentIds.includes(layer.get('id'))); disableLayers.forEach((l) => this.setLayerBySide(l.layer, side, map)); } else { sideGroupLayers.push(layer.get('id')); 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'); } }, @@ -124,6 +126,8 @@ export default Ember.Mixin.create({ if (this.parentLayersVisible(parentIds, side)) { this.setLayerBySide(layer, side, map); } + + this.sendAction('enableGroupVisibility'); } }, diff --git a/addon/templates/components/flexberry-maplayer.hbs b/addon/templates/components/flexberry-maplayer.hbs index 3945e9587..04ab290fe 100644 --- a/addon/templates/components/flexberry-maplayer.hbs +++ b/addon/templates/components/flexberry-maplayer.hbs @@ -210,6 +210,7 @@ sideBySide=sideBySide leftLayer=leftLayer rightLayer=rightLayer + enableGroupVisibility=(action 'enableGroupVisibility') isGroup=isGroup backgroundLayers=backgroundLayers ignoreCompareMode=ignoreCompareMode diff --git a/addon/templates/components/flexberry-maplayers.hbs b/addon/templates/components/flexberry-maplayers.hbs index 7d25d8620..c1a468cce 100644 --- a/addon/templates/components/flexberry-maplayers.hbs +++ b/addon/templates/components/flexberry-maplayers.hbs @@ -68,6 +68,7 @@ rightLayer=rightLayer closeOtherCalendar = (action "closeOtherCalendar") layerTimeChanged=(action "onLayerTimeChanged") + enableGroupVisibility=(action 'enableGroupVisibility') dynamicButtons=dynamicButtons external=(action 'external') backgroundLayers=backgroundLayers