mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
remove widget/component(s): fixed
This commit is contained in:
parent
453405d7f2
commit
9770df8b3f
3 changed files with 14 additions and 14 deletions
|
|
@ -56,7 +56,7 @@ export const ConfigHandle = function ConfigHandle({
|
||||||
role="button"
|
role="button"
|
||||||
height="12"
|
height="12"
|
||||||
draggable="false"
|
draggable="false"
|
||||||
onClick={() => removeComponent({ id })}
|
onClick={() => removeComponent(id)}
|
||||||
data-cy={`${component.name.toLowerCase()}-delete-button`}
|
data-cy={`${component.name.toLowerCase()}-delete-button`}
|
||||||
className="delete-icon"
|
className="delete-icon"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -768,7 +768,7 @@ const EditorComponent = (props) => {
|
||||||
draft.homePageId = newDefinition.homePageId;
|
draft.homePageId = newDefinition.homePageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts?.generalAppDefinitionChanged || opts?.globalSettings) {
|
if (opts?.generalAppDefinitionChanged || opts?.globalSettings || isEmpty(opts)) {
|
||||||
Object.assign(draft, newDefinition);
|
Object.assign(draft, newDefinition);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -952,20 +952,20 @@ const EditorComponent = (props) => {
|
||||||
// }
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeComponent = (component) => {
|
const removeComponent = (componentId) => {
|
||||||
if (!props.isVersionReleased) {
|
if (!props.isVersionReleased) {
|
||||||
let newDefinition = cloneDeep(appDefinition);
|
let newDefinition = cloneDeep(appDefinition);
|
||||||
// Delete child components when parent is deleted
|
// Delete child components when parent is deleted
|
||||||
|
|
||||||
let childComponents = [];
|
let childComponents = [];
|
||||||
|
|
||||||
if (newDefinition.pages[currentPageId].components?.[component.id].component.component === 'Tabs') {
|
if (newDefinition.pages[currentPageId].components?.[componentId].component.component === 'Tabs') {
|
||||||
childComponents = Object.keys(newDefinition.pages[currentPageId].components).filter((key) =>
|
childComponents = Object.keys(newDefinition.pages[currentPageId].components).filter((key) =>
|
||||||
newDefinition.pages[currentPageId].components[key].parent?.startsWith(component.id)
|
newDefinition.pages[currentPageId].components[key].parent?.startsWith(componentId)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
childComponents = Object.keys(newDefinition.pages[currentPageId].components).filter(
|
childComponents = Object.keys(newDefinition.pages[currentPageId].components).filter(
|
||||||
(key) => newDefinition.pages[currentPageId].components[key].parent === component.id
|
(key) => newDefinition.pages[currentPageId].components[key].parent === componentId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -973,7 +973,7 @@ const EditorComponent = (props) => {
|
||||||
delete newDefinition.pages[currentPageId].components[componentId];
|
delete newDefinition.pages[currentPageId].components[componentId];
|
||||||
});
|
});
|
||||||
|
|
||||||
delete newDefinition.pages[currentPageId].components[component.id];
|
delete newDefinition.pages[currentPageId].components[componentId];
|
||||||
const platform = navigator?.userAgentData?.platform || navigator?.platform || 'unknown';
|
const platform = navigator?.userAgentData?.platform || navigator?.platform || 'unknown';
|
||||||
if (platform.toLowerCase().indexOf('mac') > -1) {
|
if (platform.toLowerCase().indexOf('mac') > -1) {
|
||||||
toast('Component deleted! (⌘ + Z to undo)', {
|
toast('Component deleted! (⌘ + Z to undo)', {
|
||||||
|
|
@ -985,7 +985,7 @@ const EditorComponent = (props) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
appDefinitionChanged(newDefinition, {
|
appDefinitionChanged(newDefinition, {
|
||||||
skipAutoSave: props.isVersionReleased,
|
componentDefinitionChanged: true,
|
||||||
});
|
});
|
||||||
handleInspectorView();
|
handleInspectorView();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1049,10 +1049,10 @@ const EditorComponent = (props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeComponents = () => {
|
const removeComponents = () => {
|
||||||
if (!props.isVersionReleased && selectedComponents?.length > 1) {
|
if (!props.isVersionReleased && selectedComponents?.length >= 1) {
|
||||||
let newDefinition = cloneDeep(appDefinition);
|
let newDefinition = cloneDeep(appDefinition);
|
||||||
|
|
||||||
removeSelectedComponent(currentPageId, newDefinition, selectedComponents);
|
removeSelectedComponent(currentPageId, newDefinition, selectedComponents, appDefinitionChanged);
|
||||||
const platform = navigator?.userAgentData?.platform || navigator?.platform || 'unknown';
|
const platform = navigator?.userAgentData?.platform || navigator?.platform || 'unknown';
|
||||||
if (platform.toLowerCase().indexOf('mac') > -1) {
|
if (platform.toLowerCase().indexOf('mac') > -1) {
|
||||||
toast('Selected components deleted! (⌘ + Z to undo)', {
|
toast('Selected components deleted! (⌘ + Z to undo)', {
|
||||||
|
|
@ -1063,9 +1063,7 @@ const EditorComponent = (props) => {
|
||||||
icon: '🗑️',
|
icon: '🗑️',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
appDefinitionChanged(newDefinition, {
|
// appDefinitionChanged(newDefinition);
|
||||||
skipAutoSave: props.isVersionReleased,
|
|
||||||
});
|
|
||||||
handleInspectorView();
|
handleInspectorView();
|
||||||
} else if (props.isVersionReleased) {
|
} else if (props.isVersionReleased) {
|
||||||
useAppVersionStore.getState().actions.enableReleasedVersionPopupState();
|
useAppVersionStore.getState().actions.enableReleasedVersionPopupState();
|
||||||
|
|
|
||||||
|
|
@ -1565,7 +1565,7 @@ export function snapToGrid(canvasWidth, x, y) {
|
||||||
const snappedY = Math.round(y / 10) * 10;
|
const snappedY = Math.round(y / 10) * 10;
|
||||||
return [snappedX, snappedY];
|
return [snappedX, snappedY];
|
||||||
}
|
}
|
||||||
export const removeSelectedComponent = (pageId, newDefinition, selectedComponents) => {
|
export const removeSelectedComponent = (pageId, newDefinition, selectedComponents, updateAppDefinition) => {
|
||||||
selectedComponents.forEach((component) => {
|
selectedComponents.forEach((component) => {
|
||||||
let childComponents = [];
|
let childComponents = [];
|
||||||
|
|
||||||
|
|
@ -1585,6 +1585,8 @@ export const removeSelectedComponent = (pageId, newDefinition, selectedComponent
|
||||||
|
|
||||||
delete newDefinition.pages[pageId].components[component.id];
|
delete newDefinition.pages[pageId].components[component.id];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
updateAppDefinition(newDefinition, { componentDefinitionChanged: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSelectedText = () => {
|
const getSelectedText = () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue