Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add editability feature #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/CustomDropdown.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
<description>Widget to make a selection in a dropdown menu.</description>
<icon/>
<properties>
<propertyGroup caption="General">
<property key="editable" type="boolean" required="true" defaultValue="true" >
<caption>Editable</caption>
<description>The widget doesn't listen to the editability setting of the containing dataview, but you can set it's editability here</description>
</property>
</propertyGroup>

<propertyGroup caption="Data source">
<property key="defaultValue" type="datasource" isList="true" required="false" >
<caption>Default value</caption>
Expand Down
3 changes: 2 additions & 1 deletion src/components/CustomDropdown/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const defaultProps = {
enableClear: true,
enableSearch: true,
useAvatar: true,
editable: true,
useDefaultStyle: true,
placeholder: "placeholder",
className: "custom-dropdown",
Expand Down Expand Up @@ -380,7 +381,7 @@ describe("Custom dropdown component", () => {
paginate: false,
setLimit
},
paginate: false,
paginate: false
};
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down
2 changes: 2 additions & 0 deletions src/components/CustomDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ export default class CustomDropdown extends Component<CustomDropdownContainerPro
onChange={this.handleChange}
isClearable={this.props.enableClear}
isSearchable={this.props.enableSearch}
isDisabled={!this.props.editable}
styles={styles}
placeholder={isLoading ? "Loading..." : this.props.placeholder}
className={this.props.className!}
Expand Down Expand Up @@ -330,6 +331,7 @@ export default class CustomDropdown extends Component<CustomDropdownContainerPro
onChange={this.handleChange}
isClearable={this.props.enableClear}
isSearchable={this.props.enableSearch}
isDisabled={!this.props.editable}
styles={styles}
placeholder={isLoading ? "Loading..." : this.props.placeholder}
className={this.props.className!}
Expand Down
Binary file modified tests/testProject/CustomDropdownTestProject.mpr
Binary file not shown.
Binary file modified tests/testProject/widgets/mendix.CustomDropdown.mpk
Binary file not shown.
2 changes: 2 additions & 0 deletions typings/CustomDropdownProps.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface CustomDropdownContainerProps {
class: string;
style?: CSSProperties;
tabIndex?: number;
editable: boolean;
defaultValue?: ListValue;
objIdDefaultValue?: ListAttributeValue<string>;
firstLabelDefaultValue?: ListAttributeValue<string>;
Expand Down Expand Up @@ -43,6 +44,7 @@ export interface CustomDropdownContainerProps {
export interface CustomDropdownPreviewProps {
class: string;
style: string;
editable: boolean;
defaultValue: {} | { type: string } | null;
objIdDefaultValue: string;
firstLabelDefaultValue: string;
Expand Down