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

Merge remote-tracking branch 'origin/2.4' #5102

Merged
merged 9 commits into from
Sep 2, 2019
3 changes: 2 additions & 1 deletion api/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import config from './src/constants.js';
import Map from './src/Map.js';

config.themesUrl = 'https://geomapfish-demo-2-5.camptocamp.com/themes?version=2&background=background';
config.themesUrl = 'https://geomapfish-demo-2-5.camptocamp.com/themes?' +
'version=2&background=background&interface=api';

const lib = {
Map
Expand Down
2 changes: 1 addition & 1 deletion api/src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ class Map {
if (table) {
contentHTML += '<table><tbody>';
for (const key in properties) {
if (!EXCLUDE_PROPERTIES.includes(key) || key !== geometryName) {
if (!EXCLUDE_PROPERTIES.includes(key) && key !== geometryName) {
contentHTML += '<tr>';
contentHTML += `<th>${key}</th>`;
contentHTML += `<td>${properties[key]}</td>`;
Expand Down
1 change: 1 addition & 0 deletions contribs/gmf/src/backgroundlayerselector/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ Controller.prototype.getSetBgLayerOpacity = function(val) {
}
if (val !== undefined) {
this.opacityLayer.setOpacity(val);
this.opacityLayer.setVisible(val !== 0);
}
return this.opacityLayer.getOpacity();
};
Expand Down
35 changes: 35 additions & 0 deletions contribs/gmf/src/layertree/TreeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ export function LayertreeTreeManager($timeout, $injector, gettextCatalog, ngeoLa
*/
this.ngeoStateManager_ = ngeoStateManager;

/**
* @type {Array.<import('gmf/themes.js').GmfGroup>|undefined}
* @private
*/
this.initialLevelFirstGroups_ = undefined;

/**
* A reference to the OGC servers loaded by the theme service.
* @type {?import('gmf/themes.js').GmfOgcServers}
Expand Down Expand Up @@ -197,6 +203,22 @@ LayertreeTreeManager.prototype.addFirstLevelGroups = function(firstLevelGroups,
return groupNotAdded.length === 0;
};

/**
* @param {Array.<import('gmf/themes.js').GmfGroup>} firstGroups The groups we add to the layertree
*/
LayertreeTreeManager.prototype.setItintialFirstLevelGroups = function(firstGroups) {
this.initialLevelFirstGroups_ = firstGroups;
};

/**
* @param {array} array An array of groups.
* @param {number} old_index The old index before reorder (the current one).
* @param {number} new_index The new index after reorder.
* @private
*/
LayertreeTreeManager.prototype.reorderChild_ = function(array, old_index, new_index) {
array.splice(new_index, 0, array.splice(old_index, 1)[0]);
};

/**
* Update the application state with the list of first level groups in the tree
Expand Down Expand Up @@ -265,7 +287,20 @@ LayertreeTreeManager.prototype.addFirstLevelGroup_ = function(group) {
// Add each first-level-groups.
this.groupsToAddInThisDigestLoop_.forEach((grp) => {
this.root.children.unshift(grp);

// We reorder the groups now as it has to be done before the permalink to be updated
// initialFirstGroups_ is only defined for user change theme loading
this.root.children.forEach((group, old_index) => {
if (this.initialLevelFirstGroups_ !== undefined) {
const new_index = this.initialLevelFirstGroups_.findIndex(
firstLevelGroup => firstLevelGroup.id === group.id);
if (new_index !== -1 && new_index !== old_index) {
this.reorderChild_(this.root.children, old_index, new_index);
}
}
});
});
this.initialLevelFirstGroups_ = undefined;
//Update the permalink
this.updateTreeGroupsState_(this.root.children);
// Reset the groups and the promise state. Don't reset the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
ng-click="$ctrl.removeDataSource(dataSource)">
<span class="fa fa-trash"></span>
</a>
</span>
</span>
</div>
</li>
</ul>
1 change: 1 addition & 0 deletions contribs/gmf/src/theme/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ ThemeManagerService.prototype.updateCurrentTheme = function(themeName, fallbackT
// In flush mode load current theme private groups
const fallbackTheme = findThemeByName(themes, fallbackThemeName);
if (fallbackTheme) {
this.gmfTreeManager_.setItintialFirstLevelGroups(fallbackTheme.children);
this.gmfTreeManager_.addFirstLevelGroups(fallbackTheme.children, false, opt_silent);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/map/BackgroundLayerMgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ export class MapBackgroundLayerManager extends olObservable {
const opacityBackgroundLayer = this.getOpacityBgLayer(map);
if (opacityBackgroundLayer) {
const previous = bgGroup.getLayers().remove(opacityBackgroundLayer);
layer.setOpacity(previous ? previous.getOpacity() : 0);
layer.setVisible(previous ? previous.getVisible() : true);
const opacity = previous ? previous.getOpacity() : 0;
layer.setOpacity(opacity);
layer.setVisible(opacity !== 0);
}
const ZIndex = -100;
layer.setZIndex(ZIndex);
Expand Down