mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-22 16:38:21 +00:00
fixes: entity ids needs to map correctly with entity name in for a referenced to b type
This commit is contained in:
parent
e4c1a3c82f
commit
f841e9ccbd
3 changed files with 45 additions and 7 deletions
|
|
@ -1379,11 +1379,22 @@ const EditorComponent = (props) => {
|
|||
|
||||
const newAppDefinition = JSON.parse(JSON.stringify(useEditorStore.getState().appDefinition));
|
||||
const currentComponents = newAppDefinition.pages[currentPageId].components;
|
||||
const currentDataQueries = useDataQueriesStore.getState().dataQueries;
|
||||
|
||||
const newComponentDefinition = useResolveStore
|
||||
.getState()
|
||||
.actions.findAndReplaceReferences(currentComponents, deletedComponentNames);
|
||||
|
||||
const entityReferencesInQuerries = findAllEntityReferences(currentDataQueries, []);
|
||||
|
||||
if (entityReferencesInQuerries.length > 0) {
|
||||
const newDataQueries = useResolveStore
|
||||
.getState()
|
||||
.actions.findAndReplaceReferences(currentDataQueries, deletedComponentNames);
|
||||
|
||||
useDataQueriesStore.getState().actions.setDataQueries(newDataQueries, 'mappingUpdate');
|
||||
}
|
||||
|
||||
newAppDefinition.pages[currentPageId].components = newComponentDefinition;
|
||||
|
||||
useEditorStore.getState().actions.updateEditorState({
|
||||
|
|
|
|||
|
|
@ -1232,7 +1232,7 @@ export function runQuery(
|
|||
useResolveStore.getState().actions.addAppSuggestions({
|
||||
queries: {
|
||||
[queryName]: {
|
||||
data: [...finalData],
|
||||
data: finalData,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
import { create, zustandDevTools } from './utils';
|
||||
import { create, findAllEntityReferences, zustandDevTools } from './utils';
|
||||
import { getDefaultOptions } from './storeHelper';
|
||||
import { dataqueryService } from '@/_services';
|
||||
// import debounce from 'lodash/debounce';
|
||||
import { useAppDataStore } from '@/_stores/appDataStore';
|
||||
import { useQueryPanelStore } from '@/_stores/queryPanelStore';
|
||||
import { useAppVersionStore } from '@/_stores/appVersionStore';
|
||||
import { runQueries } from '@/_helpers/appUtils';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { toast } from 'react-hot-toast';
|
||||
import _, { isEmpty, throttle } from 'lodash';
|
||||
|
|
@ -101,10 +99,15 @@ export const useDataQueriesStore = create(
|
|||
set({ dataQueries });
|
||||
if (type === 'mappingUpdate') {
|
||||
const { actions } = useQueryPanelStore.getState();
|
||||
actions.setSelectedQuery(null);
|
||||
const queryId = dataQueries[0]?.id;
|
||||
|
||||
actions.setSelectedQuery(queryId);
|
||||
return new Promise((resolve) => {
|
||||
actions.setSelectedQuery(null);
|
||||
resolve();
|
||||
}).then(() => {
|
||||
const queryId = dataQueries[0]?.id;
|
||||
|
||||
actions.setSelectedQuery(queryId);
|
||||
});
|
||||
}
|
||||
},
|
||||
deleteDataQueries: (queryId) => {
|
||||
|
|
@ -138,6 +141,30 @@ export const useDataQueriesStore = create(
|
|||
}, {}),
|
||||
});
|
||||
|
||||
const newAppDefinition = JSON.parse(JSON.stringify(useEditorStore.getState().appDefinition));
|
||||
const currentPageId = useEditorStore.getState().currentPageId;
|
||||
const currentComponents = newAppDefinition.pages[currentPageId].components;
|
||||
|
||||
const newComponentDefinition = useResolveStore
|
||||
.getState()
|
||||
.actions.findAndReplaceReferences(currentComponents, [deletedQueryName]);
|
||||
const entityReferencesInQuerries = findAllEntityReferences(get().dataQueries, []);
|
||||
|
||||
if (entityReferencesInQuerries.length > 0) {
|
||||
const newDataQueries = useResolveStore
|
||||
.getState()
|
||||
.actions.findAndReplaceReferences(get().dataQueries, [deletedQueryName]);
|
||||
|
||||
get().actions.setDataQueries(newDataQueries, 'mappingUpdate');
|
||||
}
|
||||
|
||||
newAppDefinition.pages[currentPageId].components = newComponentDefinition;
|
||||
|
||||
useEditorStore.getState().actions.updateEditorState({
|
||||
appDefinition: newAppDefinition,
|
||||
isUpdatingEditorStateInProcess: true,
|
||||
});
|
||||
|
||||
const referenceManager = useResolveStore.getState().referenceMapper;
|
||||
referenceManager.delete(queryId);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue