Skip to content

Commit b25d5ce

Browse files
committed
feat: allow boolean to choose for checkbox type
1 parent 9565cc0 commit b25d5ce

File tree

12 files changed

+29
-5
lines changed

12 files changed

+29
-5
lines changed

packages/pluggableWidgets/checkbox-radio-selection-web/src/CheckboxRadioSelection.editorConfig.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export function getProperties(
4343
hidePropertiesIn(defaultProperties, values, ["customEditability", "customEditabilityExpression"]);
4444
}
4545

46+
if (values.optionsSourceType !== "boolean") {
47+
hidePropertiesIn(defaultProperties, values, ["controlType"]);
48+
}
49+
4650
if (values.source === "context") {
4751
hidePropertiesIn(defaultProperties, values, [
4852
"staticAttribute",

packages/pluggableWidgets/checkbox-radio-selection-web/src/CheckboxRadioSelection.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<widget id="com.mendix.widget.web.checkboxradioselection.CheckboxRadioSelection" pluginWidget="true" offlineCapable="true" xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../node_modules/mendix/custom_widget.xsd">
3-
<name>Checkbox Radio Selection</name>
3+
<name>Check box / Radio button</name>
44
<description />
55
<studioProCategory>Input elements</studioProCategory>
66
<studioCategory>Display</studioCategory>
@@ -28,6 +28,14 @@
2828
<enumerationValue key="boolean">Boolean</enumerationValue>
2929
</enumerationValues>
3030
</property>
31+
<property key="controlType" type="enumeration" defaultValue="checkbox" required="true">
32+
<caption>Component</caption>
33+
<description />
34+
<enumerationValues>
35+
<enumerationValue key="checkbox">Checkbox</enumerationValue>
36+
<enumerationValue key="radio">Radio button</enumerationValue>
37+
</enumerationValues>
38+
</property>
3139

3240
<!-- ENUM & BOOLEAN-->
3341
<property key="attributeEnumeration" type="attribute" required="true" setLabel="true">

packages/pluggableWidgets/checkbox-radio-selection-web/src/components/RadioSelection/RadioSelection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function RadioSelection({
4747
})}
4848
>
4949
<input
50-
type="radio"
50+
type={selector.controlType}
5151
id={radioId}
5252
name={name}
5353
value={optionId}

packages/pluggableWidgets/checkbox-radio-selection-web/src/helpers/Association/AssociationSingleSelector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export class AssociationSingleSelector
88
implements SingleSelector
99
{
1010
type = "single" as const;
11+
controlType: "checkbox" | "radio" = "radio";
1112

1213
updateProps(props: CheckboxRadioSelectionContainerProps): void {
1314
super.updateProps(props);

packages/pluggableWidgets/checkbox-radio-selection-web/src/helpers/Association/Preview/AssociationPreviewSelector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class AssociationPreviewSelector implements SingleSelector {
1313
status: Status = "available";
1414
attributeType?: "string" | "boolean" | "big" | "date" | undefined;
1515
selectorType?: "context" | "database" | "static" | undefined;
16+
controlType: "checkbox" | "radio" = "radio";
1617
// type: "single";
1718
readOnly: boolean;
1819
validation?: string | undefined;

packages/pluggableWidgets/checkbox-radio-selection-web/src/helpers/Database/DatabaseSingleSelector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export class DatabaseSingleSelector<T extends string | Big, R extends EditableVa
1616
attributeType: "string" | "big" | "boolean" | "date" = "string";
1717
selectorType: "context" | "database" | "static" = "database";
1818
status: Status = "unavailable";
19+
controlType: "checkbox" | "radio" = "radio";
1920
options: DatabaseOptionsProvider;
2021
caption: DatabaseCaptionsProvider;
2122
clearable = false;

packages/pluggableWidgets/checkbox-radio-selection-web/src/helpers/Database/Preview/DatabasePreviewSelector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class DatabasePreviewSelector implements SingleSelector {
1313
status: Status = "available";
1414
attributeType?: "string" | "boolean" | "big" | "date" | undefined;
1515
selectorType?: "context" | "database" | "static" | undefined;
16-
// type: "single";
16+
controlType: "checkbox" | "radio" = "radio";
1717
readOnly: boolean;
1818
validation?: string | undefined;
1919
clearable: boolean = false;

packages/pluggableWidgets/checkbox-radio-selection-web/src/helpers/EnumBool/EnumBooleanSingleSelector.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { extractEnumerationProps } from "./utils";
1212
export class EnumBooleanSingleSelector implements SingleSelector {
1313
status: Status = "unavailable";
1414
type = "single" as const;
15+
controlType: "checkbox" | "radio" = "radio";
1516
validation?: string = undefined;
1617
private isBoolean = false;
1718
private _attr: EditableValue<string | boolean> | undefined;
@@ -58,6 +59,7 @@ export class EnumBooleanSingleSelector implements SingleSelector {
5859
this.currentId = attr.value?.toString() ?? null;
5960
this.readOnly = attr.readOnly;
6061
this.validation = attr.validation;
62+
this.controlType = props.controlType;
6163
}
6264

6365
setValue(value: string | null): void {

packages/pluggableWidgets/checkbox-radio-selection-web/src/helpers/Static/Preview/StaticPreviewSelector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class StaticPreviewSelector implements SingleSelector {
1313
status: Status = "available";
1414
attributeType?: "string" | "boolean" | "big" | "date" | undefined;
1515
selectorType?: "context" | "database" | "static" | undefined;
16-
// type: "single";
16+
controlType: "checkbox" | "radio" = "radio";
1717
readOnly: boolean;
1818
validation?: string | undefined;
1919
clearable: boolean = false;

packages/pluggableWidgets/checkbox-radio-selection-web/src/helpers/Static/StaticSingleSelector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class StaticSingleSelector implements SingleSelector {
1717
attributeType: "string" | "big" | "boolean" | "date" = "string";
1818
selectorType: "context" | "database" | "static" = "static";
1919
status: Status = "unavailable";
20+
controlType: "checkbox" | "radio" = "radio";
2021
options: StaticOptionsProvider;
2122
caption: StaticCaptionsProvider;
2223
clearable = false;

0 commit comments

Comments
 (0)