diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a64b9ac6..8a74346c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,6 @@ Changelog ========= +- Enh #423: Add Create Button 1.5.4 - (Unreleased) ----------------------- diff --git a/resources/css/calendar.css b/resources/css/calendar.css index d31b4276..c4dbe595 100644 --- a/resources/css/calendar.css +++ b/resources/css/calendar.css @@ -102,6 +102,10 @@ html .fc, border: 1px solid #eeeeee !important; } +/* Hide Create button when user can not create events */ +#calendar[data-can-create="0"] .fc-create-button { + display: none; +} /* Content ------------------------------------------------------------------------*/ diff --git a/resources/css/calendar.min.css b/resources/css/calendar.min.css index 89dd69aa..a2de5b18 100644 --- a/resources/css/calendar.min.css +++ b/resources/css/calendar.min.css @@ -2,4 +2,4 @@ * FullCalendar v2.0.2 Stylesheet * Docs & License: http://arshaw.com/fullcalendar/ * (c) 2013 Adam Shaw - */.fc{direction:ltr;text-align:left}.fc table{border-collapse:collapse;border-spacing:0}.fc table,html .fc{font-size:1em}.fc td,.fc th{padding:0;vertical-align:top}.fc-header td{white-space:nowrap}.fc-header-left{width:25%;text-align:left}.fc-header-center{text-align:center}.fc-header-right{width:25%;text-align:right}.fc-header-title{display:inline-block;vertical-align:top;color:red!important}.fc-header-toolbar h2{margin-top:0;white-space:nowrap;font-size:20px;font-weight:600;color:#555}.fc .fc-header-space{padding-left:10px}.fc-header .fc-button{margin-bottom:1em;vertical-align:top}.fc-header .fc-button{margin-right:-1px}.fc-header .fc-corner-right,.fc-header .ui-corner-right{margin-right:0}.fc-header .fc-state-hover,.fc-header .ui-state-hover{z-index:2}.fc-header .fc-state-down{z-index:3}.fc-header .fc-state-active,.fc-header .ui-state-active{z-index:4}.fc-day-header{border:1px solid #eee!important}.fc-content{position:relative;z-index:1;clear:both;zoom:1}.fc-content .fa{margin:0 2px}.fc-view{position:relative;width:100%;overflow:hidden}.fc-widget-content,.fc-widget-header{border:1px solid #eee}td.fc-today{background:var(--background-color-highlight)}.fc-state-highlight,.fc-unthemed td.fc-today{background:#f6fdfc!important}.fc-cell-overlay{background:#bce8f1;opacity:.3}.fc-button{position:relative;display:inline-block;padding:0 .6em;overflow:hidden;height:1.9em;line-height:1.9em;white-space:nowrap;cursor:pointer}.fc-state-default{border:1px solid;background-image:none!important}.fc-state-default.fc-corner-left{border-top-left-radius:4px;border-bottom-left-radius:4px}.fc-state-default.fc-corner-right{border-top-right-radius:4px;border-bottom-right-radius:4px}.fc-disabled-cursor:hover{cursor:not-allowed}.fc-button .fc-icon{margin:0 .1em;font-family:"Courier New",Courier,monospace;vertical-align:baseline}.fc-icon-left-single-arrow:after{content:"\02039";font-weight:700}.fc-icon-right-single-arrow:after{content:"\0203A";font-weight:700}.fc-icon-left-double-arrow:after{content:"\000AB"}.fc-icon-right-double-arrow:after{content:"\000BB"}.fc-button .ui-icon{position:relative;top:50%;float:left;margin-top:-8px}.fc-state-default{background-color:#ededed;color:#777;border-color:#ededed}.fc-state-hover{background-color:#ededed;color:#777}.fc-state-active,.fc-state-down{background-color:#d7d7d7;border-color:#d7d7d7;color:#777}.fc-state-disabled{cursor:default;background-image:none;opacity:.65;box-shadow:none}.fc-event-container>*{z-index:8}.fc-event-container>.ui-draggable-dragging,.fc-event-container>.ui-resizable-resizing{z-index:9}.fc-event{background-color:#6fdbe8;color:#fff;font-size:.85em;cursor:default}a.fc-event{text-decoration:none}.fc-event-draggable,a.fc-event{cursor:pointer}.fc-rtl .fc-event{text-align:right}.fc-day-grid-event{border:none}.fc-content{width:100%;height:100%;overflow:hidden;padding:2px;border:none}.fc-event-time,.fc-event-title{padding:0 1px;font-size:13px}.fc .ui-resizable-handle{display:block;position:absolute;z-index:99999;overflow:hidden;font-size:300%;line-height:50%}.fc-event-hori{border-width:1px 0;margin-bottom:1px}.fc-ltr .fc-event-hori.fc-event-start,.fc-rtl .fc-event-hori.fc-event-end{border-left-width:1px;border-top-left-radius:3px;border-bottom-left-radius:3px}.fc-ltr .fc-event-hori.fc-event-end,.fc-rtl .fc-event-hori.fc-event-start{border-right-width:1px;border-top-right-radius:3px;border-bottom-right-radius:3px}.fc-event-hori .ui-resizable-e{top:0!important;right:-3px!important;width:7px!important;height:100%!important;cursor:e-resize}.fc-event-hori .ui-resizable-w{top:0!important;left:-3px!important;width:7px!important;height:100%!important;cursor:w-resize}table.fc-border-separate{border-collapse:separate}.fc-border-separate td,.fc-border-separate th{border-width:1px 0 0 1px}.fc-border-separate td.fc-last,.fc-border-separate th.fc-last{border-right-width:1px}.fc-border-separate tr.fc-last td,.fc-border-separate tr.fc-last th{border-bottom-width:1px}.fc-border-separate tbody tr.fc-first td,.fc-border-separate tbody tr.fc-first th{border-top-width:0}.fc-grid th{text-align:center}.fc .fc-week-number{width:22px;text-align:center}.fc .fc-week-number div{padding:0 2px}.fc-grid .fc-day-number{float:right;padding:0 2px}.fc-grid .fc-other-month .fc-day-number{opacity:.3}.fc-grid .fc-day-content{clear:both;padding:2px 2px 1px}.fc-grid .fc-event-time{font-weight:700}.fc-rtl .fc-grid .fc-day-number{float:left}.fc-rtl .fc-grid .fc-event-time{float:right}.fc-agenda table{border-collapse:separate}.fc-agenda-days th{text-align:center}.fc-agenda .fc-agenda-axis{width:50px;padding:0 4px;vertical-align:middle;text-align:right;font-weight:400}.fc-agenda-slots .fc-agenda-axis{white-space:nowrap}.fc-agenda .fc-week-number{font-weight:700}.fc-agenda .fc-day-content{padding:2px 2px 1px}.fc-agenda-days .fc-agenda-axis{border-right-width:1px}.fc-agenda-days .fc-col0{border-left-width:0}.fc-agenda-allday th{border-width:0 1px}.fc-agenda-allday .fc-day-content{min-height:34px}.fc-agenda-divider-inner{height:2px;overflow:hidden}.fc-widget-header .fc-agenda-divider-inner{background:#eee}.fc-agenda-slots th{border-width:1px 1px 0}.fc-agenda-slots td{border-width:1px 0 0;background:0 0}.fc-agenda-slots td div{height:20px}.fc-agenda-slots tr.fc-slot0 td,.fc-agenda-slots tr.fc-slot0 th{border-top-width:0}.fc-agenda-slots tr.fc-minor td,.fc-agenda-slots tr.fc-minor th{border-top-style:dotted}.fc-event-vert{border-width:0 1px}.fc-event-vert.fc-event-start{border-top-width:1px;border-top-left-radius:3px;border-top-right-radius:3px}.fc-event-vert.fc-event-end{border-bottom-width:1px;border-bottom-left-radius:3px;border-bottom-right-radius:3px}.fc-event-vert .fc-event-time{white-space:nowrap;font-size:13px;font-weight:700}.fc-event-vert .fc-event-inner{position:relative;z-index:2}.fc-event-vert .fc-event-bg{position:absolute;z-index:1;top:0;left:0;width:100%;height:100%;background:#fff;opacity:.25}.fc-event-vert .ui-resizable-s{bottom:0!important;width:100%!important;height:8px!important;overflow:hidden!important;line-height:8px!important;font-size:11px!important;font-family:monospace;text-align:center;cursor:s-resize}.fc-content,.fc-divider,.fc-list-heading td,.fc-list-view,.fc-popover,.fc-row,tbody,td,th,thead{border-color:#eee}.fc-list-view{width:auto!important}.fc-event-dot{margin-right:2px}.fc-list-item{cursor:pointer}.fc-list-heading{background-color:#eee}.fc-view-container .table>tbody>tr>td,.fc-view-container .table>tbody>tr>th,.fc-view-container .table>tfoot>tr>td,.fc-view-container .table>tfoot>tr>th,.fc-view-container .table>thead>tr>td,.fc-view-container .table>thead>tr>th{padding:10px}.calendar-options .calendar-filters,.calendar-options .calendar-selectors,.calendar-options .calendar-types{float:left;margin-right:10px}.timeField .form-group{margin-bottom:0}.timeField .help-block{margin:0}#calendar-entry-form{padding-top:0}#calendar-entry-form .tab-menu{margin-bottom:0}#calendar-entry-form .bootstrap-timepicker-widget{min-width:140px}#calendar-entry-form .ProseMirror-menubar-wrapper{z-index:8}#calendar-entry-form .ProseMirror{min-height:150px!important}.calendar-entry-participants.modal-body{padding:0 0 20px 0}.calendar-entry-participants button.btn-participants-action{margin:10px 0 0 12px}.calendar-entry-participants .pagination{margin:10px 0 0}.calendar-entry-participants .media-list{margin:0 11px}.calendar-entry-participants .media-body{width:1%;word-break:initial}.calendar-entry-participants .media-body:first-child{width:auto}.calendar-entry-participants .media-body:first-child .media-object{float:left;margin-right:5px}.calendar-entry-participants .media-body:not(:first-child){padding-left:5px}.calendar-entry-participants select.form-control{width:auto;height:40px;padding-right:24px}.calendar-entry-new-participants-form button.btn,.calendar-entry-participants .media-list button.btn{height:32px;margin-top:3px}.calendar-entry-participants-count{padding:18px 18px 36px;margin:0}#calendar-entry-participants-list{position:relative}.calendar-entry-participants-export-button{margin:18px 18px 0}.calendar-entry-new-participants-form{padding:18px 18px 4px}.calendar-entry-new-participants-form .form-group.field-calendarentryparticipationform-newparticipantstatus{padding:0;margin:0}.calendar-entry-new-participants-form .form-group .checkbox label{padding-left:0}.calendar-entry-new-participants-form .form-group.field-calendarentryparticipationform-newforcestatus{display:inline-block}.calendar-entry-participants-filters{padding:10px 18px 0}.calendar-entry-participants-filter-title{font-size:80%}.calendar-entry-participants-filters .btn.btn-info{margin:10px 8px 0 0;padding:3px 14px}.calendar-entry-participants-filters .btn.btn-info.active{background:#0397a8!important;color:#fff!important}.calendar-entry-participants-filters .btn.btn-info:not(.active){border:1px solid #435f6f;color:#435f6f!important;background:#fff}.calendar-entry-participants-filters .btn.btn-info:not(.active):hover{background:#0397a8!important;border:1px solid #0397a8;color:#fff!important}.calendar-entry-participants .pagination-container{margin-top:25px}.calendar-entry-participants .pagination>li>a{color:#000}.calendar-entry-participants .pagination>.active>a{color:#fff}.calendar-option-buttons{float:right}#calendar-overview-loader{position:absolute;right:10px;top:60px}.calendar-wall-entry .calendar-wall-entry-section{margin-bottom:10px}.calendar-wall-entry .event-info-section{margin-bottom:10px}.calendar-wall-entry .event-info-section-content{padding-left:25px}.calendar-wall-entry .event-participation-buttons{margin:32px 0 15px}.calendar-wall-entry .event-participation-buttons button{margin-right:8px}.calendar-wall-entry .event-participation-buttons button .fa{font-size:130%;position:relative;top:1px;margin-right:3px}.calendar-wall-entry [data-action-click]{cursor:pointer}.calendar-wall-entry .event-info-section-content h1{margin:0 0 5px;font-weight:600;font-size:14px}@media (max-width:767px){.calendar-option-buttons{float:none;text-align:right}#calendar-overview-loader{position:inherit;float:left}} \ No newline at end of file + */.fc-button,.fc-content,.fc-view{position:relative}.fc-agenda-slots .fc-agenda-axis,.fc-button,.fc-header td,.fc-header-toolbar h2{white-space:nowrap}.calendar-entry-new-participants-form .form-group.field-calendarentryparticipationform-newforcestatus,.fc-button,.fc-header-title{display:inline-block}.fc{direction:ltr;text-align:left}.fc table{border-collapse:collapse;border-spacing:0}.fc table,html .fc{font-size:1em}.fc td,.fc th{padding:0;vertical-align:top}.fc-header-left{width:25%;text-align:left}.fc-agenda-days th,.fc-grid th,.fc-header-center{text-align:center}.fc-header-right,.fc-rtl .fc-event{text-align:right}.fc-header-right{width:25%}.fc-content,.fc-view{width:100%;overflow:hidden}.fc-header-title{vertical-align:top;color:red!important}.fc-header-toolbar h2{margin-top:0;font-size:20px;font-weight:600;color:#555}.fc .fc-header-space{padding-left:10px}.fc-header .fc-button{margin-bottom:1em;vertical-align:top;margin-right:-1px}.fc-header .fc-corner-right,.fc-header .ui-corner-right{margin-right:0}.fc-header .fc-state-hover,.fc-header .ui-state-hover{z-index:2}.fc-header .fc-state-down{z-index:3}.fc-header .fc-state-active,.fc-header .ui-state-active{z-index:4}.fc-day-header{border:1px solid #eee!important}#calendar[data-can-create="0"] .fc-create-button{display:none}.fc-content{z-index:1;clear:both;zoom:1}.fc-content .fa{margin:0 2px}.fc-widget-content,.fc-widget-header{border:1px solid #eee}td.fc-today{background:var(--background-color-highlight)}.fc-state-highlight,.fc-unthemed td.fc-today{background:#f6fdfc!important}.fc-cell-overlay{background:#bce8f1;opacity:.3}.fc-state-default,.fc-state-hover{background-color:#ededed;color:#777}.fc-button{padding:0 .6em;overflow:hidden;height:1.9em;line-height:1.9em;cursor:pointer}.fc-state-default{border:1px solid #ededed;background-image:none!important}.fc-state-default.fc-corner-left{border-top-left-radius:4px;border-bottom-left-radius:4px}.fc-state-default.fc-corner-right{border-top-right-radius:4px;border-bottom-right-radius:4px}.fc-disabled-cursor:hover{cursor:not-allowed}.fc-button .fc-icon{margin:0 .1em;font-family:"Courier New",Courier,monospace;vertical-align:baseline}.fc-icon-left-single-arrow:after{content:"\02039";font-weight:700}.fc-icon-right-single-arrow:after{content:"\0203A";font-weight:700}.fc-icon-left-double-arrow:after{content:"\000AB"}.fc-icon-right-double-arrow:after{content:"\000BB"}.fc-button .ui-icon{position:relative;top:50%;float:left;margin-top:-8px}.fc-state-active,.fc-state-down{background-color:#d7d7d7;border-color:#d7d7d7;color:#777}.fc-content,.fc-day-grid-event{border:none}.calendar-entry-participants .pagination>.active>a,.fc-event{color:#fff}.fc-state-disabled{cursor:default;background-image:none;opacity:.65;box-shadow:none}#calendar-entry-form .ProseMirror-menubar-wrapper,.fc-event-container>*{z-index:8}.fc-event-container>.ui-draggable-dragging,.fc-event-container>.ui-resizable-resizing{z-index:9}.fc-event{background-color:#6fdbe8;font-size:.85em;cursor:default}a.fc-event{text-decoration:none}.calendar-wall-entry [data-action-click],.fc-event-draggable,.fc-list-item,a.fc-event{cursor:pointer}.fc-content{height:100%;padding:2px}.fc-event-time,.fc-event-title{padding:0 1px;font-size:13px}.fc .ui-resizable-handle{display:block;position:absolute;z-index:99999;overflow:hidden;font-size:300%;line-height:50%}.fc-event-hori{border-width:1px 0;margin-bottom:1px}.fc-ltr .fc-event-hori.fc-event-start,.fc-rtl .fc-event-hori.fc-event-end{border-left-width:1px;border-top-left-radius:3px;border-bottom-left-radius:3px}.fc-ltr .fc-event-hori.fc-event-end,.fc-rtl .fc-event-hori.fc-event-start{border-right-width:1px;border-top-right-radius:3px;border-bottom-right-radius:3px}.fc-event-hori .ui-resizable-e{top:0!important;right:-3px!important;width:7px!important;height:100%!important;cursor:e-resize}.fc-event-hori .ui-resizable-w{top:0!important;left:-3px!important;width:7px!important;height:100%!important;cursor:w-resize}.fc-agenda table,table.fc-border-separate{border-collapse:separate}.fc-border-separate td,.fc-border-separate th{border-width:1px 0 0 1px}.fc-agenda-days .fc-agenda-axis,.fc-border-separate td.fc-last,.fc-border-separate th.fc-last{border-right-width:1px}.fc-border-separate tr.fc-last td,.fc-border-separate tr.fc-last th{border-bottom-width:1px}.fc-agenda-slots tr.fc-slot0 td,.fc-agenda-slots tr.fc-slot0 th,.fc-border-separate tbody tr.fc-first td,.fc-border-separate tbody tr.fc-first th{border-top-width:0}.fc .fc-week-number{width:22px;text-align:center}.fc .fc-week-number div{padding:0 2px}.fc-grid .fc-day-number{float:right;padding:0 2px}.fc-grid .fc-other-month .fc-day-number{opacity:.3}.fc-grid .fc-day-content{clear:both;padding:2px 2px 1px}.fc-agenda .fc-week-number,.fc-grid .fc-event-time{font-weight:700}.fc-rtl .fc-grid .fc-day-number{float:left}.calendar-option-buttons,.fc-rtl .fc-grid .fc-event-time{float:right}.fc-agenda .fc-agenda-axis{width:50px;padding:0 4px;vertical-align:middle;text-align:right;font-weight:400}.fc-agenda .fc-day-content{padding:2px 2px 1px}.fc-agenda-days .fc-col0{border-left-width:0}.fc-agenda-allday th,.fc-event-vert{border-width:0 1px}.fc-agenda-allday .fc-day-content{min-height:34px}.fc-agenda-divider-inner{height:2px;overflow:hidden}.fc-widget-header .fc-agenda-divider-inner{background:#eee}.fc-agenda-slots th{border-width:1px 1px 0}.fc-agenda-slots td{border-width:1px 0 0;background:0 0}.fc-agenda-slots td div{height:20px}.fc-agenda-slots tr.fc-minor td,.fc-agenda-slots tr.fc-minor th{border-top-style:dotted}.fc-event-vert.fc-event-start{border-top-width:1px;border-top-left-radius:3px;border-top-right-radius:3px}.fc-event-vert.fc-event-end{border-bottom-width:1px;border-bottom-left-radius:3px;border-bottom-right-radius:3px}.fc-event-vert .fc-event-time{white-space:nowrap;font-size:13px;font-weight:700}.fc-event-vert .fc-event-inner{position:relative;z-index:2}.fc-event-vert .fc-event-bg{position:absolute;z-index:1;top:0;left:0;width:100%;height:100%;background:#fff;opacity:.25}.fc-event-vert .ui-resizable-s{bottom:0!important;width:100%!important;height:8px!important;overflow:hidden!important;line-height:8px!important;font-size:11px!important;font-family:monospace;text-align:center;cursor:s-resize}.fc-content,.fc-divider,.fc-list-heading td,.fc-list-view,.fc-popover,.fc-row,tbody,td,th,thead{border-color:#eee}.fc-list-view{width:auto!important}.fc-event-dot{margin-right:2px}.fc-list-heading{background-color:#eee}.fc-view-container .table>tbody>tr>td,.fc-view-container .table>tbody>tr>th,.fc-view-container .table>tfoot>tr>td,.fc-view-container .table>tfoot>tr>th,.fc-view-container .table>thead>tr>td,.fc-view-container .table>thead>tr>th{padding:10px}.calendar-options .calendar-filters,.calendar-options .calendar-selectors,.calendar-options .calendar-types{float:left;margin-right:10px}#calendar-entry-form .tab-menu,.timeField .form-group{margin-bottom:0}.timeField .help-block{margin:0}#calendar-entry-form{padding-top:0}#calendar-entry-form .bootstrap-timepicker-widget{min-width:140px}#calendar-entry-form .ProseMirror{min-height:150px!important}.calendar-entry-participants.modal-body{padding:0 0 20px}.calendar-entry-participants button.btn-participants-action{margin:10px 0 0 12px}.calendar-entry-participants .pagination{margin:10px 0 0}.calendar-entry-participants .media-list{margin:0 11px}.calendar-entry-participants .media-body{width:1%;word-break:initial}.calendar-entry-participants .media-body:first-child{width:auto}.calendar-entry-participants .media-body:first-child .media-object{float:left;margin-right:5px}.calendar-entry-participants .media-body:not(:first-child){padding-left:5px}.calendar-entry-participants select.form-control{width:auto;height:40px;padding-right:24px}.calendar-entry-new-participants-form button.btn,.calendar-entry-participants .media-list button.btn{height:32px;margin-top:3px}.calendar-entry-participants-count{padding:18px 18px 36px;margin:0}#calendar-entry-participants-list{position:relative}.calendar-entry-participants-export-button{margin:18px 18px 0}.calendar-entry-new-participants-form{padding:18px 18px 4px}.calendar-entry-new-participants-form .form-group.field-calendarentryparticipationform-newparticipantstatus{padding:0;margin:0}.calendar-entry-new-participants-form .form-group .checkbox label{padding-left:0}.calendar-entry-participants-filters{padding:10px 18px 0}.calendar-entry-participants-filter-title{font-size:80%}.calendar-entry-participants-filters .btn.btn-info{margin:10px 8px 0 0;padding:3px 14px}.calendar-entry-participants-filters .btn.btn-info.active{background:#0397a8!important;color:#fff!important}.calendar-entry-participants-filters .btn.btn-info:not(.active){border:1px solid #435f6f;color:#435f6f!important;background:#fff}.calendar-entry-participants-filters .btn.btn-info:not(.active):hover{background:#0397a8!important;border:1px solid #0397a8;color:#fff!important}.calendar-entry-participants .pagination-container{margin-top:25px}.calendar-entry-participants .pagination>li>a{color:#000}#calendar-overview-loader{position:absolute;right:10px;top:60px}.calendar-wall-entry .calendar-wall-entry-section,.calendar-wall-entry .event-info-section{margin-bottom:10px}.calendar-wall-entry .event-info-section-content{padding-left:25px}.calendar-wall-entry .event-participation-buttons{margin:32px 0 15px}.calendar-wall-entry .event-participation-buttons button{margin-right:8px}.calendar-wall-entry .event-participation-buttons button .fa{font-size:130%;position:relative;top:1px;margin-right:3px}.calendar-wall-entry .event-info-section-content h1{margin:0 0 5px;font-weight:600;font-size:14px}@media (max-width:767px){.calendar-option-buttons{float:none;text-align:right}#calendar-overview-loader{position:inherit;float:left}} \ No newline at end of file diff --git a/resources/js/humhub.calendar.Calendar.js b/resources/js/humhub.calendar.Calendar.js index bfa00c84..7be409cd 100644 --- a/resources/js/humhub.calendar.Calendar.js +++ b/resources/js/humhub.calendar.Calendar.js @@ -129,11 +129,49 @@ humhub.module('calendar.Calendar', function (module, require, $) { buttonText.list = module.text('button.list'); } + var that = this; + var options = { + customButtons: { + create: { + click: function() { + // Start: next full hour + var start = new Date(); + start.setHours(start.getHours() + 1); + start.setMinutes(0, 0, 0); + + // End: next full hour +1 + var end = new Date(); + end.setHours(end.getHours() + 2); + end.setMinutes(0, 0, 0); + + var options = { + data: { + start: that.toJsonDateFormat(start, false), + end: that.toJsonDateFormat(end, false), + cal: 1 + } + } + var createUrl = that.options.global ? that.options.globalCreateUrl : that.options.editUrl; + + modal.global.load(createUrl, options).then(function () { + modal.global.$.one('hidden.bs.modal submitted', function () { + that.fetch(); + }); + }).catch(function (e) { + modal.global.close(); + module.log.error(e, true); + }); + + that.fullCalendar.unselect(); + }, + bootstrapFontAwesome: 'fa-plus', + } + }, header: { left: 'prev,next today', center: 'title', - right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek' + right: 'create dayGridMonth,timeGridWeek,timeGridDay,listWeek' }, buttonText: buttonText, plugins: ['dayGrid', 'timeGrid', 'list', 'interaction', 'bootstrap', 'moment', 'momentTimezone'], @@ -159,7 +197,8 @@ humhub.module('calendar.Calendar', function (module, require, $) { right: 'today' }; options.footer = { - center: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek' + center: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek', + right: 'create' }; } diff --git a/resources/js/humhub.calendar.Calendar.min.js b/resources/js/humhub.calendar.Calendar.min.js index 2fc13ba0..e8fc8189 100644 --- a/resources/js/humhub.calendar.Calendar.min.js +++ b/resources/js/humhub.calendar.Calendar.min.js @@ -1 +1 @@ -humhub.module("calendar.Calendar",function(a,t,i){var e=t("ui.widget").Widget,r=t("client"),n=t("util").string,o=t("ui.loader"),l=t("ui.view"),s=t("ui.modal"),d=e.extend();d.prototype.init=function(){var n=this;this.options.events=function(t,e,o){i.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)}})},a.log.debug("Init calendar: ",this.options),this.initCalendarFilter(),this.updateCalendarFilters()},d.prototype.initCalendarFilter=function(){var t=this;i(".selectorCheckbox").click(function(){t.updateCalendarFilters(!0)}),i(".filterCheckbox").click(function(){"3"==i(this).val()&&i(":checkbox[value=4][name='filter']").attr("checked",!1),"4"==i(this).val()&&i(":checkbox[value=3][name='filter']").attr("checked",!1),t.updateCalendarFilters(!0)}),i('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=[],i(".selectorCheckbox").each(function(){i(this).prop("checked")&&e.options.selectors.push(i(this).val())}),i(".filterCheckbox").each(function(){i(this).prop("checked")&&e.options.filters.push(i(this).val())}),e.options.types=i('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 t={};"today"!==a.text("button.today")&&(t.today=a.text("button.today")),"month"!==a.text("button.month")&&(t.month=a.text("button.month")),"week"!==a.text("button.week")&&(t.week=a.text("button.week")),"day"!==a.text("button.day")&&(t.day=a.text("button.day")),"list"!==a.text("button.list")&&(t.list=a.text("button.list"));var e={header:{left:"prev,next today",center:"title",right:"dayGridMonth,timeGridWeek,timeGridDay,listWeek"},buttonText:t,plugins:["dayGrid","timeGrid","list","interaction","bootstrap","moment","momentTimezone"],defaultView:"dayGridMonth",canCreate:!0,selectable:!0,select:i.proxy(this.select,this),eventAllow:function(){return!0},themeSystem:"bootstrap",loading:i.proxy(this.loader,this),eventResize:i.proxy(this.updateEvent,this),eventDrop:i.proxy(this.updateEvent,this),eventClick:i.proxy(this.clickEvent,this),eventRender:i.proxy(this.renderEvent,this)};return l.isSmall()&&(e.header={left:"prev,next",center:"title",right:"today"},e.footer={center:"dayGridMonth,timeGridWeek,timeGridDay,listWeek"}),e},d.prototype.renderEvent=function(t,e){var o=i(e);o.attr({title:o.text()}),t.icon&&n.startsWith(t.icon,"fa-")&&o.find(".fc-content").prepend(i(''))},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(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;s.global.load(n,o).then(function(){s.global.$.one("hidden.bs.modal submitted",function(){e.fetch()})}).catch(function(t){s.global.close(),a.log.error(t,!0)}),this.fullCalendar.unselect()},d.prototype.fetch=function(){this.fullCalendar.refetchEvents()},d.prototype.updateEvent=function(e){var o=this,t=e.event,n=t.extendedProps,i={data:{id:t.id,start:this.toJsonDateFormat(t.start,t.allDay),end:this.toJsonDateFormat(t.end,t.allDay)}};this.loader(),r.post(n.updateUrl,i).then(function(t){t.success?a.log.success("saved"):a.log.error(t,!0),n.refreshAfterUpdate&&o.fetch()}).catch(function(t){a.log.error(t,!0),e.revert()}).finally(function(){o.loader(!1)})},d.prototype.clickEvent=function(t){var e=t.event.extendedProps;if(e.viewUrl){var o=this;"modal"===e.viewMode?s.global.load(e.viewUrl,{viewContext:"fullCalendar"}).then(function(){s.global.set({backdrop:!0}),s.global.$.one("hidden.bs.modal",function(){o.fetch()})}).catch(function(t){a.log.error(t,!0),s.global.close()}):r.pjax.redirect(e.viewUrl)}},d.prototype.loader=function(t){!1===t?o.reset(i("#calendar-overview-loader")):o.set(i("#calendar-overview-loader"),{size:"8px",css:{padding:"2px ",width:"60px"}})},a.export=d}); \ No newline at end of file +humhub.module("calendar.Calendar",function(a,t,i){var e=t("ui.widget").Widget,l=t("client"),o=t("util").string,n=t("ui.loader"),r=t("ui.view"),s=t("ui.modal"),e=e.extend();e.prototype.init=function(){var n=this;this.options.events=function(t,e,o){i.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)}})},a.log.debug("Init calendar: ",this.options),this.initCalendarFilter(),this.updateCalendarFilters()},e.prototype.initCalendarFilter=function(){var t=this;i(".selectorCheckbox").click(function(){t.updateCalendarFilters(!0)}),i(".filterCheckbox").click(function(){"3"==i(this).val()&&i(":checkbox[value=4][name='filter']").attr("checked",!1),"4"==i(this).val()&&i(":checkbox[value=3][name='filter']").attr("checked",!1),t.updateCalendarFilters(!0)}),i('select[name="filterType[]"]').on("change.select2",function(){t.updateCalendarFilters(!0)})},e.prototype.updateCalendarFilters=function(t){var e=this;this.options.selectors=[],this.options.filters=[],this.options.types=[],i(".selectorCheckbox").each(function(){i(this).prop("checked")&&e.options.selectors.push(i(this).val())}),i(".filterCheckbox").each(function(){i(this).prop("checked")&&e.options.filters.push(i(this).val())}),e.options.types=i('select[name="filterType[]"]').val(),this.initFullCalendar(t)},e.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())},e.prototype.getDefaultOptions=function(){var t={};"today"!==a.text("button.today")&&(t.today=a.text("button.today")),"month"!==a.text("button.month")&&(t.month=a.text("button.month")),"week"!==a.text("button.week")&&(t.week=a.text("button.week")),"day"!==a.text("button.day")&&(t.day=a.text("button.day")),"list"!==a.text("button.list")&&(t.list=a.text("button.list"));var o=this,t={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);t={data:{start:o.toJsonDateFormat(t,!1),end:o.toJsonDateFormat(e,!1),cal:1}},e=o.options.global?o.options.globalCreateUrl:o.options.editUrl;s.global.load(e,t).then(function(){s.global.$.one("hidden.bs.modal submitted",function(){o.fetch()})}).catch(function(t){s.global.close(),a.log.error(t,!0)}),o.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:i.proxy(this.select,this),eventAllow:function(){return!0},themeSystem:"bootstrap",loading:i.proxy(this.loader,this),eventResize:i.proxy(this.updateEvent,this),eventDrop:i.proxy(this.updateEvent,this),eventClick:i.proxy(this.clickEvent,this),eventRender:i.proxy(this.renderEvent,this)};return r.isSmall()&&(t.header={left:"prev,next",center:"title",right:"today"},t.footer={center:"dayGridMonth,timeGridWeek,timeGridDay,listWeek",right:"create"}),t},e.prototype.renderEvent=function(t,e){e=i(e);e.attr({title:e.text()}),t.icon&&o.startsWith(t.icon,"fa-")&&e.find(".fc-content").prepend(i(''))},e.prototype.toJsonDateFormat=function(t,e){return e?FullCalendarMoment.toMoment(t,this.fullCalendar).format("YYYY-MM-DD"):FullCalendarMoment.toMoment(t,this.fullCalendar).format()},e.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");t=this.options.global?this.options.globalCreateUrl:this.options.editUrl;s.global.load(t,o).then(function(){s.global.$.one("hidden.bs.modal submitted",function(){e.fetch()})}).catch(function(t){s.global.close(),a.log.error(t,!0)}),this.fullCalendar.unselect()},e.prototype.fetch=function(){this.fullCalendar.refetchEvents()},e.prototype.updateEvent=function(e){var o=this,t=e.event,n=t.extendedProps,t={data:{id:t.id,start:this.toJsonDateFormat(t.start,t.allDay),end:this.toJsonDateFormat(t.end,t.allDay)}};this.loader(),l.post(n.updateUrl,t).then(function(t){t.success?a.log.success("saved"):a.log.error(t,!0),n.refreshAfterUpdate&&o.fetch()}).catch(function(t){a.log.error(t,!0),e.revert()}).finally(function(){o.loader(!1)})},e.prototype.clickEvent=function(t){var e,t=t.event.extendedProps;t.viewUrl&&(e=this,"modal"===t.viewMode?s.global.load(t.viewUrl,{viewContext:"fullCalendar"}).then(function(){s.global.set({backdrop:!0}),s.global.$.one("hidden.bs.modal",function(){e.fetch()})}).catch(function(t){a.log.error(t,!0),s.global.close()}):l.pjax.redirect(t.viewUrl))},e.prototype.loader=function(t){!1===t?n.reset(i("#calendar-overview-loader")):n.set(i("#calendar-overview-loader"),{size:"8px",css:{padding:"2px ",width:"60px"}})},a.export=e}); \ No newline at end of file