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.3' #4862

Merged
merged 9 commits into from
Apr 30, 2019
21 changes: 2 additions & 19 deletions contribs/gmf/src/controllers/AbstractAppController.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import olStyleFill from 'ol/style/Fill.js';
import olStyleStroke from 'ol/style/Stroke.js';
import olStyleStyle from 'ol/style/Style.js';
import {ThemeEventType} from 'gmf/theme/Manager.js';
import {findThemeByName} from 'gmf/theme/Themes.js';


/**
Expand Down Expand Up @@ -230,7 +229,8 @@ export function AbstractAppController(config, map, $scope, $injector) {
this.gmfThemes_.loadThemes(roleId);

if (evt.type !== 'ready') {
this.updateCurrentTheme_(previousThemeName);
const themeName = this.permalink_.defaultThemeNameFromFunctionalities();
this.gmfThemeManager.updateCurrentTheme(themeName, previousThemeName);
}
this.setDefaultBackground_(null);
this.updateHasEditableLayers_();
Expand Down Expand Up @@ -755,23 +755,6 @@ AbstractAppController.prototype.setDefaultBackground_ = function(theme) {
});
};

/**
* @param {string} fallbackThemeName fallback theme name.
* @private
*/
AbstractAppController.prototype.updateCurrentTheme_ = function(fallbackThemeName) {
this.gmfThemes_.getThemesObject().then((themes) => {
const themeName = this.permalink_.defaultThemeNameFromFunctionalities();
if (themeName) {
const theme = findThemeByName(themes, /** @type {string} */ (themeName));
if (theme) {
this.gmfThemeManager.addTheme(theme, true);
}
} else {
this.gmfThemeManager.setThemeName(fallbackThemeName);
}
});
};

/**
* @protected
Expand Down
19 changes: 14 additions & 5 deletions contribs/gmf/src/print/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,10 @@ class Controller {
* Init the controller
*/
$onInit() {
olEvents.listen(this.map.getView(), 'change:rotation', (event) => {
this.updateRotation_(Math.round(olMath.toDegrees(event.target.getRotation())));
});

// Clear the capabilities if the roles changes
this.$scope_.$watch(() => this.gmfAuthenticationService_.getRolesIds().join(','), () => {
this.gmfPrintState_.state = PrintStateEnum.CAPABILITIES_NOT_LOADED;
Expand Down Expand Up @@ -867,11 +871,7 @@ class Controller {
* @param {number} rotation The optional new rotation value in degrees.
*/
setRotation(rotation) {
this.rotation = olMath.clamp(rotation, -180, 180);

// sync all the inputs
this.rotationInput_.val(this.rotation.toString());

this.updateRotation_(rotation);
// Render the map to update the postcompose mask or rotate the map.
if (this.rotateMask) {
this.map.render();
Expand All @@ -880,6 +880,15 @@ class Controller {
}
}

/**
* Set the current rotation value.
* @param {number} rotation The optional new rotation value in degrees.
*/
updateRotation_(rotation) {
this.rotation = olMath.clamp(rotation, -180, 180);
// sync all the inputs
this.rotationInput_.val(this.rotation.toString());
}

/**
* Calculate the angle and the sense of rotation between two lines. One from the
Expand Down
29 changes: 28 additions & 1 deletion contribs/gmf/src/theme/Manager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import angular from 'angular';
import gmfLayertreeTreeManager from 'gmf/layertree/TreeManager.js';
import gmfThemeThemes from 'gmf/theme/Themes.js';
import gmfThemeThemes, {findThemeByName} from 'gmf/theme/Themes.js';
import ngeoStatemanagerService from 'ngeo/statemanager/Service.js';


Expand Down Expand Up @@ -115,6 +115,33 @@ ThemeManagerService.prototype.isLoading = function() {
return !this.gmfThemes_.loaded;
};


/**
* @param {string} themeName wanted theme name.
* @param {string} fallbackThemeName fallback theme name.
* @export
*/
ThemeManagerService.prototype.updateCurrentTheme = function(themeName, fallbackThemeName) {
this.gmfThemes_.getThemesObject().then((themes) => {
if (!themeName && this.modeFlush) {
// In flush mode load current theme private groups
const fallbackTheme = findThemeByName(themes, fallbackThemeName);
if (fallbackTheme) {
this.gmfTreeManager_.addFirstLevelGroups(fallbackTheme.children, false, false);
}
}
if (themeName) {
const theme = findThemeByName(themes, themeName);
if (theme) {
this.addTheme(theme, true);
}
} else {
this.setThemeName(fallbackThemeName);
}
});
};


/**
* @param {string} name The new theme name.
* @param {boolean=} opt_silent Don't emit a theme change event, default is false.
Expand Down