From cab5361a385c059e5df3cf046c767a10e0ded9e1 Mon Sep 17 00:00:00 2001 From: Keith Banner Date: Tue, 10 Sep 2024 09:20:16 -0600 Subject: [PATCH] Clarified documentation on restrictions and how they interact. --- src/docs/partials/namespace/errors.html | 6 +-- src/docs/partials/options/restrictions.html | 46 ++++++++++++++------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/docs/partials/namespace/errors.html b/src/docs/partials/namespace/errors.html index caf37db3f..ca649d508 100644 --- a/src/docs/partials/namespace/errors.html +++ b/src/docs/partials/namespace/errors.html @@ -49,8 +49,8 @@

unexpectedOptionValue (code: 2) -

numbersOutOfRage (code: 4)

numbersOutOfRange (code: 4)

An error when an option value is outside of the expected range. @@ -137,7 +137,7 @@

failedToParseInputUnexpectedOptions
  • UnexpectedOptionValue
  • TypeMismatch
  • -
  • NumbersOutOfRage
  • +
  • numbersOutOfRange
  • FailedToParseDate
  • MustProvideElement
  • SubscribeMismatch
  • diff --git a/src/docs/partials/options/restrictions.html b/src/docs/partials/options/restrictions.html index ac6085bd4..503e9d1ae 100644 --- a/src/docs/partials/options/restrictions.html +++ b/src/docs/partials/options/restrictions.html @@ -3,6 +3,12 @@ Restrictions allow you to prevent users from selected dates or times based on a set of rules.

    +  
    + In general, when using these options, each date in the calendar is evaluated against all configuration options that have been set. +
    + Dates will only be enabled if they are valid for all criteria. If any one of the options would disable a date (or time), it will be disabled. + This means that if you use enabledDates, the dates in that array can still be disabled if some other setting such as minDate, maxDate, or daysOfWeekDisabled would disable those dates. +
    new tempusDominus.TempusDominus(document.getElementById('datetimepicker1'), { restrictions: { @@ -18,7 +24,6 @@ } )
    -

    minDate enabledDates/disabledDates
    Accepts: array of string | Date | DateTime Defaults: undefined
    - Use one or the other, don't provide both enabledDates and disabledDates. + If enabledDates and disabledDates are used at the same time, the only dates that will be available in the calendar + are the enabledDates that are also not in the disabledDates option and are otherwise valid. + They are not intended to be used together. Use either enabledDates or disabledDates.

    enabledDates

    - Allows the user to select only from the provided days. Setting this takes precedence - over + Allows the user to select only from the provided days. If combined with options.minDate, - options.maxDate configuration. + options.maxDate, + or daysOfWeekDisabled + only dates that are within the min and max date range, AND not in daysOfWeekDisabled, AND in the enabledDates range will be considered valid.

    disabledDates

    - Disallows the user to select any of the provided days. Setting this takes precedence - over - options.minDate, - options.maxDate configuration. + Prohibits the user from selecting any of the provided days. If combined with + options.minDate or + options.maxDate, + any date that is in this array or that is before the minDate, or after the maxDate, will be invalid.

    @@ -92,12 +100,15 @@

    enabledHours/disabledHours class='fa-solid fa-anchor' aria-hidden='true'>

    - Accepts: array of number from 0-24 Defaults: undefined
    + Accepts: array of number from 0-23 Defaults: undefined
    Use one or the other, don't provide both enabledHours and disabledHours. + If enabledHours and disabledHours are used at the same time, the only hours that will be available in the calendar + are the enabledHours that are also not in the disabledHour option and are otherwise valid. + They are not intended to be used together. Use either enabledHours or disabledHours.

    - Throws numbersOutOfRage any value is + Throws numbersOutOfRange any value is not between 0-23

    @@ -109,7 +120,7 @@

    enabledHours

    disabledHours

    - Disallows the user to select any of the provided hours. + Prohibits the user from selecting any of the provided hours.

    @@ -147,12 +158,15 @@

    daysOfWeekDisabled

    Accepts: array of numbers from 0-6
    - Disallow the user to select weekdays that exist in this array. This has lower priority over the - options.minDate, options.maxDate, options.disabledDates and options.enabledDates configuration - settings. + Prohibits the user from selecting weekdays that exist in this array. + When combined with the + options.minDate, options.maxDate, and options.disabledDates configuration + settings, any date that is not valid for any of those options or this one will be prohibiited. + For a date to be allowed it must be valid based on all criteria. + If combined with options.enabled, only dates that are enabled AND a valid day of the week will be enabled.

    - Throws numbersOutOfRage any value is not + Throws numbersOutOfRange any value is not between 0-6.