Skip to content

Commit

Permalink
[JavaScript] Remove mainLizmap from FeaturesTable module
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Jul 31, 2024
1 parent b50b4ef commit bf4d277
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions assets/src/modules/FeaturesTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @copyright 2024 3Liz
* @license MPL-2.0
*/
import { mainLizmap, mainEventDispatcher } from '../modules/Globals.js';
import { Config } from './Config.js';
import Utils from './Utils.js';

/**
Expand All @@ -13,8 +13,14 @@ import Utils from './Utils.js';
*/
export default class FeaturesTable {

constructor() {

/**
* Create a features table instance
* @param {Config} initialConfig - The lizmap initial config instance
* @param {object} lizmap3 - The old lizmap object
*/
constructor(initialConfig, lizmap3) {
this._initialConfig = initialConfig;
this._lizmap3 = lizmap3;
}

/**
Expand Down Expand Up @@ -69,7 +75,7 @@ export default class FeaturesTable {

let previousMessage = document.getElementById('lizmap-features-table-message');
if (previousMessage) previousMessage.remove();
mainLizmap.lizmap3.addMessage(
this._lizmap3.addMessage(
message, type, true, duration
).attr('id', 'lizmap-features-table-message');
}
Expand All @@ -88,10 +94,10 @@ export default class FeaturesTable {
openPopup(layerId, feature, uniqueField, targetElement, aCallBack) {

// Get the layer name & configuration
if (!mainLizmap.initialConfig.layers.layerIds.includes(layerId)) {
if (!this._initialConfig.layers.layerIds.includes(layerId)) {
return null;
}
const layerConfig = mainLizmap.initialConfig.layers.getLayerConfigByLayerId(layerId);
const layerConfig = this._initialConfig.layers.getLayerConfigByLayerId(layerId);
const layerName = layerConfig.name;

// Layer WMS name
Expand Down
2 changes: 1 addition & 1 deletion assets/src/modules/Lizmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default class Lizmap {
this.permalink = new Permalink();
this.map = new map('newOlMap', this.initialConfig, this.serviceURL, this.state.map, this.state.baseLayers, this.state.rootMapGroup, this.lizmap3);
this.edition = new Edition(this.lizmap3);
this.featuresTable = new FeaturesTable();
this.featuresTable = new FeaturesTable(this.initialConfig, this.lizmap3);
this.geolocation = new Geolocation(this.map, this.lizmap3);
this.geolocationSurvey = new GeolocationSurvey(this.geolocation, this.edition);
this.selectionTool = new SelectionTool();
Expand Down

0 comments on commit bf4d277

Please sign in to comment.