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

233532 When enabling a layer, enable all groups recursively #795

Merged
merged 4 commits into from
Aug 15, 2023
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
43 changes: 43 additions & 0 deletions addon/components/flexberry-maplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
},

/**
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions addon/components/flexberry-maplayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
6 changes: 5 additions & 1 deletion addon/mixins/compare-layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а новое условие зачем?

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');
}
},

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

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

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