? ? Success

User tests: Successful: Unsuccessful:

avatar drewgg
drewgg
19 Jul 2017

Pull Request for Issue #17171 .

Summary of Changes

Removed a conditional that prevented dates to be updated manually (via input field) after the date is changed via the calendar tool.

Testing Instructions

  1. Open an article (new or existing)
  2. Change the "Start Publishing" date/time via the calendar tool (call this DATE 1)
  3. Change the "Start Publishing" date/time manually (via typing in the text field) (call this DATE 2)
  4. Save the article (or open the calendar tool again)

Expected result

DATE 2 should be saved

Actual result

DATE 1 is saved

Documentation Changes Required

Might need @farhadst to test the Jallali calendar

(this is my first attempt to contribute code changes so please let me know if I'm doing it incorrectly)

avatar drewgg drewgg - open - 19 Jul 2017
avatar drewgg drewgg - change - 19 Jul 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 19 Jul 2017
Category JavaScript
avatar drewgg drewgg - change - 19 Jul 2017
The description was changed
avatar drewgg drewgg - edited - 19 Jul 2017
avatar drewgg drewgg - change - 19 Jul 2017
The description was changed
avatar drewgg drewgg - edited - 19 Jul 2017
avatar brianteeman
brianteeman - comment - 19 Jul 2017

You can use any minify tool. There is no preference for j3

avatar infograf768
infograf768 - comment - 20 Jul 2017

@dgt41
Please check

avatar dgt41
dgt41 - comment - 20 Jul 2017

@infograf768 @drewgg you are removing a check if (typeof calObj.dateClicked === 'undefined') {
IIRC I put that so we can distinguish the 2 different inputs (typed or GUI). have you checked if this
if (typeof calObj.params.dateClicked === 'undefined') { works? (it seems wrong that this param is mot under the params object...

avatar drewgg
drewgg - comment - 20 Jul 2017

@dgt41 That conditional works as expected before the first time the date/time is changed via the tool but once the tool is used to affect the date/time then calObj.dateClicked will be either true or false but never again undefined (until the page is reloaded).

When I modified to to also check for truthiness as well (if (typeof calObj.dateClicked === 'undefined' || calObj.dateClicked === false) {) it corrected the issue in most cases. However, it would still break when clicking the "today" button (which sets calObj.dateClicked to true when clicked). It looked like the issue only happened when the conditional returned false (when calObj.dateClicked is true).

More precisely, the issue happens when data-local-value isn't being set. The truthy path set's both data-local-value and data-alt-value. The falsey path only sets data-alt-value. That seems to be the core issue. My original patch was to set the data-local-value in the falsey path:

	} else {
		calObj.inputField.setAttribute('data-local-value', Date.parseFieldDate(calObj.inputField.value, calObj.params.dateFormat, calObj.params.dateType)
 		.print(calObj.params.dateFormat, 'gregorian', false));
		calObj.inputField.setAttribute('data-alt-value', Date.parseFieldDate(calObj.inputField.value, calObj.params.dateFormat, calObj.params.dateType)
		.print(calObj.params.dateFormat, 'gregorian', false));
  	}

This seems to fix the issue, but at that point I couldn't see the benefit of the falsey path vs the truthy one. Both are nearly equivalent in what they are doing (setting data-local-value and data-alt-value) other than the truthy path seems to have better data/formatting checks. That's what led me to just remove the conditional and falsey path.

edit Oh, my apologies. I just realized in your question about whether I had tested that conditional you had changed it from calObj.dateClicked to calObj.params.dateClicked. No, I had not tested that. Let me do that now.

avatar dgt41
dgt41 - comment - 20 Jul 2017

@drewgg data-local-value is available only in non gregorian calendars, data-alt-value is always the value that will be sent upon form submit, hope this helps

avatar drewgg
drewgg - comment - 20 Jul 2017

@dgt41 Changing the conditional to calObj.params.dateClicked resolves the issues for me. I've update the code. Thank you!

avatar drewgg
drewgg - comment - 20 Jul 2017

Do I need to do anything do fix that "continuous-integration/drone/pr" build failure?

avatar dgt41
dgt41 - comment - 20 Jul 2017

@drewgg don't worry the fail is not related to the code here. But you need to update the minified file as well as @brianteeman mentioned above

avatar drewgg
drewgg - comment - 20 Jul 2017

@dgt41 done. Thanks!

avatar infograf768
infograf768 - comment - 22 Jul 2017

Test with Gregorian calendar works fine.

avatar farhadst
farhadst - comment - 22 Jul 2017

@drewgg @infograf768
I replace the calendar.js and calendar.min.js
This work for persian calendar:
Open an article (new or existing)
Change the "Start Publishing" date/time via the calendar tool
Change the "Start Publishing" date/time manually (via typing in the text field)
Save the article
Date saved is via manually

but problem for persian calendar in set manually date (in some months, one day will be added or one day will be reduced) not fix

avatar infograf768
infograf768 - comment - 24 Jul 2017

@drewgg
Please add this modified code proposed by @dgt41 #17150 (comment)

and update also the minified version.
This would solve both Jalali calendar and this popup followed by field edit.

avatar drewgg
drewgg - comment - 24 Jul 2017

@infograf768 Considering #17150 (comment), do you still want me to apply those edits? Or hold off until there is resolution?

avatar infograf768
infograf768 - comment - 24 Jul 2017

Let's wait a bit indeed.

avatar franz-wohlkoenig franz-wohlkoenig - test_item - 28 Jul 2017 - Tested successfully
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 28 Jul 2017

I have tested this item successfully on 8b3da70


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17183.

avatar infograf768 infograf768 - test_item - 28 Jul 2017 - Tested successfully
avatar infograf768
infograf768 - comment - 28 Jul 2017

I have tested this item successfully on 8b3da70

I guess we should separate this issue from the Jalali calendar issue and set this as RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17183.

avatar infograf768 infograf768 - change - 28 Jul 2017
Status Pending Ready to Commit
avatar infograf768
infograf768 - comment - 28 Jul 2017

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17183.

avatar mbabker mbabker - change - 31 Jul 2017
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-07-31 11:44:12
Closed_By mbabker
Labels Added: ?
avatar mbabker mbabker - close - 31 Jul 2017
avatar mbabker mbabker - merge - 31 Jul 2017

Add a Comment

Login with GitHub to post a comment