mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 01:18:23 +00:00
Fixed events missing on duplicating queries (#2499)
This commit is contained in:
parent
f45463d889
commit
1c83d01026
3 changed files with 18 additions and 2 deletions
|
|
@ -262,7 +262,7 @@ export const copyComponents = ({ isCut = false, isCloning = false }) => {
|
|||
|
||||
for (let selectedComponent of filteredSelectedComponents) {
|
||||
if (addedComponentId.has(selectedComponent.id)) continue;
|
||||
const events = useStore.getState().eventsSlice.geEventsByComponentsId(selectedComponent.id);
|
||||
const events = useStore.getState().eventsSlice.getEventsByComponentsId(selectedComponent.id);
|
||||
const component = {
|
||||
component: allComponents[selectedComponent.id]?.component,
|
||||
layouts: allComponents[selectedComponent.id]?.layouts,
|
||||
|
|
|
|||
|
|
@ -223,6 +223,8 @@ export const createDataQuerySlice = (set, get) => ({
|
|||
set((state) => {
|
||||
state.dataQuery.creatingQueryInProcessId = uuidv4();
|
||||
});
|
||||
const { eventsSlice } = get();
|
||||
const { getEventsByComponentsId, createAppVersionEventHandlers } = eventsSlice;
|
||||
const dataQueries = get().dataQuery.queries.modules[moduleId];
|
||||
const queryToClone = { ...dataQueries.find((query) => query.id === id) };
|
||||
let newName = queryToClone.name + '_copy';
|
||||
|
|
@ -266,6 +268,20 @@ export const createDataQuerySlice = (set, get) => ({
|
|||
rawData: [],
|
||||
id: data.id,
|
||||
});
|
||||
|
||||
const events = getEventsByComponentsId(queryToClone.id);
|
||||
|
||||
events.forEach((event) => {
|
||||
const newEvent = {
|
||||
event: {
|
||||
...event.event,
|
||||
},
|
||||
eventType: event.target,
|
||||
attachedTo: data.id,
|
||||
index: event.index,
|
||||
};
|
||||
createAppVersionEventHandlers(newEvent, moduleId);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('error', error);
|
||||
|
|
|
|||
|
|
@ -948,7 +948,7 @@ export const createEventsSlice = (set, get) => ({
|
|||
};
|
||||
},
|
||||
// Selectors
|
||||
geEventsByComponentsId: (componentId, moduleId = 'canvas') => {
|
||||
getEventsByComponentsId: (componentId, moduleId = 'canvas') => {
|
||||
const { eventsSlice } = get();
|
||||
return eventsSlice.module[moduleId]?.events?.filter((event) => event.sourceId === componentId);
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue