Fullcalendar lib updated to latest version, fixed js calls

- Removed custom view (new view api added in latest fullcalendar code)
pull/2650/head
Julio Montoya 6 years ago
parent 6496bbfe7b
commit 70f80d0769
  1. 5
      assets/js/vendor.js
  2. 5
      main/calendar/agenda_js.php
  3. 156
      main/template/default/agenda/month.html.twig
  4. 2
      package.json
  5. 18
      yarn.lock

@ -31,6 +31,11 @@ require('bootstrap-select/dist/css/bootstrap-select.css');
require('flag-icon-css/css/flag-icon.css'); require('flag-icon-css/css/flag-icon.css');
require("bootstrap-daterangepicker"); require("bootstrap-daterangepicker");
require("bootstrap-daterangepicker/daterangepicker.scss"); require("bootstrap-daterangepicker/daterangepicker.scss");
require("fullcalendar/dist/fullcalendar.js");
require("fullcalendar/dist/fullcalendar.css");
require("fullcalendar/dist/gcal.js");
require("fullcalendar/dist/locale-all.js");
//require("readmore-js"); //require("readmore-js");
// doesn't work with webpack added directly in /public/libs folder // doesn't work with webpack added directly in /public/libs folder

@ -20,10 +20,10 @@ require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_CALENDAR_EVENT; $current_course_tool = TOOL_CALENDAR_EVENT;
$this_section = SECTION_MYAGENDA; $this_section = SECTION_MYAGENDA;
$htmlHeadXtra[] = api_get_asset('fullcalendar/dist/fullcalendar.js'); /*$htmlHeadXtra[] = api_get_asset('fullcalendar/dist/fullcalendar.js');
$htmlHeadXtra[] = api_get_asset('fullcalendar/dist/locale-all.js'); $htmlHeadXtra[] = api_get_asset('fullcalendar/dist/locale-all.js');
$htmlHeadXtra[] = api_get_asset('fullcalendar/dist/gcal.js'); $htmlHeadXtra[] = api_get_asset('fullcalendar/dist/gcal.js');
$htmlHeadXtra[] = api_get_css_asset('fullcalendar/dist/fullcalendar.min.css'); $htmlHeadXtra[] = api_get_css_asset('fullcalendar/dist/fullcalendar.min.css');*/
if (api_is_platform_admin() && ($type == 'admin' || $type == 'platform')) { if (api_is_platform_admin() && ($type == 'admin' || $type == 'platform')) {
$type = 'admin'; $type = 'admin';
@ -165,7 +165,6 @@ if ($type == 'course' && !empty($group_id)) {
} }
$defaultView = api_get_setting('default_calendar_view'); $defaultView = api_get_setting('default_calendar_view');
if (empty($defaultView)) { if (empty($defaultView)) {
$defaultView = 'month'; $defaultView = 'month';
} }

@ -68,162 +68,16 @@ $(document).ready(function() {
} }
}); });
var CustomListViewGrid = ListViewGrid.extend({ var calendar = $('#calendar').fullCalendar({
fgSegHtml: function(seg) {
var view = this.view;
var classes = [ 'fc-list-item' ].concat(this.getSegCustomClasses(seg));
var bgColor = this.getSegBackgroundColor(seg);
var event = seg.event;
var url = event.url;
var timeHtml;
if (event.allDay) {
timeHtml = view.getAllDayHtml();
}
else if (view.isMultiDayEvent(event)) { // if the event appears to span more than one day
if (seg.isStart || seg.isEnd) { // outer segment that probably lasts part of the day
timeHtml = htmlEscape(this.getEventTimeText(seg));
}
else { // inner segment that lasts the whole day
timeHtml = view.getAllDayHtml();
}
}
else {
// Display the normal time text for the *event's* times
timeHtml = htmlEscape(this.getEventTimeText(event));
}
if (url) {
classes.push('fc-has-url');
}
return '<tr class="' + classes.join(' ') + '">' +
(this.displayEventTime ?
'<td class="fc-list-item-time ' + view.widgetContentClass + '">' +
(timeHtml || '') +
'</td>' :
'') +
'<td class="fc-list-item-marker ' + view.widgetContentClass + '">' +
'<span class="fc-event-dot"' +
(bgColor ?
' style="background-color:' + bgColor + '"' :
'') +
'></span>' +
'</td>' +
'<td class="fc-list-item-title ' + view.widgetContentClass + '">' +
'<a' + (url ? ' href="' + htmlEscape(url) + '"' : '') + '>' +
htmlEscape(seg.event.title || '') + (seg.event.description || '')
'</a>' +
'</td>' +
'</tr>';
},
// render the event segments in the view
renderSegList: function(allSegs) {
var segsByDay = this.groupSegsByDay(allSegs); // sparse array
var dayIndex;
var daySegs;
var i;
var tableEl = $('<table class="fc-list-table"><tbody/></table>');
var tbodyEl = tableEl.find('tbody');
var eventList = new Array;
for (dayIndex = 0; dayIndex < segsByDay.length; dayIndex++) {
daySegs = segsByDay[dayIndex];
if (daySegs) { // sparse array, so might be undefined
this.sortEventSegs(daySegs);
for (i = 0; i < daySegs.length; i++) {
var event = daySegs[i].event;
if (jQuery.inArray(event.id, eventList) !== -1) {
continue;
}
eventList.push(event.id);
// append a day header
tbodyEl.append(this.dayHeaderHtml(
this.view.start.clone().add(dayIndex, 'days'),
event
));
tbodyEl.append(daySegs[i].el); // append event row
}
}
}
this.el.empty().append(tableEl);
},
// generates the HTML for the day headers that live amongst the event rows
dayHeaderHtml: function(dayDate, event) {
var view = this.view;
var mainFormat = 'LL';
var altFormat = 'dddd';
var checkIfSame = true;
if (event.end) {
checkIfSame = event.end.format(mainFormat) == dayDate.format(mainFormat);
}
return '<tr class="fc-list-heading" data-date="' + dayDate.format('YYYY-MM-DD') + '">' +
'<td class="' + view.widgetHeaderClass + '" colspan="3">' +
(mainFormat ?
view.buildGotoAnchorHtml(
dayDate,
{ 'class': 'fc-list-heading-main' },
htmlEscape(dayDate.format(mainFormat)) // inner HTML
) :
'') +
((checkIfSame == false && mainFormat) ?
view.buildGotoAnchorHtml(
dayDate,
{ 'class': 'fc-list-heading-main' },
'&nbsp;-&nbsp; ' + htmlEscape(event.end.format(mainFormat)) // inner HTML
) :
'') +
(altFormat ?
view.buildGotoAnchorHtml(
dayDate,
{ 'class': 'fc-list-heading-alt' },
htmlEscape(dayDate.format(altFormat)) // inner HTML
) :
'') +
'</td>' +
'</tr>';
},
});
var FC = $.fullCalendar; // a reference to FullCalendar's root namespace
var View = ListView; // the class that all views must inherit from
var CustomView; // our subclass
CustomView = View.extend({ // make a subclass of View
initialize: function() {
this.grid = new CustomListViewGrid(this);
this.scroller = new Scroller({
overflowX: 'hidden',
overflowY: 'auto'
});
}
});
FC.views.CustomView = CustomView; // register our class with the view system
var calendar = $('#calendar').fullCalendar({
header: { header: {
left: 'today,prev,next', left: 'today,prev,next',
center: 'title', center: 'title',
right: 'month,agendaWeek,agendaDay,CustomView' right: 'month,agendaWeek,agendaDay,listDay,listWeek,listMonth'
}, },
views: { views: {
CustomView: { // name of view listDay: { buttonText: 'list day' },
type: 'list', listWeek: { buttonText: 'list week' },
buttonText: '{{ 'AgendaList' | get_lang | escape('js') }}', listMonth: { buttonText: 'list month' },
duration: { month: 1 },
defaults: {
'listDayAltFormat': 'dddd' // day-of-week is nice-to-have
}
},
month: {
'displayEventEnd' : true
}
}, },
locale: region_value, locale: region_value,
{% if use_google_calendar == 1 %} {% if use_google_calendar == 1 %}

@ -22,7 +22,7 @@
"cropper": "^4.0", "cropper": "^4.0",
"flag-icon-css": "^3.0", "flag-icon-css": "^3.0",
"fs": "0.0.1-security", "fs": "0.0.1-security",
"fullcalendar": "3.1.0", "fullcalendar": "^3.0",
"highlight.js": "^9.12.0", "highlight.js": "^9.12.0",
"image-map-resizer": "^1.0.7", "image-map-resizer": "^1.0.7",
"jquery": "^3.3.1", "jquery": "^3.3.1",

@ -2636,12 +2636,12 @@ fstream@^1.0.0, fstream@^1.0.2:
mkdirp ">=0.5 0" mkdirp ">=0.5 0"
rimraf "2" rimraf "2"
fullcalendar@3.1.0: fullcalendar@^3.0:
version "3.1.0" version "3.9.0"
resolved "https://registry.yarnpkg.com/fullcalendar/-/fullcalendar-3.1.0.tgz#c81286ce00876294b2d3dba2d811ee33a8843917" resolved "https://registry.yarnpkg.com/fullcalendar/-/fullcalendar-3.9.0.tgz#b608a9989f3416f0b1d526c6bdfeeaf2ac79eda5"
dependencies: dependencies:
jquery ">=2.0.0" jquery "2 - 3"
moment ">=2.9.0" moment "^2.20.1"
function-bind@^1.0.2, function-bind@^1.1.1: function-bind@^1.0.2, function-bind@^1.1.1:
version "1.1.1" version "1.1.1"
@ -3461,7 +3461,7 @@ jquery.scrollbar@^0.2.11:
version "0.2.11" version "0.2.11"
resolved "https://registry.yarnpkg.com/jquery.scrollbar/-/jquery.scrollbar-0.2.11.tgz#e91bd4a97d83859463024d26e730dc36676ab59d" resolved "https://registry.yarnpkg.com/jquery.scrollbar/-/jquery.scrollbar-0.2.11.tgz#e91bd4a97d83859463024d26e730dc36676ab59d"
jquery@>=1.10, jquery@>=1.2.3, jquery@>=1.6.0, jquery@>=1.7, jquery@>=2.0.0, jquery@^3.2.1, jquery@^3.3.1: "jquery@2 - 3", jquery@>=1.10, jquery@>=1.2.3, jquery@>=1.6.0, jquery@>=1.7, jquery@^3.2.1, jquery@^3.3.1:
version "3.3.1" version "3.3.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca" resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca"
@ -4034,7 +4034,11 @@ mockconsole@0.0.1, mockconsole@0.0.x:
version "0.0.1" version "0.0.1"
resolved "https://registry.yarnpkg.com/mockconsole/-/mockconsole-0.0.1.tgz#d62a7ed85530964abcd24edb9f30fa58bbce56c6" resolved "https://registry.yarnpkg.com/mockconsole/-/mockconsole-0.0.1.tgz#d62a7ed85530964abcd24edb9f30fa58bbce56c6"
moment@>=2.9.0, moment@^2.22, moment@^2.9.0: moment@^2.20.1:
version "2.22.2"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66"
moment@^2.22, moment@^2.9.0:
version "2.22.1" version "2.22.1"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.1.tgz#529a2e9bf973f259c9643d237fda84de3a26e8ad" resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.1.tgz#529a2e9bf973f259c9643d237fda84de3a26e8ad"

Loading…
Cancel
Save