Skip to content

Commit 02c1ab3

Browse files
bulk actions
1 parent 9ac931a commit 02c1ab3

File tree

1 file changed

+28
-34
lines changed

1 file changed

+28
-34
lines changed

client/packages/lowcoder/src/pages/editor/LeftLayersContent.tsx

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import cloneDeep from 'lodash/cloneDeep';
3333
import { useDispatch } from "react-redux";
3434
import { useApplicationId } from "util/hooks";
3535
import { updateApplication } from "redux/reduxActions/applicationActions";
36-
import { Button, Divider, Dropdown, Flex, Input, MenuProps, Space } from "antd";
36+
import { Button, Divider, Dropdown, Flex, Input, Menu, MenuProps, Space } from "antd";
3737
import { Switch } from "antd";
3838
import {
3939
saveCollisionStatus,
@@ -223,19 +223,7 @@ export const LeftLayersContent = (props: LeftLayersContentProps) => {
223223
pos: index,
224224
};
225225
})
226-
227-
dispatch(
228-
updateApplication({
229-
applicationId: applicationId,
230-
editingApplicationDSL: {
231-
...dsl,
232-
ui: {
233-
...dsl.ui,
234-
layout,
235-
}
236-
} as object,
237-
})
238-
);
226+
239227
editorState.rootComp.children.ui.dispatchChangeValueAction({
240228
...dsl.ui,
241229
layout,
@@ -292,30 +280,32 @@ export const LeftLayersContent = (props: LeftLayersContentProps) => {
292280
return checkedKeys;
293281
}
294282

283+
useEffect(() => {
284+
console.log('onChange', actionValue);
285+
}, [actionValue])
286+
295287
const getActionValue = () => {
296288
return actionValue;
297289
}
298290

299-
const handleComponentsActions = (actionType : string) => {
291+
const handleComponentsActions = useCallback((actionType: string) => {
292+
const value = getActionValue();
300293
for (let key of getCheckedKeys()) {
301294
const node = getTreeNodeByKey(componentTreeData, key);
302295
const comp = editorState.getUICompByName(node.title);
303-
if (comp != undefined) {
304-
if (actionType === "hidden") {
305-
comp.children.comp.dispatchChangeValueAction({ hidden: getActionValue() });
306-
}
307-
else if (actionType === "disable") {
308-
comp.children.comp.dispatchChangeValueAction({ disabled: getActionValue() });
309-
}
310-
else if (actionType === "background") {
311-
comp.children.comp.dispatchChangeValueAction({ BackgroundColor : getActionValue() });
296+
if(comp) {
297+
const { children } = comp.children.comp
298+
const types = actionType.split('.');
299+
300+
if(types.length === 1) { // e.g hidden, disabled
301+
children[types[0]]?.dispatchChangeValueAction(value);
312302
}
313-
else {
314-
comp.children.comp.dispatchChangeValueAction({ actionType: getActionValue() });
303+
else if(types.length === 2) { // nested object e.g. style.background
304+
children[types[0]][types[1]]?.dispatchChangeValueAction(value);
315305
}
316306
}
317307
}
318-
}
308+
}, [getActionValue, getCheckedKeys]);
319309

320310
/*
321311
@@ -331,18 +321,15 @@ export const LeftLayersContent = (props: LeftLayersContentProps) => {
331321
const layerActions: ItemType[] = [
332322
{
333323
label: 'Hide Component',
334-
key: 'hide',
335-
onClick: () => handleComponentsActions("hidden"),
324+
key: 'hidden',
336325
},
337326
{
338327
label: 'Disable Component',
339-
key: 'background',
340-
onClick: () => handleComponentsActions("disable"),
328+
key: 'disable',
341329
},
342330
{
343331
label: 'Component Background',
344-
key: '3',
345-
onClick: () => handleComponentsActions("background"),
332+
key: 'style.background',
346333
},
347334
{
348335
label: 'Unlock',
@@ -396,7 +383,14 @@ export const LeftLayersContent = (props: LeftLayersContentProps) => {
396383
{trans("leftPanel.selectedComponents")}<br/>
397384
{trans("leftPanel.displayComponents")}
398385
<Input placeholder="Action Value" onChange={handleActionValueChange}/>
399-
<CustomDropdown menu={{ items: layerActions }}>
386+
<CustomDropdown
387+
dropdownRender={() => (
388+
<Menu
389+
items={layerActions}
390+
onClick={({key}) => handleComponentsActions(key)}
391+
/>
392+
)}
393+
>
400394
<Button size={"small"}>
401395
<Space>
402396
Action

0 commit comments

Comments
 (0)