diff --git a/js/extension/stateManagement/epics/getDocuments.js b/js/extension/stateManagement/epics/getDocuments.js index e6bc52e..2fc0346 100644 --- a/js/extension/stateManagement/epics/getDocuments.js +++ b/js/extension/stateManagement/epics/getDocuments.js @@ -4,7 +4,7 @@ import { setDocuments, docsLoading as loading, } from "../actions/actions"; -import { getPluginCfg, isActive } from "../selector/selector"; +import { getEntity, getPluginCfg, isActive } from "../selector/selector"; import { wrapStartStop } from "@mapstore/observables/epics"; import { getDocuments } from "@js/extension/requests/documentsApi"; @@ -20,9 +20,10 @@ export function getDocumentsById(action$, store) { if (!apiUrl || !idPlugin) { return observable$; } + const params = {...action?.params, entity: getEntity(store.getState())} if (apiUrl) { observable$ = Rx.Observable.defer(() => - getDocuments(apiUrl, idPlugin, action?.params) + getDocuments(apiUrl, idPlugin, params) ) .catch((e) => { console.log("Error - Get list of documents"); diff --git a/js/extension/stateManagement/selector/selector.js b/js/extension/stateManagement/selector/selector.js index d71361a..633802d 100644 --- a/js/extension/stateManagement/selector/selector.js +++ b/js/extension/stateManagement/selector/selector.js @@ -22,13 +22,15 @@ export const getIdToDelete = state => state?.docsManager?.idToDelete; export const getIdToConsult = state => state?.docsManager?.idToConsult; export const getEntity = (state) => { - let cfg = state?.pluginCfg; + let cfg = state?.docsManager?.pluginCfg; if (cfg?.entity?.get) { return get(state, cfg.entity.get); } - if (cfg?.entity && cfg?.entity?.plugin && cfg?.entity?.plugin.propCfg) { - let pluginCfg = state[plugin]?.pluginCfg; - return pluginCfg ? pluginCfg[propCfg] : null; + if (cfg?.entity && cfg?.entity?.plugin && cfg?.entity?.propCfg && cfg?.entity?.attribute) { + const plugin = cfg?.entity?.plugin; + const propCfg = cfg?.entity?.propCfg; + let pluginCfg = state[plugin]; + return pluginCfg ? pluginCfg[propCfg][cfg?.entity?.attribute] : null; } }