Enable Week Number in the little Calendar too?

Hello!
I applied the option to display Week Number in the Calendar Module, but I wanted to know if it is possible to apply this option in the little Calendar that appears when you create new rows in modules.
Example (in the opportunities):
example calendar

hi

I made this PR that adds week numbers as an option from the UI:

But it was a long time ago and I don’t fully remember what it does… :grinning_face_with_smiling_eyes:

How did you add week numbers? By changing code?

@martaz
Look at the file include/javascript/calendar.js and add one or two lines

...
calendar = new YAHOO.widget.Calendar(showButtonElement.id + '_div', {
    iframe:false,
    hide_blank_weeks:true,
/* add line */
    show_week_header:true,
    show_week_footer:true,
/**/
    navigator:navConfig
});
...

It isn’t support upgrade.

1 Like

I changed WeekNumbers:True

I tried to add those lines in calendar.js but the calendar is not changing, even with Repair Js Files

@martaz

Have you cleared your browser cache?

Yes, I cleared it too.
Actually I’m not sure if I paste the code correctly:

@martaz

It’s not right. You should find line where is created new object YAHOO.widget.Calendar and add one or two line as parameters of the object. I wrote the lines block so you can find the right place. You should add the lines only:

show_week_header:true,
show_week_footer:true,

Okay, thanks for the explanation. Now I’m making the changes correctly, but they’re not showing anyway. Maybe I’m not “repairing” correctly, (changes are not updating correctly). Could you please tell me what type of Repair should I do?

@martaz
No. You shouldn’t do Repair. This file load directly. You should clear cache only and can check the file in your browser.

Okay, thanks for the explanation! Now the editings are showing, but there’s still a problem with the calculation:
wrong calculation
The week 1 should start from January 4th, not December.

There are options

https://fullcalendar.io/docs/weekNumberCalculation

although I am not sure about how they should be used to get what you want…

I found this documentation for the calendar:
https://yui.github.io/yui2/docs/yui_2.5.0/docs/YAHOO.widget.Calendar.html
I had to set START_WEEKDAY to 1 (Monday), but I also need to change the week number calculation, from default to ISO, but I’m not finding any variable that is implicated in this calculation

I think we use FullCalendar, not that YUI (unless for some reason they are the same), and the correct Docs site is the one I linked in my post above. Have you tried that setting?

In the javascript code for the little calendar to create the Calendar object you used the class: calendar=new YAHOO.widget.Calendar (…)
That’s why I searched for it and tried to find the variables to change, that are:
first day of the week (monday), already changed
calculation (ISO), don’t know how to change it in the code
I actually don’t know exactly how the week numbers are calculated in that code, but of course it is set to default (Local), but I wanted ISO

In the same place where you specified option show_week_header etc, try adding

weekNumberCalculation : “ISO”

I already tried, but it didn’t work. probably it’s another variable

I solved the problem! I’m going to write here the solution:
In the standard calcuation (USA-local) “0” is the first day of the week (sunday), and the week 1 starts from January 1st
In the ISO calculation the week starts from January 4th
So you have to change the value of two variables in these files for the correct calculation:

cache\include\javascript\sugar_grp1_yui.js
cache\include\javascript\sugar_grp_yui_widgets.js
include\javascript\yui\build\calendar\calendar.js
include\javascript\yui\build\calendar\calendar-min.js
include\javascript\yui\build\datemath\datemath.js
include\javascript\yui\build\datemath\datemath-min.js

firstDayOfWeek = firstDayOfWeek || 0 ----> firstDayOfWeek = firstDayOfWeek || 1
WEEK_ONE_JAN_DATE : 1 ----> WEEK_ONE_JAN_DATE : 4

Then the Week Calculation is correct (for ISO)
Good afternoon !

:+1: nice!

note that the content of calendar.js is likely coming from this file:

jssource/src_files/include/javascript/calendar.js

… and then it’s compiled into the other files from the JS rebuilds in Admin / Repairs. So don’t be surprised if you find that repairs break your customization.

Strangely, the other file datemath.js doesn’t seem to be coming from jssource.

Also the min files are auto-generated in the Minify JS repair.

1 Like

Yes, I forgot to tell that you don’t have to do repair with JS, but you have to clear the cache. These are unsafe changes, but at least they’re working. :slightly_smiling_face: