Skip to content

Commit

Permalink
feature: Add tempary toggle for the disabling date function
Browse files Browse the repository at this point in the history
  • Loading branch information
zjh1943 committed Mar 27, 2023
1 parent 6ba3582 commit baa7252
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "antddaterangepicker",
"widgetName": "AntdDateRangePicker",
"version": "1.0.3",
"version": "1.1.0",
"description": "A powerful Mendix pluggable widget used to pick date and time. It brings the ant-deign widget DatePicker into Mendix and implements almost all the features of the original widget.",
"copyright": "© Mendix Technology BV 2022. All rights reserved.",
"author": "Jonathan Zhu",
Expand Down
2 changes: 1 addition & 1 deletion src/AntdDateRangePicker.editorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function getProperties(
): Properties {
// Do the values manipulation here to control the visibility of properties in Studio and Studio Pro conditionally.
if (values.disableDateMode === "off") {
hidePropertiesIn(defaultProperties, values, ["disableDatesDatasource", "disableDatesAttribute"]);
hidePropertiesIn(defaultProperties, values, ["disableDateTemparyToggle", "disableDatesDatasource", "disableDatesAttribute"]);
}
if (values.showCustomFooter === false) {
hidePropertyIn(defaultProperties, values, "pannelFooterContent");
Expand Down
8 changes: 8 additions & 0 deletions src/AntdDateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,15 @@ export class AntdDateRangePicker extends Component<AntdDateRangePickerContainerP
}

// === sub group Disable Date ===
let disablingFunctionOpen = false;
if (props.disableDateMode !== "off") {
disablingFunctionOpen = true;
if (props.disableDateTemparyToggle && props.disableDateTemparyToggle?.value === false) {
disablingFunctionOpen = false;
}
}

if (disablingFunctionOpen) {
pickerProps.disabledDate = date => {
if (props.disableDatesDatasource?.status === "available") {
// console.log(`begin check disable. date = ${date}`);
Expand Down
7 changes: 7 additions & 0 deletions src/AntdDateRangePicker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@
<enumerationValue key="negative">Negative</enumerationValue>
</enumerationValues>
</property>
<property key="disableDateTemparyToggle" type="attribute" required="false">
<caption>Tempary toggle</caption>
<description>Use this dynamic attribute to control the tempary open state of the disabling function. Commonly, you do not need to config this property. Unless you want to close the disabling function tempary during the application running.</description>
<attributeTypes>
<attributeType name="Boolean" />
</attributeTypes>
</property>
<property key="disableDatesDatasource" type="datasource" isList="true" required="false">
<caption>Disable datasource</caption>
<description></description>
Expand Down
2 changes: 1 addition & 1 deletion src/package.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="AntdDateRangePicker" version="1.0.3" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="AntdDateRangePicker" version="1.1.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="AntdDateRangePicker.xml"/>
</widgetFiles>
Expand Down
2 changes: 2 additions & 0 deletions typings/AntdDateRangePickerProps.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface AntdDateRangePickerContainerProps {
defaultPickerValueStart?: EditableValue<Date>;
defaultPickerValueEnd?: EditableValue<Date>;
disableDateMode: DisableDateModeEnum;
disableDateTemparyToggle?: EditableValue<boolean>;
disableDatesDatasource?: ListValue;
disableDatesAttribute?: ListAttributeValue<Date>;
size: SizeEnum;
Expand Down Expand Up @@ -80,6 +81,7 @@ export interface AntdDateRangePickerPreviewProps {
defaultPickerValueStart: string;
defaultPickerValueEnd: string;
disableDateMode: DisableDateModeEnum;
disableDateTemparyToggle: string;
disableDatesDatasource: {} | { type: string } | null;
disableDatesAttribute: string;
size: SizeEnum;
Expand Down

0 comments on commit baa7252

Please sign in to comment.