Skip to content

Commit 6880071

Browse files
committed
feat: no options text
1 parent c076024 commit 6880071

File tree

12 files changed

+33
-19
lines changed

12 files changed

+33
-19
lines changed

packages/pluggableWidgets/checkbox-radio-selection-web/src/CheckboxRadioSelection.editorPreview.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export const preview = (props: CheckboxRadioSelectionPreviewProps): ReactElement
2222
labelId: `${id}-label`,
2323
readOnlyStyle: props.readOnlyStyle,
2424
ariaRequired: dynamic(false),
25-
groupName: dynamic(`${id}-group`)
25+
groupName: dynamic(`${id}-group`),
26+
emptyOptionText: "NO OPTIONS AVAILABLE"
2627
};
2728

2829
// eslint-disable-next-line react-hooks/rules-of-hooks

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ export default function CheckboxRadioSelection(props: CheckboxRadioSelectionCont
1818
labelId: `${props.id}-label`,
1919
readOnlyStyle: props.readOnlyStyle,
2020
ariaRequired: props.ariaRequired,
21-
groupName: props.groupName
21+
groupName: props.groupName,
22+
emptyOptionText: props.emptyOptionText?.value ?? "NO OPTIONS AVAILABLE"
2223
};
2324

2425
return (
2526
<div className={`widget-checkbox-radio-selection`}>
2627
{selector.status === "unavailable" ? (
27-
<Placeholder />
28+
<Placeholder emptyOptionText={commonProps.emptyOptionText} />
2829
) : selector.type === "single" ? (
2930
<RadioSelection selector={selector} {...commonProps} />
3031
) : (

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@
190190
<!-- STATIC END-->
191191
<!-- GENERAL -->
192192
<propertyGroup caption="General">
193+
<property key="emptyOptionText" type="textTemplate" required="false">
194+
<caption>Empty option text</caption>
195+
<description />
196+
<translations>
197+
<translation lang="en_US">NO OPTIONS AVAILABLE</translation>
198+
<translation lang="nl_NL">GEEN OPTIES BESCHIKBAAR</translation>
199+
</translations>
200+
</property>
193201
<property key="optionsSourceCustomContentType" type="enumeration" defaultValue="no" required="true">
194202
<caption>Custom content</caption>
195203
<description />

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import classNames from "classnames";
22
import { ReactElement, createElement, MouseEvent } from "react";
33
import { SelectionBaseProps, MultiSelector } from "../../helpers/types";
44
import { CaptionContent } from "../CaptionContent";
5+
import { Placeholder } from "../Placeholder";
56

67
export function CheckboxSelection({
78
selector,
89
tabIndex = 0,
910
inputId,
1011
ariaRequired,
1112
readOnlyStyle,
12-
groupName
13+
groupName,
14+
emptyOptionText
1315
}: SelectionBaseProps<MultiSelector>): ReactElement {
1416
const options = selector.getOptions();
1517
const currentIds = selector.currentId || [];
@@ -68,7 +70,7 @@ export function CheckboxSelection({
6870
</div>
6971
);
7072
})}
71-
{options.length === 0 && <div className="widget-checkbox-radio-selection-no-options">{`<...>`}</div>}
73+
{options.length === 0 && <Placeholder emptyOptionText={emptyOptionText} />}
7274
</div>
7375
);
7476
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ReactElement, createElement } from "react";
22

3-
export function Placeholder(): ReactElement {
3+
export function Placeholder({ emptyOptionText }: { emptyOptionText: string }): ReactElement {
44
return (
55
<div className="form-control widget-checkbox-radio-selection-placeholder">
6-
<div className="widget-checkbox-radio-selection-placeholder-content">Loading...</div>
6+
<div className="widget-checkbox-radio-selection-placeholder-content">{emptyOptionText}</div>
77
</div>
88
);
99
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import classNames from "classnames";
22
import { ChangeEvent, ReactElement, createElement, MouseEvent } from "react";
33
import { SelectionBaseProps, SingleSelector } from "../../helpers/types";
44
import { CaptionContent } from "../CaptionContent";
5+
import { Placeholder } from "../Placeholder";
56

67
export function RadioSelection({
78
selector,
89
tabIndex = 0,
910
inputId,
1011
ariaRequired,
1112
readOnlyStyle,
12-
groupName
13+
groupName,
14+
emptyOptionText
1315
}: SelectionBaseProps<SingleSelector>): ReactElement {
1416
const asSingleCheckbox = selector.controlType === "checkbox";
1517

@@ -80,7 +82,7 @@ export function RadioSelection({
8082
</div>
8183
);
8284
})}
83-
{options.length === 0 && <div className="widget-checkbox-radio-selection-no-options">{`<...>`}</div>}
85+
{options.length === 0 && <Placeholder emptyOptionText={emptyOptionText} />}
8486
</div>
8587
);
8688
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { SingleSelector, Status, CaptionsProvider, OptionsProvider } from "../../types";
21
import {
32
CheckboxRadioSelectionPreviewProps,
43
OptionsSourceCustomContentTypeEnum
54
} from "../../../../typings/CheckboxRadioSelectionProps";
6-
import { generateUUID } from "@mendix/widget-plugin-platform/framework/generate-uuid";
75
import { PreviewCaptionsProvider } from "../../Preview/PreviewCaptionsProvider";
86
import { PreviewOptionsProvider } from "../../Preview/PreviewOptionsProvider";
7+
import { CaptionsProvider, OptionsProvider, SingleSelector, Status } from "../../types";
98
import { getCustomCaption } from "../../utils";
109

