Skip to content

Commit

Permalink
Merge pull request #5030 from neo-garaix/red-ml-dep/features-table
Browse files Browse the repository at this point in the history
Reduce mainLizmap dependencies in FeaturesTable  module
  • Loading branch information
rldhont authored Dec 2, 2024
2 parents 95f428c + 23b9fa0 commit 87808dc
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 @@ -151,7 +151,7 @@ export default class Lizmap {
this.permalink = new Permalink();
this.map = new map();
this.edition = new Edition(this._lizmap3);
this.featuresTable = new FeaturesTable();
this.featuresTable = new FeaturesTable(this.initialConfig, this.lizmap3);
this.geolocation = new Geolocation();
this.geolocationSurvey = new GeolocationSurvey();
this.selectionTool = new SelectionTool();
Expand Down

0 comments on commit 87808dc

Please sign in to comment.