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

Deprecate hooks ProjectsRegistry~setCurrentProject(project) and ProjectsRegistry~createProject(projectConfig) #320

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/app/core/data/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
3 changes: 3 additions & 0 deletions src/app/core/print/printservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
37 changes: 19 additions & 18 deletions src/app/gui/map/mapservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 12 additions & 12 deletions src/app/gui/queryresults/queryresultsservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ class QueryResultsService extends G3WObject {

/**
* @FIXME add description
*
*
* @param opts.layer
* @param opts.dynamicProperties
*/
Expand All @@ -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({
Expand Down Expand Up @@ -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 }) ],
Expand Down Expand Up @@ -885,7 +885,7 @@ class QueryResultsService extends G3WObject {

/**
* Clear layer actions (if present)
*
*
* @since 3.9.0
*/
_clearActions() {
Expand Down Expand Up @@ -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) ||
Expand Down Expand Up @@ -1048,7 +1048,7 @@ class QueryResultsService extends G3WObject {
}

/**
* @since 3.9.0
* @since 3.9.0
*/
_hasLayerObjImageField(features, rawdata, attributes) {
/** @FIXME add description */
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -1402,7 +1402,7 @@ class QueryResultsService extends G3WObject {

/**
* @FIXME add description
*
*
* @param container DOM element
*/
hideChart(container) {
Expand Down Expand Up @@ -1703,7 +1703,7 @@ class QueryResultsService extends G3WObject {

/**
* Save current filter for a layer
*
*
* @since 3.9.0
*/
saveFilter(layer) {
Expand Down Expand Up @@ -2238,7 +2238,7 @@ QueryResultsService.prototype.clearSelectionExtenalLayer = deprecate(addToSelect

/**
* Alias functions
*
*
* @TODO choose which ones deprecate
*/
QueryResultsService.prototype.init = QueryResultsService.prototype.clearState;
Expand Down Expand Up @@ -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 => {
Expand Down
11 changes: 6 additions & 5 deletions src/app/gui/wms/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions src/store/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
16 changes: 12 additions & 4 deletions src/store/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down