1110
export class AssociationPreviewSelector implements SingleSelector {
@@ -24,7 +23,7 @@ export class AssociationPreviewSelector implements SingleSelector {
2423

2524
constructor(props: CheckboxRadioSelectionPreviewProps) {
2625
this.readOnly = props.readOnly;
27-
this.currentId = `single-${generateUUID()}`;
26+
this.currentId = `PREVIEW_OPTION`;
2827
this.customContentType = props.optionsSourceCustomContentType;
2928
this.readOnly = props.readOnly;
3029
this.controlType = props.controlType;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { SingleSelector, Status, CaptionsProvider, OptionsProvider, MultiSelector } from "../../types";
21
import {
32
CheckboxRadioSelectionPreviewProps,
43
OptionsSourceCustomContentTypeEnum
54
} from "../../../../typings/CheckboxRadioSelectionProps";
6-
import { generateUUID } from "@mendix/widget-plugin-platform/framework/generate-uuid";
75
import { PreviewCaptionsProvider } from "../../Preview/PreviewCaptionsProvider";
86
import { PreviewOptionsProvider } from "../../Preview/PreviewOptionsProvider";
7+
import { CaptionsProvider, MultiSelector, OptionsProvider, SingleSelector, Status } from "../../types";
98
import { getCustomCaption } from "../../utils";
109

1110
export class DatabasePreviewSelector implements SingleSelector {
@@ -23,7 +22,7 @@ export class DatabasePreviewSelector implements SingleSelector {
2322
options: OptionsProvider;
2423

2524
constructor(props: CheckboxRadioSelectionPreviewProps) {
26-
this.currentId = `single-${generateUUID()}`;
25+
this.currentId = `PREVIEW_OPTION`;
2726
this.customContentType = props.optionsSourceCustomContentType;
2827
this.readOnly = props.readOnly;
2928
this.caption = new PreviewCaptionsProvider(new Map(), getCustomCaption(props));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ export class PreviewOptionsProvider implements OptionsProvider<ObjectItem, BaseO
2727
throw new Error("Method not implemented.");
2828
}
2929
getAll(): string[] {
30-
return ["..."];
30+
return ["PREVIEW_OPTION"];
3131
}
3232
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { SingleSelector, Status, CaptionsProvider, OptionsProvider } from "../../types";
21
import {
32
CheckboxRadioSelectionPreviewProps,
43
OptionsSourceCustomContentTypeEnum
54
} from "../../../../typings/CheckboxRadioSelectionProps";
65
import { PreviewCaptionsProvider } from "../../Preview/PreviewCaptionsProvider";
76
import { PreviewOptionsProvider } from "../../Preview/PreviewOptionsProvider";
8-
import { generateUUID } from "@mendix/widget-plugin-platform/framework/generate-uuid";
7+
import { CaptionsProvider, OptionsProvider, SingleSelector, Status } from "../../types";
98
import { getCustomCaption } from "../../utils";
109

1110
export class StaticPreviewSelector implements SingleSelector {
@@ -23,7 +22,7 @@ export class StaticPreviewSelector implements SingleSelector {
2322
options: OptionsProvider;
2423

2524
constructor(props: CheckboxRadioSelectionPreviewProps) {
26-
this.currentId = `single-${generateUUID()}`;
25+
this.currentId = `PREVIEW_OPTION`;
2726
this.customContentType = props.optionsSourceCustomContentType;
2827
this.readOnly = props.readOnly;
2928
this.caption = new PreviewCaptionsProvider(new Map(), getCustomCaption(props));

0 commit comments

Comments
 (0)