Problem/Motivation

If custom is the only allowed duration value the end time field is not visible. I have to select and deselect the all_date checkbox to make the end time field visible.

The end date field is also not visible. Also if the widget option "Hide the end date field unless it's different from the start date." is enabled. I do not get it how it works at all, so I deselected the option.

Steps to reproduce

Create a smart_date field with Recurring enabled and set to 12 month ahead.
Set default date value to current_date
Set Allowed duration value only to custom
Set default duration to 0

Proposed resolution

CommentFileSizeAuthor
#3 smart_date_default_values.png51.36 KBsunlix

Issue fork smart_date-3498221

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

sunlix created an issue. See original summary.

sunlix’s picture

I digged a little bit into it.

I think the main problem is that if custom is the only allowed value in the duration_increments you can't set custom for the default_duration. It will be casted to 0 because the config schema requires integer.

By that in the smart_date.js the setInitialDuration function hide the end date and end time field.
This hiding is intended for non custom values. But duration can't be initially set to custom due to the integer casting for default_duration

sunlix’s picture

StatusFileSize
new51.36 KB
mandclu’s picture

I don't really understand the custom behaviour here. Should the widget treat "custom" as zero (for the sake of automatically calculating the end date based on the start but then allow the user to change the end to whatever they want?

sunlix’s picture

Hey @mandclu,

thank you for your response.
Yes we are interpreting 'custom' as "The user choose what ever he want as end date/time".
In smart_date 4.1 with 'custom' no end date / time calculation was done and if 'custom' was the only value provided the 'duration' field was not displayed. This was our use case with it.

So yes, from my perspective, your interpretation is right. :-)

anybody’s picture

I'm having a similar issue, maybe the same:

Having Hide the end date field unless it's different from the start date. widget setting enabled and I create a NEW node, the node creation form only shows the start date, unless I check "All day".

So the workaround is either not using that option or checking "All day", then setting the end date and then unchecking "All day" again to have a different end date for fresh entities!

If the start date is empty, the end date should always show, I think. Otherwise, it's not even possible to select a different end date.

sunlix’s picture

Yes that is excatly our current "user workaround". :)

agoradesign’s picture

What commit exactly broke this behaviour? This is still a blocker for updating a customer website, where the editors use this field quite often.. also the configured separator is missing, as well as the end date (only the end timefield is shown upon toggling the all day checkbox)

agoradesign’s picture

Status: Active » Needs review
anybody’s picture

Thanks @agoradesign looks like this was a "simple" bug? Maybe would be worth adding a test to ensure this won't break again in the future?

agoradesign’s picture

seems so, yes :) at least it works for me.. and as you can see, after calling calcDuration() , it's totally impossible that duration === 'custom' in that line

So, it seems, that this is a classical refactoring bug, that happened here..

I agree that a test would be great, but I cannot afford the time for it unfortunately

  • mandclu committed 7cc70e4c on 4.3.x authored by agoradesign
    fix: #3498221 No end date/time field if 'custom' is the only allowed...
mandclu’s picture

Version: 4.2.1 » 4.3.x-dev
Status: Needs review » Fixed

Thanks for the work here. Merged into the 4.3.x branch

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.