joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.76k stars 3.64k forks source link

Calendar field bug with param maxyear #19926

Closed thomaslanger closed 5 years ago

thomaslanger commented 6 years ago

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

thomaslanger commented 6 years ago

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.

dgrammatiko commented 6 years ago

is max year bigger than min year?

thomaslanger commented 6 years ago

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.

thomaslanger commented 6 years ago

<field name="birthday" type="calendar" label="BIRTHDAY_LABEL" maxyear="-16" />


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

thomaslanger commented 6 years ago

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.

thomaslanger commented 6 years ago

screen shot 2018-03-23 at 14 42 38


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

thomaslanger commented 6 years ago

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.

brianteeman commented 6 years ago

I can reproduce this

pinta83 commented 5 years ago

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.

pinta83 commented 5 years ago

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.

pinta83 commented 5 years ago

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.

ghost commented 5 years ago

@dgrammatiko comment as js-guru?

dgrammatiko commented 5 years ago

Seems reasonable

ghost commented 5 years ago

@pinta83 can you do a Pull Request?

pinta83 commented 5 years ago

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

ghost commented 5 years ago

Closed as having Pull Request #26119