From 70f80d076923f0f23aa1f30a96bf93f56a5a9a24 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 29 Aug 2018 13:00:12 +0200 Subject: [PATCH] Fullcalendar lib updated to latest version, fixed js calls - Removed custom view (new view api added in latest fullcalendar code) --- assets/js/vendor.js | 5 + main/calendar/agenda_js.php | 5 +- main/template/default/agenda/month.html.twig | 156 +------------------ package.json | 2 +- yarn.lock | 18 ++- 5 files changed, 24 insertions(+), 162 deletions(-) diff --git a/assets/js/vendor.js b/assets/js/vendor.js index ef5a95a4ed..a36e7b3def 100644 --- a/assets/js/vendor.js +++ b/assets/js/vendor.js @@ -31,6 +31,11 @@ require('bootstrap-select/dist/css/bootstrap-select.css'); require('flag-icon-css/css/flag-icon.css'); require("bootstrap-daterangepicker"); 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"); // doesn't work with webpack added directly in /public/libs folder diff --git a/main/calendar/agenda_js.php b/main/calendar/agenda_js.php index 0f1007cf67..16a93a3fe6 100755 --- a/main/calendar/agenda_js.php +++ b/main/calendar/agenda_js.php @@ -20,10 +20,10 @@ require_once __DIR__.'/../inc/global.inc.php'; $current_course_tool = TOOL_CALENDAR_EVENT; $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/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')) { $type = 'admin'; @@ -165,7 +165,6 @@ if ($type == 'course' && !empty($group_id)) { } $defaultView = api_get_setting('default_calendar_view'); - if (empty($defaultView)) { $defaultView = 'month'; } diff --git a/main/template/default/agenda/month.html.twig b/main/template/default/agenda/month.html.twig index 7af6053db7..34a2646404 100644 --- a/main/template/default/agenda/month.html.twig +++ b/main/template/default/agenda/month.html.twig @@ -68,162 +68,16 @@ $(document).ready(function() { } }); - var CustomListViewGrid = ListViewGrid.extend({ - 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 '' + - (this.displayEventTime ? - '' + - (timeHtml || '') + - '' : - '') + - '' + - '' + - '' + - '' + - '' + - htmlEscape(seg.event.title || '') + (seg.event.description || '') - '' + - '' + - ''; - }, - - // 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 = $('
'); - 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 '' + - '' + - (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' }, - ' -  ' + htmlEscape(event.end.format(mainFormat)) // inner HTML - ) : - '') + - - (altFormat ? - view.buildGotoAnchorHtml( - dayDate, - { 'class': 'fc-list-heading-alt' }, - htmlEscape(dayDate.format(altFormat)) // inner HTML - ) : - '') + - '' + - ''; - }, - }); - - 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({ + var calendar = $('#calendar').fullCalendar({ header: { left: 'today,prev,next', center: 'title', - right: 'month,agendaWeek,agendaDay,CustomView' + right: 'month,agendaWeek,agendaDay,listDay,listWeek,listMonth' }, views: { - CustomView: { // name of view - type: 'list', - buttonText: '{{ 'AgendaList' | get_lang | escape('js') }}', - duration: { month: 1 }, - defaults: { - 'listDayAltFormat': 'dddd' // day-of-week is nice-to-have - } - }, - month: { - 'displayEventEnd' : true - } + listDay: { buttonText: 'list day' }, + listWeek: { buttonText: 'list week' }, + listMonth: { buttonText: 'list month' }, }, locale: region_value, {% if use_google_calendar == 1 %} diff --git a/package.json b/package.json index 31423a78f4..b356422397 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "cropper": "^4.0", "flag-icon-css": "^3.0", "fs": "0.0.1-security", - "fullcalendar": "3.1.0", + "fullcalendar": "^3.0", "highlight.js": "^9.12.0", "image-map-resizer": "^1.0.7", "jquery": "^3.3.1", diff --git a/yarn.lock b/yarn.lock index 302ebb78d1..ee414813d5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2636,12 +2636,12 @@ fstream@^1.0.0, fstream@^1.0.2: mkdirp ">=0.5 0" rimraf "2" -fullcalendar@3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/fullcalendar/-/fullcalendar-3.1.0.tgz#c81286ce00876294b2d3dba2d811ee33a8843917" +fullcalendar@^3.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/fullcalendar/-/fullcalendar-3.9.0.tgz#b608a9989f3416f0b1d526c6bdfeeaf2ac79eda5" dependencies: - jquery ">=2.0.0" - moment ">=2.9.0" + jquery "2 - 3" + moment "^2.20.1" function-bind@^1.0.2, function-bind@^1.1.1: version "1.1.1" @@ -3461,7 +3461,7 @@ jquery.scrollbar@^0.2.11: version "0.2.11" 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" 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" 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" resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.1.tgz#529a2e9bf973f259c9643d237fda84de3a26e8ad"