aboutsummaryrefslogtreecommitdiffstats
path: root/view
diff options
context:
space:
mode:
Diffstat (limited to 'view')
-rw-r--r--view/css/cdav_calendar.css6
-rw-r--r--view/theme/redbasic/css/style.css11
-rw-r--r--view/theme/redbasic/js/redbasic.js3
-rw-r--r--view/tpl/cdav_calendar.tpl338
-rw-r--r--view/tpl/cdav_widget_calendar.tpl14
-rwxr-xr-xview/tpl/jot-header.tpl2
6 files changed, 304 insertions, 70 deletions
diff --git a/view/css/cdav_calendar.css b/view/css/cdav_calendar.css
index 2deff683c..da594b420 100644
--- a/view/css/cdav_calendar.css
+++ b/view/css/cdav_calendar.css
@@ -29,3 +29,9 @@ main.fullscreen .fc td:last-child {
.fc-list-view {
border-width: 0px;
}
+
+.bootstrap-tagsinput {
+ width: 100%;
+ padding: 6px 12px;
+}
+
diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css
index 18c3db665..3bee84378 100644
--- a/view/theme/redbasic/css/style.css
+++ b/view/theme/redbasic/css/style.css
@@ -942,17 +942,18 @@ a .generic-icons {
color: $font_colour;
}
-.generic-icons:hover,
-a .generic-icons:hover {
- color: $font_colour;
-}
-
.generic-icons-right {
font-size: 1rem;
margin-left: 0.5rem;
color: $font_colour;
}
+.generic-icons:hover,
+a .generic-icons:hover,
+.generic-icons-right:hover,
+a .generic-icons-right:hover {
+ color: $font_colour;
+}
.generic-icons-nav {
font-size: 1rem;
diff --git a/view/theme/redbasic/js/redbasic.js b/view/theme/redbasic/js/redbasic.js
index 8d3b795cc..b8e7946c2 100644
--- a/view/theme/redbasic/js/redbasic.js
+++ b/view/theme/redbasic/js/redbasic.js
@@ -21,7 +21,8 @@ $(document).ready(function() {
$('#left_aside_wrapper, #right_aside_wrapper').stick_in_parent({
offset_top: parseInt($('aside').css('padding-top')),
parent: 'main',
- spacer: '.aside_spacer'
+ spacer: '.aside_spacer',
+ recalc_every: 10
});
}
diff --git a/view/tpl/cdav_calendar.tpl b/view/tpl/cdav_calendar.tpl
index cf4542bbe..827c57b96 100644
--- a/view/tpl/cdav_calendar.tpl
+++ b/view/tpl/cdav_calendar.tpl
@@ -4,6 +4,18 @@ var new_event = {};
var new_event_id = Math.random().toString(36).substring(7);
var views = {'dayGridMonth' : '{{$month}}', 'timeGridWeek' : '{{$week}}', 'timeGridDay' : '{{$day}}', 'listMonth' : '{{$list_month}}', 'listWeek' : '{{$list_week}}', 'listDay' : '{{$list_day}}'};
+var event_id;
+var event_uri;
+
+var contact_allow = [];
+var group_allow = [];
+var contact_deny = [];
+var group_deny = [];
+
+var resource = {{$resource}};
+var default_view = resource !== null ? 'timeGridDay' : 'dayGridMonth';
+var default_date = resource !== null ? new Date(resource.dtstart) : new Date();
+
$(document).ready(function() {
var calendarEl = document.getElementById('calendar');
calendar = new FullCalendar.Calendar(calendarEl, {
@@ -21,6 +33,9 @@ $(document).ready(function() {
firstDay: {{$first_day}},
+ defaultView: default_view,
+ defaultDate: default_date,
+
monthNames: aStr['monthNames'],
monthNamesShort: aStr['monthNamesShort'],
dayNames: aStr['dayNames'],
@@ -45,7 +60,7 @@ $(document).ready(function() {
dtend.setHours(dtend.getHours() + 1);
}
- $('#event_uri').val('');
+ event_uri = '';
$('#id_title').val('New event');
$('#calendar_select').val($("#calendar_select option:first").val()).attr('disabled', false);
$('#id_dtstart').val(info.date.toUTCString());
@@ -61,15 +76,32 @@ $(document).ready(function() {
eventClick: function(info) {
+ //reset categories
+ $('#id_categories').tagsinput('removeAll');
+
var event = info.event._def;
var dtstart = new Date(info.event._instance.range.start);
var dtend = new Date(info.event._instance.range.end);
-
+
+ if(event.extendedProps.plink) {
+ if(! $('#l2s').length)
+ $('#id_title_wrapper').prepend('<span id="l2s" class="float-right"></span>');
+
+ $('#l2s').html('<a href="' + event.extendedProps.plink[0] + '" target="_blank"><i class="fa fa-external-link"></i> ' + event.extendedProps.plink[1] + '</a>');
+ }
+ else {
+ $('#l2s').remove();
+ }
+
if(event.publicId == new_event_id) {
+ $('#calendar_select').trigger('change');
+ $('#event_submit').show();
+ event_id = 0;
$(window).scrollTop(0);
$('.section-content-tools-wrapper, #event_form_wrapper').show();
$('#recurrence_warning').hide();
$('#id_title').focus().val('');
+
return false;
}
@@ -79,18 +111,29 @@ $(document).ready(function() {
new_event = {};
}
+ var calendar_id = ((event.extendedProps.calendar_id.constructor === Array) ? event.extendedProps.calendar_id[0] + ':' + event.extendedProps.calendar_id[1] : event.extendedProps.calendar_id);
+
if(!event.extendedProps.recurrent) {
$(window).scrollTop(0);
$('.section-content-tools-wrapper, #event_form_wrapper').show();
$('#recurrence_warning').hide();
- $('#event_uri').val(event.extendedProps.uri);
+ event_uri = event.extendedProps.uri;
$('#id_title').val(event.title);
- $('#calendar_select').val(event.extendedProps.calendar_id[0] + ':' + event.extendedProps.calendar_id[1]).attr('disabled', true);
+ $('#calendar_select').val(calendar_id).attr('disabled', true).trigger('change');
+ $('#id_categories').tagsinput('add', event.extendedProps.categories);
$('#id_dtstart').val(dtstart.toUTCString());
$('#id_dtend').val(dtend.toUTCString());
$('#id_description').val(event.extendedProps.description);
$('#id_location').val(event.extendedProps.location);
$('#event_submit').val('update_event').html('{{$update}}');
+ $('#dbtn-acl').addClass('d-none');
+ event_id = event.extendedProps.item ? event.extendedProps.item.id : 0;
+
+ contact_allow = event.extendedProps.contact_allow || [];
+ group_allow = event.extendedProps.group_allow || [];
+ contact_deny = event.extendedProps.contact_deny || [];
+ group_deny = event.extendedProps.group_deny || [];
+
if(event.extendedProps.rw) {
$('#event_delete').show();
$('#event_submit').show();
@@ -100,6 +143,10 @@ $(document).ready(function() {
$('#id_dtend').attr('disabled', false);
$('#id_description').attr('disabled', false);
$('#id_location').attr('disabled', false);
+
+ if(calendar_id == 'channel_calendar' && !event.ui.startEditable) {
+ $('#event_submit').hide();
+ }
}
else {
$('#event_submit').hide();
@@ -114,13 +161,13 @@ $(document).ready(function() {
else if(event.extendedProps.recurrent && event.extendedProps.rw) {
$('.section-content-tools-wrapper, #recurrence_warning').show();
$('#event_form_wrapper').hide();
- $('#event_uri').val(event.extendedProps.uri);
- $('#calendar_select').val(event.extendedProps.calendar_id[0] + ':' + event.extendedProps.calendar_id[1]).attr('disabled', true);
+ event_uri = event.extendedProps.uri;
+ $('#calendar_select').val(calendar_id).attr('disabled', true).trigger('change');
}
},
eventResize: function(info) {
-
+
var event = info.event._def;
var dtstart = new Date(info.event._instance.range.start);
var dtend = new Date(info.event._instance.range.end);
@@ -129,16 +176,41 @@ $(document).ready(function() {
$('#id_dtstart').val(dtstart.toUTCString());
$('#id_dtend').val(dtend.toUTCString());
- $.post( 'cdav/calendar', {
- 'update': 'resize',
- 'id[]': event.extendedProps.calendar_id,
- 'uri': event.extendedProps.uri,
- 'dtstart': dtstart ? dtstart.toUTCString() : '',
- 'dtend': dtend ? dtend.toUTCString() : ''
- })
- .fail(function() {
- info.revert();
- });
+ event_id = event.extendedProps.item ? event.extendedProps.item.id : 0;
+
+ if(event.extendedProps.calendar_id === 'channel_calendar') {
+ $.post( 'channel_calendar', {
+ 'event_id': event_id,
+ 'event_hash': event_uri,
+ 'xchan': '{{$channel_hash}}',
+ //'mid': mid,
+ 'type': 'event',
+ 'preview': 0,
+ 'summary': event.title,
+ 'dtstart': dtstart.toUTCString(),
+ 'dtend': dtend.toUTCString(),
+ 'adjust': event.extendedProps.item.adjust,
+ 'categories': event.extendedProps.categories,
+ 'desc': event.extendedProps.description,
+ 'location': event.extendedProps.location,
+ //'submit': $('#event_submit').val()
+ })
+ .fail(function() {
+ info.revert();
+ });
+ }
+ else {
+ $.post( 'cdav/calendar', {
+ 'update': 'resize',
+ 'id[]': event.extendedProps.calendar_id,
+ 'uri': event.extendedProps.uri,
+ 'dtstart': dtstart ? dtstart.toUTCString() : '',
+ 'dtend': dtend ? dtend.toUTCString() : ''
+ })
+ .fail(function() {
+ info.revert();
+ });
+ }
},
eventDrop: function(info) {
@@ -150,19 +222,44 @@ $(document).ready(function() {
$('#id_title').val(event.title);
$('#id_dtstart').val(dtstart.toUTCString());
$('#id_dtend').val(dtend.toUTCString());
-
- $.post( 'cdav/calendar', {
- 'update': 'drop',
- 'id[]': event.extendedProps.calendar_id,
- 'uri': event.extendedProps.uri,
- 'dtstart': dtstart ? dtstart.toUTCString() : '',
- 'dtend': dtend ? dtend.toUTCString() : ''
- })
- .fail(function() {
- info.revert();
- });
+
+ event_id = event.extendedProps.item ? event.extendedProps.item.id : 0;
+
+ if(event.extendedProps.calendar_id === 'channel_calendar') {
+ $.post( 'channel_calendar', {
+ 'event_id': event_id,
+ 'event_hash': event_uri,
+ 'xchan': '{{$channel_hash}}',
+ //'mid': mid,
+ 'type': 'event',
+ 'preview': 0,
+ 'summary': event.title,
+ 'dtstart': dtstart.toUTCString(),
+ 'dtend': dtend.toUTCString(),
+ 'adjust': event.extendedProps.item.adjust,
+ 'categories': event.extendedProps.categories,
+ 'desc': event.extendedProps.description,
+ 'location': event.extendedProps.location,
+ //'submit': $('#event_submit').val()
+ })
+ .fail(function() {
+ info.revert();
+ });
+ }
+ else {
+ $.post( 'cdav/calendar', {
+ 'update': 'drop',
+ 'id[]': event.extendedProps.calendar_id,
+ 'uri': event.extendedProps.uri,
+ 'dtstart': dtstart ? dtstart.toUTCString() : '',
+ 'dtend': dtend ? dtend.toUTCString() : ''
+ })
+ .fail(function() {
+ info.revert();
+ });
+ }
},
-
+
loading: function(isLoading, view) {
$('#events-spinner').show();
$('#today-btn > i').hide();
@@ -175,7 +272,7 @@ $(document).ready(function() {
});
calendar.render();
-
+
$('#title').text(calendar.view.title);
$('#view_selector').html(views[calendar.view.type]);
@@ -193,6 +290,13 @@ $(document).ready(function() {
calendar.next();
$('#title').text(calendar.view.title);
});
+
+ $('#calendar_select').on('change', function() {
+ if(this.value === 'channel_calendar')
+ $('#dbtn-acl, #id_categories_wrapper').removeClass('d-none');
+ else
+ $('#dbtn-acl, #id_categories_wrapper').addClass('d-none');
+ });
$('.color-edit').colorpicker({ input: '.color-edit-input' });
@@ -202,6 +306,28 @@ $(document).ready(function() {
$(document).on('click','#event_more', on_more);
$(document).on('click','#event_cancel, #event_cancel_recurrent', reset_form);
$(document).on('click','#event_delete, #event_delete_recurrent', on_delete);
+
+ if(resource !== null) {
+ $('.section-content-tools-wrapper, #event_form_wrapper').show();
+
+ $('#id_title_wrapper').prepend('<span id="l2s" class="float-right"></span>');
+ $('#l2s').html('<a href="' + resource.plink[0] + '" target="_blank"><i class="fa fa-external-link"></i> ' + resource.plink[1] + '</a>');
+
+ event_id = resource.id;
+ event_uri = resource.event_hash;
+ $('#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_categories').tagsinput('add', '{{$categories}}'),
+ $('#id_description').val(resource.description);
+ $('#id_location').val(resource.location);
+
+ if(resource.event_xchan !== '{{$channel_hash}}')
+ $('#event_submit').hide();
+ else
+ $('#event_submit').html('{{$update}}');
+ }
});
@@ -213,9 +339,16 @@ function changeView(action, viewName) {
}
function add_remove_json_source(source, color, editable, status) {
- var parts = source.split('/');
- var id = parts[4];
-
+ var id, parts = [];
+
+ if(source == '/channel_calendar/json')
+ id = 'channel_calendar'
+
+ if(! id) {
+ parts = source.split('/');
+ id = parts[4];
+ }
+
var eventSource = calendar.getEventSourceById(id);
var selector = '#calendar-btn-' + id;
@@ -247,37 +380,93 @@ function updateSize() {
}
function on_submit() {
- $.post( 'cdav/calendar', {
- 'submit': $('#event_submit').val(),
- 'target': $('#calendar_select').val(),
- 'uri': $('#event_uri').val(),
- 'title': $('#id_title').val(),
- 'dtstart': $('#id_dtstart').val(),
- 'dtend': $('#id_dtend').val(),
- 'description': $('#id_description').val(),
- 'location': $('#id_location').val()
- })
- .done(function() {
- var parts = $('#calendar_select').val().split(':');
- var eventSource = calendar.getEventSourceById(parts[0]);
- eventSource.refetch();
- reset_form();
+ if($('#calendar_select').val() == 'channel_calendar') {
+ if(new_event_id) {
+ $("input[name='contact_allow[]']").each(function() {
+ contact_allow.push($(this).val());
+ });
+ $("input[name='group_allow[]']").each(function() {
+ group_allow.push($(this).val());
+ });
+ $("input[name='contact_deny[]']").each(function() {
+ contact_deny.push($(this).val());
+ });
+ $("input[name='group_deny[]']").each(function() {
+ group_deny.push($(this).val());
+ });
+ }
- });
+ $.post( 'channel_calendar', {
+ 'event_id': event_id,
+ 'event_hash': event_uri,
+ 'xchan': '{{$channel_hash}}',
+ //'mid': mid,
+ 'type': 'event',
+ 'preview': 0,
+ 'summary': $('#id_title').val(),
+ 'dtstart': $('#id_dtstart').val(),
+ 'dtend': $('#id_dtend').val(),
+ 'adjust': 0,
+ 'categories': $('#id_categories').val(),
+ 'desc': $('#id_description').val(),
+ 'location': $('#id_location').val(),
+ //'submit': $('#event_submit').val(),
+ 'contact_allow[]': contact_allow,
+ 'group_allow[]': group_allow,
+ 'contact_deny[]': contact_deny,
+ 'group_deny[]': group_deny
+
+ })
+ .done(function() {
+ var eventSource = calendar.getEventSourceById('channel_calendar');
+ eventSource.refetch();
+ reset_form();
+
+ });
+
+ }
+ else {
+ $.post( 'cdav/calendar', {
+ 'submit': $('#event_submit').val(),
+ 'target': $('#calendar_select').val(),
+ 'uri': event_uri,
+ 'title': $('#id_title').val(),
+ 'dtstart': $('#id_dtstart').val(),
+ 'dtend': $('#id_dtend').val(),
+ 'description': $('#id_description').val(),
+ 'location': $('#id_location').val()
+ })
+ .done(function() {
+ var parts = $('#calendar_select').val().split(':');
+ var eventSource = calendar.getEventSourceById(parts[0]);
+ eventSource.refetch();
+ reset_form();
+
+ });
+ }
}
function on_delete() {
- $.post( 'cdav/calendar', {
- 'delete': 'delete',
- 'target': $('#calendar_select').val(),
- 'uri': $('#event_uri').val(),
- })
- .done(function() {
- var parts = $('#calendar_select').val().split(':');
- var eventSource = calendar.getEventSourceById(parts[0]);
- eventSource.refetch();
- reset_form();
- });
+ if($('#calendar_select').val() == 'channel_calendar') {
+ $.get('channel_calendar/drop/' + event_uri, function() {
+ var eventSource = calendar.getEventSourceById('channel_calendar');
+ eventSource.refetch();
+ reset_form();
+ });
+ }
+ else {
+ $.post( 'cdav/calendar', {
+ 'delete': 'delete',
+ 'target': $('#calendar_select').val(),
+ 'uri': event_uri
+ })
+ .done(function() {
+ var parts = $('#calendar_select').val().split(':');
+ var eventSource = calendar.getEventSourceById(parts[0]);
+ eventSource.refetch();
+ reset_form();
+ });
+ }
}
function reset_form() {
@@ -285,8 +474,9 @@ function reset_form() {
$('#event_submit').val('');
$('#calendar_select').val('');
- $('#event_uri').val('');
+ event_uri = '';
$('#id_title').val('');
+ $('#id_categories').tagsinput('removeAll');
$('#id_dtstart').val('');
$('#id_dtend').val('');
@@ -311,6 +501,14 @@ function on_more() {
}
}
+function exportDate() {
+ alert('not implemented');
+ console.log('not implemented');
+ //var moment = $('#events-calendar').fullCalendar('getDate');
+ //var sT = 'events/' + moment.year() + '/' + (moment.month() + 1) + '/export';
+ //window.location.href=sT;
+}
+
</script>
<div class="generic-content-wrapper">
@@ -350,16 +548,28 @@ function on_more() {
</div>
</div>
<div id="event_form_wrapper" style="display: none">
- <form id="event_form" method="post" action="">
- <input id="event_uri" type="hidden" name="uri" value="">
+ <form id="event_form" method="post" action="" class="acl-form" data-form_id="event_form" data-allow_cid='{{$allow_cid}}' data-allow_gid='{{$allow_gid}}' data-deny_cid='{{$deny_cid}}' data-deny_gid='{{$deny_gid}}'>
{{include file="field_input.tpl" field=$title}}
<label for="calendar_select">{{$calendar_select_label}}</label>
<select id="calendar_select" name="target" class="form-control form-group">
+ <optgroup label="{{$calendar_optiopns_label.0}}">
+ {{foreach $channel_calendars as $channel_calendar}}
+ <option value="channel_calendar">{{$channel_calendar.displayname}}</option>
+ {{/foreach}}
+ </optgroup>
+ <optgroup label="{{$calendar_optiopns_label.1}}">
{{foreach $writable_calendars as $writable_calendar}}
<option value="{{$writable_calendar.id.0}}:{{$writable_calendar.id.1}}">{{$writable_calendar.displayname}}{{if $writable_calendar.sharer}} ({{$writable_calendar.sharer}}){{/if}}</option>
{{/foreach}}
+ </optgroup>
</select>
<div id="more_block" style="display: none;">
+ {{if $catsenabled}}
+ <div id="id_categories_wrapper" class="form-group">
+ <label id="label_categories" for="id_categories">{{$categories_label}}</label>
+ <input name="categories" id="id_categories" class="form-control" type="text" value="{{$categories}}" data-role="cat-tagsinput" />
+ </div>
+ {{/if}}
{{include file="field_input.tpl" field=$dtstart}}
{{include file="field_input.tpl" field=$dtend}}
{{include file="field_textarea.tpl" field=$description}}
@@ -368,6 +578,7 @@ function on_more() {
<div class="form-group">
<div class="pull-right">
<button id="event_more" type="button" class="btn btn-outline-secondary btn-sm"><i class="fa fa-caret-down"></i> {{$more}}</button>
+ <button id="dbtn-acl" class="btn btn-outline-secondary btn-sm d-none" type="button" data-toggle="modal" data-target="#aclModal"><i id="jot-perms-icon" class="fa fa-{{$lockstate}}"></i></button>
<button id="event_submit" type="button" value="" class="btn btn-primary btn-sm"></button>
</div>
@@ -378,6 +589,7 @@ function on_more() {
<div class="clear"></div>
</div>
</form>
+ {{$acl}}
</div>
</div>
<div class="section-content-wrapper-np">
diff --git a/view/tpl/cdav_widget_calendar.tpl b/view/tpl/cdav_widget_calendar.tpl
index 8d6414ec6..a538cd26d 100644
--- a/view/tpl/cdav_widget_calendar.tpl
+++ b/view/tpl/cdav_widget_calendar.tpl
@@ -1,3 +1,17 @@
+<div class="widget">
+ <h3>{{$channel_calendars_label}}</h3>
+ {{foreach $channel_calendars as $channel_calendar}}
+ <div id="calendar-{{$channel_calendar.calendarid}}">
+ <div class="ml-3{{if !$channel_calendar@last}} form-group{{/if}}">
+ <i id="calendar-btn-{{$channel_calendar.calendarid}}" class="fa {{if $channel_calendar.switch}}fa-calendar-check-o{{else}}fa-calendar-o{{/if}} generic-icons fakelink" onclick="add_remove_json_source('{{$channel_calendar.json_source}}', '{{$channel_calendar.color}}', {{$channel_calendar.editable}})" style="color: {{$channel_calendar.color}};"></i>{{$channel_calendar.displayname}}
+ <div class="float-right">
+ <a href="#" onclick="exportDate(); return false;"><i id="download-icon" class="fa fa-cloud-download fakelink generic-icons-right"></i></a>
+ </div>
+ </div>
+ </div>
+ {{/foreach}}
+</div>
+
{{if $my_calendars}}
<div class="widget">
<h3>{{$my_calendars_label}}</h3>
diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl
index afaaa62d9..7b1f4ee05 100755
--- a/view/tpl/jot-header.tpl
+++ b/view/tpl/jot-header.tpl
@@ -354,7 +354,7 @@ var activeCommentText = '';
}
function itemAddToCal(id) {
- $.get('{{$baseurl}}/events/add/' + id);
+ $.get('{{$baseurl}}/channel_calendar/add/' + id);
if(timer) clearTimeout(timer);
timer = setTimeout(updateInit,1000);
}