diff options
Diffstat (limited to 'view')
-rw-r--r-- | view/tpl/cdav_calendar.tpl | 95 | ||||
-rw-r--r-- | view/tpl/field_select_grouped.tpl | 2 |
2 files changed, 68 insertions, 29 deletions
diff --git a/view/tpl/cdav_calendar.tpl b/view/tpl/cdav_calendar.tpl index 083c7cea3..01739dd5b 100644 --- a/view/tpl/cdav_calendar.tpl +++ b/view/tpl/cdav_calendar.tpl @@ -39,13 +39,26 @@ $(document).ready(function() { defaultView: default_view, defaultDate: default_date, + weekNumbers: true, + navLinks: true, + + navLinkDayClick: function(date, jsEvent) { + calendar.gotoDate( date ); + changeView('timeGridDay'); + }, + + navLinkWeekClick: function(date, jsEvent) { + calendar.gotoDate( date ); + changeView('timeGridWeek'); + }, + monthNames: aStr['monthNames'], monthNamesShort: aStr['monthNamesShort'], dayNames: aStr['dayNames'], dayNamesShort: aStr['dayNamesShort'], allDayText: aStr['allday'], - snapDuration: '00:15:00', + snapDuration: '00:05:00', dateClick: function(info) { if(new_event.id) { @@ -56,6 +69,14 @@ $(document).ready(function() { allday = info.allDay; + if(allday) { + $('#id_dtstart_wrapper, #id_dtend_wrapper, #id_timezone_select_wrapper').hide(); + } + else { + $('#id_dtstart_wrapper, #id_dtend_wrapper, #id_timezone_select_wrapper').show(); + } + + var dtend = new Date(info.date.toUTCString()); if(allday) { dtend.setDate(dtend.getDate() + 1); @@ -72,14 +93,14 @@ $(document).ready(function() { $('#id_description').attr('disabled', false); $('#id_location').attr('disabled', false); $('#calendar_select').val($("#calendar_select option:first").val()).attr('disabled', false); - $('#id_dtstart').val(info.date.toUTCString()); - $('#id_dtend').val(dtend ? dtend.toUTCString() : ''); + $('#id_dtstart').val(info.date.toUTCString().slice(0, -4)); + $('#id_dtend').val(dtend ? dtend.toUTCString().slice(0, -4) : ''); $('#id_description').val(''); $('#id_location').val(''); $('#event_submit').val('create_event').html('{{$create}}'); $('#event_delete').hide(); - new_event = { id: new_event_id, title: 'New event', start: $('#id_dtstart').val(), end: $('#id_dtend').val(), allDay: info.allDay, editable: true, color: '#bbb' }; + new_event = { id: new_event_id, title: 'New event', start: info.date.toUTCString(), end: dtend ? dtend.toUTCString() : '', allDay: info.allDay, editable: true, color: '#bbb' }; calendar.addEvent(new_event); }, @@ -101,6 +122,13 @@ $(document).ready(function() { $('#l2s').remove(); } + if(event.allDay) { + $('#id_dtstart_wrapper, #id_dtend_wrapper, #id_timezone_select_wrapper').hide(); + } + else { + $('#id_dtstart_wrapper, #id_dtend_wrapper, #id_timezone_select_wrapper').show(); + } + if(event.publicId == new_event_id) { $('#calendar_select').trigger('change'); $('#event_submit').show(); @@ -136,8 +164,8 @@ $(document).ready(function() { $('#id_timezone_select').val(event.extendedProps.timezone); $('#id_location').val(event.extendedProps.location); $('#id_categories').tagsinput('add', event.extendedProps.categories); - $('#id_dtstart').val(dtstart.toUTCString()); - $('#id_dtend').val(dtend.toUTCString()); + $('#id_dtstart').val(dtstart.toUTCString().slice(0, -4)); + $('#id_dtend').val(dtend.toUTCString().slice(0, -4)); $('#id_description').val(event.extendedProps.description); $('#id_location').val(event.extendedProps.location); $('#event_submit').val('update_event').html('{{$update}}'); @@ -183,15 +211,14 @@ $(document).ready(function() { }, eventResize: function(info) { - console.log(info); var event = info.event._def; var dtstart = new Date(info.event._instance.range.start); var dtend = new Date(info.event._instance.range.end); $('#id_title').val(event.title); - $('#id_dtstart').val(dtstart.toUTCString()); - $('#id_dtend').val(dtend.toUTCString()); + $('#id_dtstart').val(dtstart.toUTCString().slice(0, -4)); + $('#id_dtend').val(dtend.toUTCString().slice(0, -4)); event_id = event.extendedProps.item ? event.extendedProps.item.id : 0; event_xchan = event.extendedProps.item ? event.extendedProps.item.event_xchan : ''; @@ -205,8 +232,8 @@ $(document).ready(function() { 'preview': 0, 'summary': event.title, 'timezone_select': event.extendedProps.timezone, - 'dtstart': dtstart.toUTCString(), - 'dtend': dtend.toUTCString(), + 'dtstart': dtstart.toUTCString().slice(0, -4), + 'dtend': dtend.toUTCString().slice(0, -4), 'adjust': event.allDay ? 0 : 1, 'categories': event.extendedProps.categories, 'desc': event.extendedProps.description, @@ -222,8 +249,8 @@ $(document).ready(function() { 'id[]': event.extendedProps.calendar_id, 'uri': event.extendedProps.uri, 'timezone_select': event.extendedProps.timezone, - 'dtstart': dtstart ? dtstart.toUTCString() : '', - 'dtend': dtend ? dtend.toUTCString() : '', + 'dtstart': dtstart ? dtstart.toUTCString().slice(0, -4) : '', + 'dtend': dtend ? dtend.toUTCString().slice(0, -4) : '', 'allday': event.allDay ? 1 : 0 }) .fail(function() { @@ -239,8 +266,8 @@ $(document).ready(function() { var dtend = new Date(info.event._instance.range.end); $('#id_title').val(event.title); - $('#id_dtstart').val(dtstart.toUTCString()); - $('#id_dtend').val(dtend.toUTCString()); + $('#id_dtstart').val(dtstart.toUTCString().slice(0, -4)); + $('#id_dtend').val(dtend.toUTCString().slice(0, -4)); event_id = event.extendedProps.item ? event.extendedProps.item.id : 0; event_xchan = event.extendedProps.item ? event.extendedProps.item.event_xchan : ''; @@ -254,8 +281,8 @@ $(document).ready(function() { 'preview': 0, 'summary': event.title, 'timezone_select': event.extendedProps.timezone, - 'dtstart': dtstart.toUTCString(), - 'dtend': dtend.toUTCString(), + 'dtstart': dtstart.toUTCString().slice(0, -4), + 'dtend': dtend.toUTCString().slice(0, -4), 'adjust': event.allDay ? 0 : 1, 'categories': event.extendedProps.categories, 'desc': event.extendedProps.description, @@ -271,8 +298,8 @@ $(document).ready(function() { 'id[]': event.extendedProps.calendar_id, 'uri': event.extendedProps.uri, 'timezone_select': event.extendedProps.timezone, - 'dtstart': dtstart ? dtstart.toUTCString() : '', - 'dtend': dtend ? dtend.toUTCString() : '', + 'dtstart': dtstart ? dtstart.toUTCString().slice(0, -4) : '', + 'dtend': dtend ? dtend.toUTCString().slice(0, -4) : '', 'allday': event.allDay ? 1 : 0 }) .fail(function() { @@ -340,8 +367,8 @@ $(document).ready(function() { $('#calendar_select').val('channel_calendar').attr('disabled', true); $('#id_title').val(resource.summary); - $('#id_dtstart').val(new Date(resource.dtstart).toUTCString()); - $('#id_dtend').val(new Date(resource.dtend).toUTCString()); + $('#id_dtstart').val(new Date(resource.dtstart).toUTCString().slice(0, -4)); + $('#id_dtend').val(new Date(resource.dtend).toUTCString().slice(0, -4)); $('#id_categories').tagsinput('add', '{{$categories}}'), $('#id_description').val(resource.description); $('#id_location').val(resource.location); @@ -352,13 +379,25 @@ $(document).ready(function() { else $('#event_submit').html('{{$update}}'); } + + if(default_view === 'dayGridMonth'); + $('#id_dtstart_wrapper, #id_dtend_wrapper, #id_timezone_select_wrapper').hide(); }); -function changeView(action, viewName) { +function changeView(viewName) { + calendar.changeView(viewName); $('#title').text(calendar.view.title); $('#view_selector').html(views[calendar.view.type]); + + if(viewName === 'dayGridMonth') { + $('#id_dtstart_wrapper, #id_dtend_wrapper, #id_timezone_select_wrapper').hide(); + } + else { + $('#id_dtstart_wrapper, #id_dtend_wrapper, #id_timezone_select_wrapper').show(); + } + return; } @@ -538,13 +577,13 @@ function exportDate() { <div class="dropdown"> <button id="view_selector" type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown"></button> <div class="dropdown-menu"> - <a class="dropdown-item" href="#" onclick="changeView('changeView', 'dayGridMonth'); return false;">{{$month}}</a></li> - <a class="dropdown-item" href="#" onclick="changeView('changeView', 'timeGridWeek'); return false;">{{$week}}</a></li> - <a class="dropdown-item" href="#" onclick="changeView('changeView', 'timeGridDay'); return false;">{{$day}}</a></li> + <a class="dropdown-item" href="#" onclick="changeView('dayGridMonth'); return false;">{{$month}}</a></li> + <a class="dropdown-item" href="#" onclick="changeView('timeGridWeek'); return false;">{{$week}}</a></li> + <a class="dropdown-item" href="#" onclick="changeView('timeGridDay'); return false;">{{$day}}</a></li> <div class="dropdown-divider"></div> - <a class="dropdown-item" href="#" onclick="changeView('changeView', 'listMonth'); return false;">{{$list_month}}</a></li> - <a class="dropdown-item" href="#" onclick="changeView('changeView', 'listWeek'); return false;">{{$list_week}}</a></li> - <a class="dropdown-item" href="#" onclick="changeView('changeView', 'listDay'); return false;">{{$list_day}}</a></li> + <a class="dropdown-item" href="#" onclick="changeView('listMonth'); return false;">{{$list_month}}</a></li> + <a class="dropdown-item" href="#" onclick="changeView('listWeek'); return false;">{{$list_week}}</a></li> + <a class="dropdown-item" href="#" onclick="changeView('listDay'); return false;">{{$list_day}}</a></li> </div> <div class="btn-group"> <button id="prev-btn" class="btn btn-outline-secondary btn-sm" title="{{$prev}}"><i class="fa fa-backward"></i></button> diff --git a/view/tpl/field_select_grouped.tpl b/view/tpl/field_select_grouped.tpl index e6d1479de..ec067b8e7 100644 --- a/view/tpl/field_select_grouped.tpl +++ b/view/tpl/field_select_grouped.tpl @@ -1,4 +1,4 @@ - <div class='form-group field select'> + <div id='id_{{$field.0}}_wrapper' class='form-group field select'> <label for='id_{{$field.0}}'>{{$field.1}}</label> <select class="form-control" name='{{$field.0}}' id='id_{{$field.0}}'> {{foreach $field.4 as $group=>$opts}} |