-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Implement Validation for Date Picker #2165
base: develop
Are you sure you want to change the base?
Conversation
Signed-off-by: JeevaRamanathan M <[email protected]>
I think a dict (object) might not be the more user-friendly way for the user... |
Actually I do think that a dict may be the only option we have. However, I wouldn't hardcode the notion of weekend or workday. This varies across cultures. My first thoughts about this would be a dict with two optional slots: one would indicate dates that must be forbidden, another would be dates that are explicitly available. The way I see you can express this is:
This has the issue of having days that fall in the two buckets, the a priority may be needed. Now I like the 'occurrence' thing but we need to allow for more expressivity, again. Same for 'repeat' (or 'interval'). The period (week, month, year...) needs to be expressed somehow. |
@FabienLelaquais, for example, Wednesday and Thursday (days 3 and 4) are accepted but also fall within the rejection period. Are you referring to this as falling into two buckets and needing prioritization, or is it something different? |
Hi @FabienLelaquais, I'd like to get your thoughts on the updated structure for date_constraints. I’ve added support for priority, weekly, monthly, yearly rules along with the after week attribute to address the cases like US election logic.
Prolly the same repeat format can be used for accept; Here's the sample frontend workaround logic for this structure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you fix the failing checks ?
Signed-off-by: JeevaRamanathan M <[email protected]>
…into issue/848
Signed-off-by: JeevaRamanathan M <[email protected]>
Signed-off-by: JeevaRamanathan M <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see a few frontend tests.
Can you add a time constraint in the rules ? (ie for example allow only to select time that are multiple of 15 minutes)
analogic? :boolean; | ||
analogic?: boolean; | ||
disableDateConfig?: string; | ||
defaultDisableDateConfig?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for this as it is not dynamic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to confirm the structure. Can I make these changes to the initial structure for the time?
{
disableWeekdays?: boolean;
disableWeekends?: boolean;
disablePastDays?: boolean;
disableFutureDays?: boolean;
dayOfWeek?: number; // 0-6 (0 = Monday, ..., 6 = Sunday)
interval?: number;
oddInterval?:boolean;
occurence?: number;
}
Or should I follow the new logic that is currently under discussion and has not been finalized after FabienLelaquais comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll wait for @FabienLelaquais 's input
@@ -74,6 +86,8 @@ const DateSelector = (props: DateSelectorProps) => { | |||
const hover = useDynamicProperty(props.hoverText, props.defaultHoverText, undefined); | |||
const min = useDynamicProperty(props.min, props.defaultMin, undefined); | |||
const max = useDynamicProperty(props.max, props.defaultMax, undefined); | |||
const emptyDateConfig = {} as Partial<DisableDateConfig>; | |||
const disableDateConfig = useDynamicJsonProperty(props.disableDateConfig, props.defaultDisableDateConfig || "", emptyDateConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for this as it is not dynamic, but your need to JSON parse it
@@ -115,25 +129,76 @@ const DateSelector = (props: DateSelectorProps) => { | |||
} | |||
}, [props.date, tz, withTime, max, min]); | |||
|
|||
|
|||
const getWeekNumberInMonth = (date: Date) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be defined outside the component
const weekNo: number = Math.ceil(((d.getTime() - firstDayOfMonth.getTime()) / 86400000 + 1) / 7); | ||
return weekNo; | ||
} | ||
const isDisabledDate = (date: Date) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useCallback
Hi @FredLL-Avaiga,
Referencing issue #848, I’ve added the following specifications for date validation to handle date disabling options:
The rules for disabling dates include options for disabling past days or future days, weekdays, weekends, or specific day of the month with
disablePastDays
,disableFutureDays
,disableWeekdays
,disableWeekends
,dayOfWeek
.To disable alternating days:
Setting
oddInterval: True
will disable Wednesdays on the 1st, 3rd, and 5th weeksTo disable the nth occurrence of a specific weekday in the month:
Could you please review this and let me know if any modifications are needed for better handling of these specifications?