igniteui-angular icon indicating copy to clipboard operation
igniteui-angular copied to clipboard

Calendar flexibility in selecting specialDates/disabledDates

Open hanastasov opened this issue 3 years ago • 7 comments

Question

The DateRangeDescriptor class provides means to configure dates selection in following ways:

  1. BETWEEN two dates
  2. AFTER a date
  3. BEFORE a date
  4. SPECIFIC dates
  5. All WEEKENDS
  6. All WEEKDAYS

Why not being able to specify the following as well:

  1. All weekends BETWEEN two dates
  2. All weekdays BEETWEEN two dates

The above seems to require no API changes and only implementation changes to respect the range provided:

    this.calendar.disabledDates = [
      { type: DateRangeType.Weekends, dateRange: range },
    ];
    this.calendar.specialDates= [
      { type: DateRangeType.Weekdays, dateRange: range },
    ];
  1. All weekends/weekdays AFTER a date
  2. All weekends/weekdays BEFORE a date

Those two seem to require API changes, maybe passing a second type constraint:

    this.calendar.specialDates= [
      { type: DateRangeType.Weekdays, dateRange: singleDate, secondConstraint: DateRangeType.After },
    ];

but seems to bring complexity that is not worth to handle I think.

hanastasov avatar Jun 01 '22 14:06 hanastasov

So are you suggesting we introduce new enumeration for all the cases you've listed? In total that would be 6 new entries. Another approach would be to introduce a second parameter to the WEEKENDS and WEEKDAYS members to specify the constraint.

kdinev avatar Jun 02 '22 06:06 kdinev

Another approach would be to introduce a second parameter to the WEEKENDS and WEEKDAYS members to specify the constraint.

That's what I though too. The second constraint can be passed even now and is ignored, if type is WEEKENDS or WEEKDAYS. It seems a dev continue to do what is doing now:

    this.calendar.disabledDates = [
      { type: DateRangeType.Weekends, dateRange: range },
    ];
    this.calendar.specialDates= [
      { type: DateRangeType.Weekdays, dateRange: range },
    ];

and no changes in the API are needed, just implementation changes.

hanastasov avatar Jun 02 '22 06:06 hanastasov

Extending the enum would be cleaner in terms of usage in the component after. Second parameter would mean passing another DateRangeDescriptor inside, but then using only BEFORE, AFTER and BETWEEN from it. We can't disallow passing the rest. You will have then cases inside the WEEKEND and WEEKDAY cases, which will bloat the code IMO.

kdinev avatar Jun 02 '22 06:06 kdinev

Extending the enum would be cleaner in terms of usage in the component after

That would mean to add two new enums to the already available, to serve for the last cases suggested - weekends/weekdays AFTER/BEFORE a date, right?

hanastasov avatar Jun 02 '22 06:06 hanastasov

There has been no recent activity and this issue has been marked inactive.

github-actions[bot] avatar Aug 02 '22 00:08 github-actions[bot]

@hanastasov This never reached development, or did we not associate it with the issue?

kdinev avatar Aug 09 '22 08:08 kdinev

Never reached development, that's why there is also no PR associated.

hanastasov avatar Aug 10 '22 09:08 hanastasov