-
Notifications
You must be signed in to change notification settings - Fork 510
Add the ability to disable arbitrary date picker and calendar dates #6905
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
Conversation
39504bd to
a648d88
Compare
a648d88 to
fc57274
Compare
|
While disabling works (I tested it in room booking), it doesn't actually display the disabled dates as inactive (w/ your example code that disables weekends). |
Sorry, missed your comment. I'll check and adjust. |
|
@ThiefMaster Can you tell me more about what you tried? I've manually overridden the filter prop like so: diff --git a/indico/web/client/js/react/components/DatePicker.jsx b/indico/web/client/js/react/components/DatePicker.jsx
index 836378c241..dd4e95b111 100644
--- a/indico/web/client/js/react/components/DatePicker.jsx
+++ b/indico/web/client/js/react/components/DatePicker.jsx
@@ -37,6 +37,10 @@ export default function DatePicker({
const formattedValue = formatDate(format, fromISOLocalDate(value));
+ filter = (d, meta) => {
+ return !meta.weekInfo.weekend.includes(d.getDay() || 7);
+ };
+
return (
<ind-date-picker
min={fromISOLocalDate(min)?.toDateString()}With this patch, I get the intended result: |
|
This is what I Tested with (in room booking) diff --git a/indico/modules/rb/client/js/components/BookingBootstrapForm.jsx b/indico/modules/rb/client/js/components/BookingBootstrapForm.jsx
index da5f9ca2fe..e2d3ff162a 100644
--- a/indico/modules/rb/client/js/components/BookingBootstrapForm.jsx
+++ b/indico/modules/rb/client/js/components/BookingBootstrapForm.jsx
@@ -381,6 +381,7 @@ class BookingBootstrapForm extends React.Component {
<Form.Group inline>
<DateRangePicker
min={getBookingRangeMinDate(isAdminOverrideEnabled, bookingGracePeriod)}
+ filter={(d, meta) => !meta.weekInfo.weekend.includes(d.getDay() || 7)}
value={{startDate: serializeDate(startDate), endDate: serializeDate(endDate)}}
onChange={({startDate: sd, endDate: ed}) =>
this.updateDates(toMoment(sd), toMoment(ed))
@@ -392,6 +393,7 @@ class BookingBootstrapForm extends React.Component {
<Form.Group inline>
<DatePicker
min={getBookingRangeMinDate(isAdminOverrideEnabled, bookingGracePeriod)}
+ filter={(d, meta) => !meta.weekInfo.weekend.includes(d.getDay() || 7)}
value={serializeDate(startDate)}
invalidValue={null}
onChange={date => this.updateDates(toMoment(date), null)} |
fc57274 to
2aa9cae
Compare
|
Turns out even I forgot the subtle nuances of disabling dates. 😂 Had to use aria-disabled instead of disabled cause the buttons still need to be reachable by keyboard. Anyway, this should fix it across the board now. |
2aa9cae to
2ae37eb
Compare

No description provided.