diff --git a/models/participation/FullCalendarSettings.php b/models/participation/FullCalendarSettings.php index a375fde6..15aadc9a 100644 --- a/models/participation/FullCalendarSettings.php +++ b/models/participation/FullCalendarSettings.php @@ -10,11 +10,10 @@ class FullCalendarSettings extends Model { - public const SETTING_LIST_WEEK = 'listWeek'; public const SETTING_GRID_DAY = 'timeGridDay'; public const SETTING_GRID_WEEK = 'timeGridWeek'; public const SETTING_GRID_MONTH = 'dayGridMonth'; - public const SETTING_LIST_YEAR = 'listYear'; + public const SETTING_LIST_MONTH = 'listMonth'; public const SETTING_VIEW_MODE_KEY = 'defaults.fullCalendarViewMode'; /** @@ -42,6 +41,11 @@ public function init() private function initSettings() { $this->viewMode = $this->getSetting(self::SETTING_VIEW_MODE_KEY, static::SETTING_GRID_MONTH); + + // Handle removed view modes + if ($this->viewMode === 'listWeek' || $this->viewMode === 'listYear') { + $this->viewMode = 'listMonth'; + } } /** @@ -110,11 +114,10 @@ public function isGlobal() public function getViewModeItems() { return [ - self::SETTING_LIST_YEAR => Yii::t('CalendarModule.base', 'Year'), self::SETTING_GRID_MONTH => Yii::t('CalendarModule.base', 'Month'), self::SETTING_GRID_WEEK => Yii::t('CalendarModule.base', 'Week'), self::SETTING_GRID_DAY => Yii::t('CalendarModule.base', 'Day'), - self::SETTING_LIST_WEEK => Yii::t('CalendarModule.base', 'List'), + self::SETTING_LIST_MONTH => Yii::t('CalendarModule.base', 'List'), ]; } } diff --git a/resources/js/humhub.calendar.Calendar.js b/resources/js/humhub.calendar.Calendar.js index 7be409cd..a7b5f86c 100644 --- a/resources/js/humhub.calendar.Calendar.js +++ b/resources/js/humhub.calendar.Calendar.js @@ -171,7 +171,7 @@ humhub.module('calendar.Calendar', function (module, require, $) { header: { left: 'prev,next today', center: 'title', - right: 'create dayGridMonth,timeGridWeek,timeGridDay,listWeek' + right: 'create dayGridMonth,timeGridWeek,timeGridDay,listMonth' }, buttonText: buttonText, plugins: ['dayGrid', 'timeGrid', 'list', 'interaction', 'bootstrap', 'moment', 'momentTimezone'], @@ -197,7 +197,7 @@ humhub.module('calendar.Calendar', function (module, require, $) { right: 'today' }; options.footer = { - center: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek', + center: 'dayGridMonth,timeGridWeek,timeGridDay,listMonth', right: 'create' }; } diff --git a/resources/js/humhub.calendar.Calendar.min.js b/resources/js/humhub.calendar.Calendar.min.js index fd71acfd..84339dff 100644 --- a/resources/js/humhub.calendar.Calendar.min.js +++ b/resources/js/humhub.calendar.Calendar.min.js @@ -1 +1 @@ -humhub.module("calendar.Calendar",function(i,t,r){var e=t("ui.widget").Widget,l=t("client"),n=t("util").string,o=t("ui.loader"),s=t("ui.view"),d=t("ui.modal"),a=e.extend();a.prototype.init=function(){var n=this;this.options.events=function(t,e,o){r.ajax({url:n.options.loadUrl,type:"GET",data:{start:moment(t.start.valueOf()).format("YYYY-MM-DD"),end:moment(t.end.valueOf()).format("YYYY-MM-DD"),selectors:n.options.selectors,filters:n.options.filters,types:n.options.types},success:function(t){e(t)}})},i.log.debug("Init calendar: ",this.options),this.initCalendarFilter(),this.updateCalendarFilters()},a.prototype.initCalendarFilter=function(){var t=this;r(".selectorCheckbox").click(function(){t.updateCalendarFilters(!0)}),r(".filterCheckbox").click(function(){"3"==r(this).val()&&r(":checkbox[value=4][name='filter']").attr("checked",!1),"4"==r(this).val()&&r(":checkbox[value=3][name='filter']").attr("checked",!1),t.updateCalendarFilters(!0)}),r('select[name="filterType[]"]').on("change.select2",function(){t.updateCalendarFilters(!0)})},a.prototype.updateCalendarFilters=function(t){var e=this;this.options.selectors=[],this.options.filters=[],this.options.types=[],r(".selectorCheckbox").each(function(){r(this).prop("checked")&&e.options.selectors.push(r(this).val())}),r(".filterCheckbox").each(function(){r(this).prop("checked")&&e.options.filters.push(r(this).val())}),e.options.types=r('select[name="filterType[]"]').val(),this.initFullCalendar(t)},a.prototype.initFullCalendar=function(t){this.fullCalendar&&t?(this.fullCalendar.removeAllEventSources(),this.fullCalendar.addEventSource(this.options.events)):(this.fullCalendar=new FullCalendar.Calendar(this.$[0],this.options),this.fullCalendar.render())},a.prototype.getDefaultOptions=function(){var t={};"today"!==i.text("button.today")&&(t.today=i.text("button.today")),"month"!==i.text("button.month")&&(t.month=i.text("button.month")),"week"!==i.text("button.week")&&(t.week=i.text("button.week")),"day"!==i.text("button.day")&&(t.day=i.text("button.day")),"list"!==i.text("button.list")&&(t.list=i.text("button.list"));var a=this,e={customButtons:{create:{click:function(){var t=new Date;t.setHours(t.getHours()+1),t.setMinutes(0,0,0);var e=new Date;e.setHours(e.getHours()+2),e.setMinutes(0,0,0);var o={data:{start:a.toJsonDateFormat(t,!1),end:a.toJsonDateFormat(e,!1),cal:1}},n=a.options.global?a.options.globalCreateUrl:a.options.editUrl;d.global.load(n,o).then(function(){d.global.$.one("hidden.bs.modal submitted",function(){a.fetch()})}).catch(function(t){d.global.close(),i.log.error(t,!0)}),a.fullCalendar.unselect()},bootstrapFontAwesome:"fa-plus"}},header:{left:"prev,next today",center:"title",right:"create dayGridMonth,timeGridWeek,timeGridDay,listWeek"},buttonText:t,plugins:["dayGrid","timeGrid","list","interaction","bootstrap","moment","momentTimezone"],defaultView:"dayGridMonth",canCreate:!0,selectable:!0,select:r.proxy(this.select,this),eventAllow:function(){return!0},themeSystem:"bootstrap",loading:r.proxy(this.loader,this),eventResize:r.proxy(this.updateEvent,this),eventDrop:r.proxy(this.updateEvent,this),eventClick:r.proxy(this.clickEvent,this),eventRender:r.proxy(this.renderEvent,this)};return s.isSmall()&&(e.header={left:"prev,next",center:"title",right:"today"},e.footer={center:"dayGridMonth,timeGridWeek,timeGridDay,listWeek",right:"create"}),e},a.prototype.renderEvent=function(t,e){var o=r(e);o.attr({title:o.text()}),t.icon&&n.startsWith(t.icon,"fa-")&&o.find(".fc-content").prepend(r(''))},a.prototype.toJsonDateFormat=function(t,e){return e?FullCalendarMoment.toMoment(t,this.fullCalendar).format("YYYY-MM-DD"):FullCalendarMoment.toMoment(t,this.fullCalendar).format()},a.prototype.select=function(t){var e=this,o={data:{start:this.toJsonDateFormat(t.start,!1),end:this.toJsonDateFormat(t.end,!1),cal:1}};"dayGridMonth"===t.view.type&&(o.data.view="month");var n=this.options.global?this.options.globalCreateUrl:this.options.editUrl;d.global.load(n,o).then(function(){d.global.$.one("hidden.bs.modal submitted",function(){e.fetch()})}).catch(function(t){d.global.close(),i.log.error(t,!0)}),this.fullCalendar.unselect()},a.prototype.fetch=function(){this.fullCalendar.refetchEvents()},a.prototype.updateEvent=function(e){var o=this,t=e.event,n=t.extendedProps,a={data:{id:t.id,start:this.toJsonDateFormat(t.start,t.allDay),end:this.toJsonDateFormat(t.end,t.allDay)}};this.loader(),l.post(n.updateUrl,a).then(function(t){t.success?i.log.success("saved"):i.log.error(t,!0),n.refreshAfterUpdate&&o.fetch()}).catch(function(t){i.log.error(t,!0),e.revert()}).finally(function(){o.loader(!1)})},a.prototype.clickEvent=function(t){var e=t.event.extendedProps;if(e.viewUrl){var o=this;"modal"===e.viewMode?d.global.load(e.viewUrl,{viewContext:"fullCalendar"}).then(function(){d.global.set({backdrop:!0}),d.global.$.one("hidden.bs.modal",function(){o.fetch()})}).catch(function(t){i.log.error(t,!0),d.global.close()}):l.pjax.redirect(e.viewUrl)}},a.prototype.loader=function(t){!1===t?o.reset(r("#calendar-overview-loader")):o.set(r("#calendar-overview-loader"),{size:"8px",css:{padding:"2px ",width:"60px"}})},i.export=a}); \ No newline at end of file +humhub.module("calendar.Calendar",function(t,e,o){var n=e("ui.widget").Widget,i=e("client"),a=e("util").string,r=e("ui.loader"),l=e("ui.view"),s=e("ui.modal"),d=n.extend();d.prototype.init=function(){var e=this;this.options.events=function(t,n,i){o.ajax({url:e.options.loadUrl,type:"GET",data:{start:moment(t.start.valueOf()).format("YYYY-MM-DD"),end:moment(t.end.valueOf()).format("YYYY-MM-DD"),selectors:e.options.selectors,filters:e.options.filters,types:e.options.types},success:function(t){n(t)}})},t.log.debug("Init calendar: ",this.options),this.initCalendarFilter(),this.updateCalendarFilters()},d.prototype.initCalendarFilter=function(){var t=this;o(".selectorCheckbox").click(function(){t.updateCalendarFilters(!0)}),o(".filterCheckbox").click(function(){"3"==o(this).val()&&o(":checkbox[value=4][name='filter']").attr("checked",!1),"4"==o(this).val()&&o(":checkbox[value=3][name='filter']").attr("checked",!1),t.updateCalendarFilters(!0)}),o('select[name="filterType[]"]').on("change.select2",function(){t.updateCalendarFilters(!0)})},d.prototype.updateCalendarFilters=function(t){var e=this;this.options.selectors=[],this.options.filters=[],this.options.types=[],o(".selectorCheckbox").each(function(){o(this).prop("checked")&&e.options.selectors.push(o(this).val())}),o(".filterCheckbox").each(function(){o(this).prop("checked")&&e.options.filters.push(o(this).val())}),e.options.types=o('select[name="filterType[]"]').val(),this.initFullCalendar(t)},d.prototype.initFullCalendar=function(t){this.fullCalendar&&t?(this.fullCalendar.removeAllEventSources(),this.fullCalendar.addEventSource(this.options.events)):(this.fullCalendar=new FullCalendar.Calendar(this.$[0],this.options),this.fullCalendar.render())},d.prototype.getDefaultOptions=function(){var e={};"today"!==t.text("button.today")&&(e.today=t.text("button.today")),"month"!==t.text("button.month")&&(e.month=t.text("button.month")),"week"!==t.text("button.week")&&(e.week=t.text("button.week")),"day"!==t.text("button.day")&&(e.day=t.text("button.day")),"list"!==t.text("button.list")&&(e.list=t.text("button.list"));var n=this,i={customButtons:{create:{click:function(){var e=new Date;e.setHours(e.getHours()+1),e.setMinutes(0,0,0);var o=new Date;o.setHours(o.getHours()+2),o.setMinutes(0,0,0);var i={data:{start:n.toJsonDateFormat(e,!1),end:n.toJsonDateFormat(o,!1),cal:1}},a=n.options.global?n.options.globalCreateUrl:n.options.editUrl;s.global.load(a,i).then(function(){s.global.$.one("hidden.bs.modal submitted",function(){n.fetch()})}).catch(function(e){s.global.close(),t.log.error(e,!0)}),n.fullCalendar.unselect()},bootstrapFontAwesome:"fa-plus"}},header:{left:"prev,next today",center:"title",right:"create dayGridMonth,timeGridWeek,timeGridDay,listMonth"},buttonText:e,plugins:["dayGrid","timeGrid","list","interaction","bootstrap","moment","momentTimezone"],defaultView:"dayGridMonth",canCreate:!0,selectable:!0,select:o.proxy(this.select,this),eventAllow:function(){return!0},themeSystem:"bootstrap",loading:o.proxy(this.loader,this),eventResize:o.proxy(this.updateEvent,this),eventDrop:o.proxy(this.updateEvent,this),eventClick:o.proxy(this.clickEvent,this),eventRender:o.proxy(this.renderEvent,this)};return l.isSmall()&&(i.header={left:"prev,next",center:"title",right:"today"},i.footer={center:"dayGridMonth,timeGridWeek,timeGridDay,listMonth",right:"create"}),i},d.prototype.renderEvent=function(t,e){var n=o(e);n.attr({title:n.text()}),t.icon&&a.startsWith(t.icon,"fa-")&&n.find(".fc-content").prepend(o(''))},d.prototype.toJsonDateFormat=function(t,e){return e?FullCalendarMoment.toMoment(t,this.fullCalendar).format("YYYY-MM-DD"):FullCalendarMoment.toMoment(t,this.fullCalendar).format()},d.prototype.select=function(e){var o=this,n={data:{start:this.toJsonDateFormat(e.start,!1),end:this.toJsonDateFormat(e.end,!1),cal:1}};"dayGridMonth"===e.view.type&&(n.data.view="month");var i=this.options.global?this.options.globalCreateUrl:this.options.editUrl;s.global.load(i,n).then(function(){s.global.$.one("hidden.bs.modal submitted",function(){o.fetch()})}).catch(function(e){s.global.close(),t.log.error(e,!0)}),this.fullCalendar.unselect()},d.prototype.fetch=function(){this.fullCalendar.refetchEvents()},d.prototype.updateEvent=function(e){var o=this,n=e.event,a=n.extendedProps,r={data:{id:n.id,start:this.toJsonDateFormat(n.start,n.allDay),end:this.toJsonDateFormat(n.end,n.allDay)}};this.loader(),i.post(a.updateUrl,r).then(function(e){e.success?t.log.success("saved"):t.log.error(e,!0),a.refreshAfterUpdate&&o.fetch()}).catch(function(o){t.log.error(o,!0),e.revert()}).finally(function(){o.loader(!1)})},d.prototype.clickEvent=function(e){var o=e.event.extendedProps;if(o.viewUrl){var n=this;"modal"===o.viewMode?s.global.load(o.viewUrl,{viewContext:"fullCalendar"}).then(function(){s.global.set({backdrop:!0}),s.global.$.one("hidden.bs.modal",function(){n.fetch()})}).catch(function(e){t.log.error(e,!0),s.global.close()}):i.pjax.redirect(o.viewUrl)}},d.prototype.loader=function(t){!1===t?r.reset(o("#calendar-overview-loader")):r.set(o("#calendar-overview-loader"),{size:"8px",css:{padding:"2px ",width:"60px"}})},t.export=d}); \ No newline at end of file