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

🔙 from #729 - 🐛 Invalid dependency Api (iframe + editing) #732

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/MapControlGeocoding.vue
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ export default {
});

// start editing session
await editing.getApi().addLayerFeature({ layerId: layerId, feature: _feature });
await editing.addLayerFeature({ layerId: layerId, feature: _feature });

} catch(e) {
console.warn(e);
Expand Down
39 changes: 13 additions & 26 deletions src/services/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Projections from 'store/projections';
import { normalizeEpsg } from 'utils/normalizeEpsg';
import { createSingleFieldParameter } from 'utils/createSingleFieldParameter';
import { getUniqueDomId } from 'utils/getUniqueDomId';
import { waitFor } from 'utils/waitFor';

/**
* @param epsg: Number Code of epsg Ex.4326
Expand Down Expand Up @@ -266,37 +267,23 @@ class BaseIframeService extends G3WObject {
layers = {}
} = {}) {
this.layers = layers;

// skip when plugin is not in configuration (ie. added to the application)
if (!ApplicationState.configurationPlugins.includes(this.pluginName)) {
if ('editing' !== this.pluginName || !ApplicationState.configurationPlugins.includes('editing')) {
return;
}
const plugin = PluginsRegistry.getPlugin(this.pluginName);
if (plugin) {
this.setDependencyApi(plugin.getApi());
this.setReady(true);
} else {
PluginsRegistry
.onafter('registerPlugin', async plugin => {
await plugin.isReady();
if (plugin.getName() === this.pluginName) {
this.setDependencyApi(plugin.getApi());
this.setReady(true);
}
})
}
}

/**
* ORIGINAL SOURCE: src/app/core/iframe/services/plugins/[email protected]
*
* @virtual method need to be implemented by subclasses
*
* @since 3.9.1
*/
setDependencyApi(api = {}) {
this.dependencyApi = api;
}
// wait until "editing" plugin is loaded
await waitFor(() => PluginsRegistry.getPlugin('editing'));

// BACKOMP v3.x
this.dependencyApi = PluginsRegistry.getPlugin('editing');
this.dependencyApi.getEditableLayersId = this.dependencyApi.getEditableLayersId || (() => Object.keys(this.dependencyApi.getEditableLayers()));
this.dependencyApi.hidePanel = this.dependencyApi.hidePanel || this.dependencyApi.hideEditingPanel;
this.dependencyApi.resetDefault = this.dependencyApi.resetDefault || this.dependencyApi.resetAPIDefault;

this.setReady(true);
}
/**
* ORIGINAL SOURCE: src/app/core/iframe/services/plugins/[email protected]
*
Expand Down