Skip to content

Commit e361299

Browse files
committed
fix simple column type (btn)
1 parent dfe87b3 commit e361299

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

client/packages/lowcoder/src/comps/comps/tableComp/column/simpleColumnTypeComps.tsx

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,21 @@ import { CSSProperties } from "react";
1414
import { RecordConstructorToComp } from "lowcoder-core";
1515
import { ToViewReturn } from "@lowcoder-ee/comps/generators/multi";
1616
import { clickEvent, eventHandlerControl } from "comps/controls/eventHandlerControl";
17+
import { migrateOldData } from "@lowcoder-ee/comps/generators/simpleGenerators";
1718

19+
export const fixOldActionData = (oldData: any) => {
20+
if (!oldData) return oldData;
21+
if (Boolean(oldData.onClick)) {
22+
return {
23+
...oldData,
24+
onClick: [{
25+
name: "click",
26+
handler: oldData.onClick,
27+
}],
28+
};
29+
}
30+
return oldData;
31+
}
1832
export const ColumnValueTooltip = trans("table.columnValueTooltip");
1933

2034
export const ButtonTypeOptions = [
@@ -37,8 +51,7 @@ const ButtonEventOptions = [clickEvent] as const;
3751
const childrenMap = {
3852
text: StringControl,
3953
buttonType: dropdownControl(ButtonTypeOptions, "primary"),
40-
onClick: ActionSelectorControlInContext,
41-
onEvent: eventHandlerControl(ButtonEventOptions),
54+
onClick: eventHandlerControl(ButtonEventOptions),
4255
loading: BoolCodeControl,
4356
disabled: BoolCodeControl,
4457
prefixIcon: IconControl,
@@ -53,11 +66,8 @@ const ButtonStyled = React.memo(({ props }: { props: ToViewReturn<RecordConstruc
5366
const iconOnly = !hasText && (hasPrefixIcon || hasSuffixIcon);
5467

5568
const handleClick = useCallback((e: React.MouseEvent) => {
56-
// Trigger legacy onClick action for backward compatibility
57-
props.onClick?.();
58-
// Trigger new event handlers
59-
props.onEvent?.("click");
60-
}, [props.onClick, props.onEvent]);
69+
props.onClick?.("click");
70+
}, [props.onClick]);
6171

6272
const buttonStyle = useMemo(() => ({
6373
margin: 0,
@@ -83,43 +93,34 @@ const ButtonStyled = React.memo(({ props }: { props: ToViewReturn<RecordConstruc
8393
);
8494
});
8595

86-
export const ButtonComp = (function () {
96+
const ButtonCompTmp = (function () {
8797
return new ColumnTypeCompBuilder(
8898
childrenMap,
8999
(props) => <ButtonStyled props={props} />,
90100
(nodeValue) => nodeValue.text.value
91101
)
92-
.setPropertyViewFn((children) => {
93-
// Check if there's a legacy action configured
94-
const hasLegacyAction = children.onClick.getView() &&
95-
typeof children.onClick.getView() === 'function' &&
96-
children.onClick.displayName() !== trans("eventHandler.incomplete");
97-
98-
return (
99-
<>
100-
{children.text.propertyView({
101-
label: trans("table.columnValue"),
102-
tooltip: ColumnValueTooltip,
103-
})}
104-
{children.prefixIcon.propertyView({
105-
label: trans("button.prefixIcon"),
106-
})}
107-
{children.suffixIcon.propertyView({
108-
label: trans("button.suffixIcon"),
109-
})}
110-
{children.buttonType.propertyView({
111-
label: trans("table.type"),
112-
radioButton: true,
113-
})}
114-
{loadingPropertyView(children)}
115-
{disabledPropertyView(children)}
116-
{children.onEvent.propertyView()}
117-
{hasLegacyAction && children.onClick.propertyView({
118-
label: trans("table.action"),
119-
placement: "table",
120-
})}
121-
</>
122-
);
123-
})
102+
.setPropertyViewFn((children) => (
103+
<>
104+
{children.text.propertyView({
105+
label: trans("table.columnValue"),
106+
tooltip: ColumnValueTooltip,
107+
})}
108+
{children.prefixIcon.propertyView({
109+
label: trans("button.prefixIcon"),
110+
})}
111+
{children.suffixIcon.propertyView({
112+
label: trans("button.suffixIcon"),
113+
})}
114+
{children.buttonType.propertyView({
115+
label: trans("table.type"),
116+
radioButton: true,
117+
})}
118+
{loadingPropertyView(children)}
119+
{disabledPropertyView(children)}
120+
{children.onClick.propertyView()}
121+
</>
122+
))
124123
.build();
125124
})();
125+
126+
export const ButtonComp = migrateOldData(ButtonCompTmp, fixOldActionData);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy