Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendar field bug with param maxyear #19926

Closed
thomaslanger opened this issue Mar 16, 2018 · 16 comments
Closed

Calendar field bug with param maxyear #19926

thomaslanger opened this issue Mar 16, 2018 · 16 comments

Comments

@thomaslanger
Copy link

thomaslanger commented Mar 16, 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

@thomaslanger
Copy link
Author

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
Copy link
Contributor

is max year bigger than min year?

@thomaslanger
Copy link
Author

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
Copy link
Author


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

@thomaslanger
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Contributor

I can reproduce this

@pinta83
Copy link
Contributor

pinta83 commented Sep 1, 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.

@pinta83
Copy link
Contributor

pinta83 commented Sep 1, 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.

@pinta83
Copy link
Contributor

pinta83 commented Sep 1, 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.

@ghost
Copy link

ghost commented Sep 1, 2019

@dgrammatiko comment as js-guru?

@dgrammatiko
Copy link
Contributor

Seems reasonable

@ghost
Copy link

ghost commented Sep 1, 2019

@pinta83 can you do a Pull Request?

@pinta83
Copy link
Contributor

pinta83 commented Sep 1, 2019

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

pinta83 added a commit to pinta83/joomla-cms that referenced this issue Sep 1, 2019
/media/system/js/fields/calendar.js at lines 861 and 864 call
date.getOtherFullYear(this.params.dateType, year);

But this function defined in
/media/system/js/fields/calendar-locales/date/jalali/date-helper.js
does not have a second parameter - year, so it can not be changed...

Here's a fix for this issue...

Fixes issue: joomla#19926
@ghost
Copy link

ghost commented Sep 1, 2019

Closed as having Pull Request #26119

@ghost ghost closed this as completed Sep 1, 2019
HLeithner pushed a commit that referenced this issue Sep 17, 2019
/media/system/js/fields/calendar.js at lines 861 and 864 call
date.getOtherFullYear(this.params.dateType, year);

But this function defined in
/media/system/js/fields/calendar-locales/date/jalali/date-helper.js
does not have a second parameter - year, so it can not be changed...

Here's a fix for this issue...

Fixes issue: #19926
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants