diff --git a/src/app/core/data/service.js b/src/app/core/data/service.js index 604e5e683..3c1c5391a 100644 --- a/src/app/core/data/service.js +++ b/src/app/core/data/service.js @@ -4,7 +4,10 @@ import GUI from 'services/gui'; const { resolve } = require('utils'); function BaseService(){ + + /** @deprecated since v3.5 */ ProjectsRegistry.onbefore('setCurrentProject' , project => this.project = project); + this.project = ProjectsRegistry.getCurrentProject(); } diff --git a/src/app/core/print/printservice.js b/src/app/core/print/printservice.js index bec3f28d4..8a07d5190 100644 --- a/src/app/core/print/printservice.js +++ b/src/app/core/print/printservice.js @@ -120,7 +120,10 @@ const POST = function({url, params, mime_type}) { */ function PrintService(options = {}) { this._currentLayerStore = ProjectsRegistry.getCurrentProject().getLayersStore(); + + /** @deprecated since v3.5 */ ProjectsRegistry.onbefore('setCurrentProject', project=> this._currentLayerStore = project.getLayersStore()); + base(this); } diff --git a/src/app/gui/map/mapservice.js b/src/app/gui/map/mapservice.js index 5baf4e554..58d0445e7 100644 --- a/src/app/gui/map/mapservice.js +++ b/src/app/gui/map/mapservice.js @@ -408,28 +408,29 @@ function MapService(options={}) { if (options.project) this.project = options.project; else { this.project = ProjectsRegistry.getCurrentProject(); - //on after setting current project - const keysetCurrentProject = ProjectsRegistry.onafter('setCurrentProject', project => { - this.removeLayers(); - this._removeListeners(); - // check if reload same project - const isSameProject = this.project.getId() === project.getId(); - this.project = project; - const changeProjectCallBack = () => { - this._resetView(); - this._setupAllLayers(); - this._checkMapControls(); - this.setUpMapOlEvents(); - this.setupCustomMapParamsToLegendUrl(); - }; - ApplicationService.isIframe() && changeProjectCallBack(); - isSameProject ? changeProjectCallBack() : this.getMap().once('change:size', changeProjectCallBack); - }); + + /** @deprecated since v3.5 */ this._keyEvents.g3wobject.push({ who: ProjectsRegistry, setter : 'setCurrentProject', - key: keysetCurrentProject + key: ProjectsRegistry.onafter('setCurrentProject', project => { // on after setting current project + this.removeLayers(); + this._removeListeners(); + // check if reload same project + const isSameProject = this.project.getId() === project.getId(); + this.project = project; + const changeProjectCallBack = () => { + this._resetView(); + this._setupAllLayers(); + this._checkMapControls(); + this.setUpMapOlEvents(); + this.setupCustomMapParamsToLegendUrl(); + }; + ApplicationService.isIframe() && changeProjectCallBack(); + isSameProject ? changeProjectCallBack() : this.getMap().once('change:size', changeProjectCallBack); + }) }); + } this._setupListeners(); this._marker = null; diff --git a/src/app/gui/queryresults/queryresultsservice.js b/src/app/gui/queryresults/queryresultsservice.js index 83a0047fa..bca602e61 100644 --- a/src/app/gui/queryresults/queryresultsservice.js +++ b/src/app/gui/queryresults/queryresultsservice.js @@ -554,7 +554,7 @@ class QueryResultsService extends G3WObject { /** * @FIXME add description - * + * * @param opts.layer * @param opts.dynamicProperties */ @@ -573,7 +573,7 @@ class QueryResultsService extends G3WObject { * * @param opts.layer layer linked to action * @param opts.id action id - * + * * @returns undefined when no action is found */ getActionLayerById({ @@ -810,7 +810,7 @@ class QueryResultsService extends G3WObject { interaction.interaction .on('picked', async ({ coordinate: coordinates }) => { if (external_layer) { - // call setQueryResponse setters method directly in case of external layer + // call setQueryResponse setters method directly in case of external layer this.setQueryResponse( { data: [ this.getVectorLayerFeaturesFromQueryRequest(this._vectorLayers.find(v => layer.id === v.get('id')), { coordinates }) ], @@ -885,7 +885,7 @@ class QueryResultsService extends G3WObject { /** * Clear layer actions (if present) - * + * * @since 3.9.0 */ _clearActions() { @@ -990,7 +990,7 @@ class QueryResultsService extends G3WObject { Layer.SourceTypes.WCS, Layer.SourceTypes.WMST ].indexOf(sourceType); - + const name = is_string && layer.split('_'); const id = (is_layer ? layer.getId() : undefined) || @@ -1048,7 +1048,7 @@ class QueryResultsService extends G3WObject { } /** - * @since 3.9.0 + * @since 3.9.0 */ _hasLayerObjImageField(features, rawdata, attributes) { /** @FIXME add description */ @@ -1122,10 +1122,10 @@ class QueryResultsService extends G3WObject { * @since 3.9.0 */ _parseLayerObjAttributes(layer, features, sourceType) { - + let layerAttrs; - if (layer instanceof Layer && 'ows' !== this.state.type) { + if (layer instanceof Layer && 'ows' !== this.state.type) { layerAttrs = layer.getAttributes(); } @@ -1402,7 +1402,7 @@ class QueryResultsService extends G3WObject { /** * @FIXME add description - * + * * @param container DOM element */ hideChart(container) { @@ -1703,7 +1703,7 @@ class QueryResultsService extends G3WObject { /** * Save current filter for a layer - * + * * @since 3.9.0 */ saveFilter(layer) { @@ -2238,7 +2238,7 @@ QueryResultsService.prototype.clearSelectionExtenalLayer = deprecate(addToSelect /** * Alias functions - * + * * @TODO choose which ones deprecate */ QueryResultsService.prototype.init = QueryResultsService.prototype.clearState; @@ -2279,7 +2279,7 @@ QueryResultsService.prototype.setters = { /** @type { boolean | undefined } */ const FILTER_SELECTED = queryResponse.query.external.filter.SELECTED; - + // add visible layers to query response (vector layers) this._vectorLayers .forEach(layer => { diff --git a/src/app/gui/wms/service.js b/src/app/gui/wms/service.js index 731e06393..a2f862d12 100644 --- a/src/app/gui/wms/service.js +++ b/src/app/gui/wms/service.js @@ -16,16 +16,17 @@ function Service(options={}){ localwmsurls: [] // contain array of object {id, url} }; - GUI.isReady().then(()=> { - GUI.getService('map').isReady().then(async ()=>{ + GUI.isReady().then(() => { + GUI.getService('map').isReady().then(async () => { this.state.localwmsurls = await this.loadClientWmsUrls(); }) - }) + }); ProjectsRegistry.onafter('setCurrentProject', async project => { - this.projectId = project.getId(); + this.projectId = project.getId(); this.state.adminwmsurls = project.wmsurls || []; - }) + }); + } const proto = Service.prototype; diff --git a/src/store/plugins.js b/src/store/plugins.js index e7c1c00b9..2ff9e60c9 100644 --- a/src/store/plugins.js +++ b/src/store/plugins.js @@ -27,10 +27,8 @@ function PluginsRegistry() { if (!this._plugins[plugin.name]) this._plugins[plugin.name] = plugin; } }; - /** - * CHECK IF STILL USEFUL. IT RELATED TO CHANGE MAP OLD BEHAVIOR (PREVIOUS VERSION 3.4). - * NOW WHEN CHANGE MAP IS TRIGGER, PAGE IS RELOADED. - */ + + /** @deprecated since v3.5 */ ProjectsRegistry.onafter('setCurrentProject', project =>{ this.gidProject = project.getGid(); }); diff --git a/src/store/projects.js b/src/store/projects.js index e22d3db11..125d106db 100644 --- a/src/store/projects.js +++ b/src/store/projects.js @@ -27,10 +27,18 @@ function ProjectsRegistry() { this.setters = { - createProject(projectConfig) { - //hook to get project config and modify it - }, - + /** + * Hook mainly used to override current project configuration while developing locally. + * + * @deprecated since v3.5 + */ + createProject(projectConfig) { }, + + /** + * Prior to v3.4 a change map hook was always triggered, now the page is simply reloaded. + * + * @deprecated since v3.5 + */ setCurrentProject(project) { if (this.state.currentProject !== project) {