J3 Issue ?
avatar thomaslanger
thomaslanger
16 Mar 2018

Steps to reproduce the issue

Add a calendar field to a form with param maxyear="-18" to set the highest year in caleandar to year 2000
In Browser click on the calendat button to choose a day

Expected result

If i click on a day in the calendar, the selected date should shown in the input field.

Actual result

After selected a date, year 2000 is shown, you get a date with current year.

Try to choose a date in year 1999. Year 2000 is shown but you hav to cklick 19 times to set the year to 1999.

The Callendar JS seems to work not with the year given by "current year" and maxyear. It works calculates only with "current year".

System information (as much as possible)

Joomla 3.8.6

avatar thomaslanger thomaslanger - open - 16 Mar 2018
avatar joomla-cms-bot joomla-cms-bot - labeled - 16 Mar 2018
avatar thomaslanger
thomaslanger - comment - 16 Mar 2018

The data-attributs in the html-Code are ok. the bug must bee in the calendar.js


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

avatar franz-wohlkoenig franz-wohlkoenig - change - 16 Mar 2018
Category Fields Fields JavaScript
avatar dgt41
dgt41 - comment - 16 Mar 2018

is max year bigger than min year?

avatar franz-wohlkoenig franz-wohlkoenig - change - 17 Mar 2018
Status New Information Required
avatar thomaslanger
thomaslanger - comment - 19 Mar 2018

minyear is not specified because i don't need a min year, only a max year older then the current. In the joomla documentation it is a optional value.


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

avatar thomaslanger
thomaslanger - comment - 23 Mar 2018
avatar thomaslanger
thomaslanger - comment - 23 Mar 2018

name="birthday"
type="calendar"
label="COM_FNETCM_BIRTHDAY_LABEL"
maxyear="-16"


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19926.
avatar thomaslanger
thomaslanger - comment - 23 Mar 2018
avatar brianteeman brianteeman - labeled - 25 Mar 2018
avatar thomaslanger
thomaslanger - comment - 3 Apr 2018

More info required? Which? Could someone reproduce the bug?


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

avatar brianteeman
brianteeman - comment - 5 Apr 2018

I can reproduce this

avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Apr 2018
Status Information Required Confirmed
avatar joomla-cms-bot joomla-cms-bot - unlabeled - 5 Apr 2018
avatar brianteeman brianteeman - change - 28 Aug 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 28 Aug 2018
avatar pinta83
pinta83 - comment - 1 Sep 2019

I have the same issue....

My maxdate is set to "-7", and when i click the date picker it only shows the currentyear -7 in the header... The actuall caledar is rendered for the current month, and I have to click the left nav arrow 7 time before i even get to the year, and then it finaly starts to change.


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

avatar pinta83
pinta83 - comment - 1 Sep 2019

And to go even further... I can click the dates (in current month) and the date will be set regardless of maxyear being set


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

avatar pinta83
pinta83 - comment - 1 Sep 2019

Found and solved the problem....

If you take a look at /media/system/js/fields/calendar.js at lines 863-869 you can see the date.getOtherFullYear(this.params.dateType, year) call with a second parameter being a year.

Now if you take a look at the getOtherFullYear() function defined in /media/system/js/fields/calendar-locales/date/jalali/date-helper.js you will see that the function excepts only 1 paramterer...

/** Returns the year for the current date. /
Date.prototype.getOtherFullYear = function (dateType) {
if (dateType != 'gregorian') {
/
* Modify to match the current calendar when overriding **/
return this.getJalaliFullYear();
} else {
return this.getFullYear();
}
};


Fix

  1. Open up /media/system/js/fields/calendar.js
  2. replace "date.getOtherFullYear(this.params.dateType, year);" with "date.setYear(year);" on lines 865 and 858
  3. Done, everything works now :)

The bugfix covers minyear bug aswell, since both are handled on the same place..


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19926.
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 1 Sep 2019

@dgrammatiko comment as js-guru?

avatar dgrammatiko
dgrammatiko - comment - 1 Sep 2019

Seems reasonable

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 1 Sep 2019

@pinta83 can you do a Pull Request?

avatar pinta83
pinta83 - comment - 1 Sep 2019

Will do it today if I catch the time, if not - tommorow morrning ;)

avatar franz-wohlkoenig franz-wohlkoenig - change - 1 Sep 2019
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2019-09-01 12:42:23
Closed_By franz-wohlkoenig
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 1 Sep 2019

Closed as having Pull Request #26119

avatar franz-wohlkoenig franz-wohlkoenig - close - 1 Sep 2019

Add a Comment

Login with GitHub to post a comment