Commit 327e5d06 authored by Mario's avatar Mario

calendar merge: implement single event editing UI

parent 674215e9
Pipeline #131032 passed with stage
in 3 minutes and 25 seconds
...@@ -890,7 +890,7 @@ class Cdav extends Controller { ...@@ -890,7 +890,7 @@ class Cdav extends Controller {
} }
//Display calendar(s) here //Display calendar(s) here
if(argc() == 2 && argv(1) === 'calendar') { if(argc() <= 3 && argv(1) === 'calendar') {
head_add_css('/library/fullcalendar/packages/core/main.min.css'); head_add_css('/library/fullcalendar/packages/core/main.min.css');
head_add_css('/library/fullcalendar/packages/daygrid/main.min.css'); head_add_css('/library/fullcalendar/packages/daygrid/main.min.css');
...@@ -905,6 +905,43 @@ class Cdav extends Controller { ...@@ -905,6 +905,43 @@ class Cdav extends Controller {
head_add_js('/library/fullcalendar/packages/list/main.min.js'); head_add_js('/library/fullcalendar/packages/list/main.min.js');
$sources = ''; $sources = '';
$iid = '';
$resource = null;
if(argc() == 3 && intval(argv(2)))
$iid = argv(2);
if($iid) {
$r = q("SELECT event.*, item.author_xchan, item.owner_xchan, item.id as item_id FROM item LEFT JOIN event ON item.resource_id = event.event_hash
WHERE item.id = %d AND item.uid = %d LIMIT 1",
dbesc($iid),
intval(local_channel())
);
if($r) {
xchan_query($r);
$r = fetch_post_tags($r,true);
$r[0]['dtstart'] = (($r[0]['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$r[0]['dtstart'], 'c') : datetime_convert('UTC','UTC',$r[0]['dtstart'],'c'));
$r[0]['dtend'] = (($r[0]['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$r[0]['dtend'], 'c') : datetime_convert('UTC','UTC',$r[0]['dtend'],'c'));
$resource = $r[0];
$catsenabled = feature_enabled(local_channel(),'categories');
$categories = '';
if($catsenabled){
if($r[0]['term']) {
$cats = get_terms_oftype($r[0]['term'], TERM_CATEGORY);
foreach ($cats as $cat) {
if(strlen($categories))
$categories .= ', ';
$categories .= $cat['term'];
}
}
}
}
}
if(get_pconfig(local_channel(), 'cdav_calendar', 'channel_calendar')) { if(get_pconfig(local_channel(), 'cdav_calendar', 'channel_calendar')) {
$sources .= '{ $sources .= '{
...@@ -1005,7 +1042,10 @@ class Cdav extends Controller { ...@@ -1005,7 +1042,10 @@ class Cdav extends Controller {
'$deny_cid' => acl2json($permissions['deny_cid']), '$deny_cid' => acl2json($permissions['deny_cid']),
'$deny_gid' => acl2json($permissions['deny_gid']), '$deny_gid' => acl2json($permissions['deny_gid']),
'$catsenabled' => $catsenabled, '$catsenabled' => $catsenabled,
'$categories_label' => t('Categories') '$categories_label' => t('Categories'),
'$resource' => json_encode($resource),
'$categories' => $categories
]); ]);
return $o; return $o;
......
...@@ -565,6 +565,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller { ...@@ -565,6 +565,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
'd' => $d, 'd' => $d,
'editable' => $edit ? true : false, 'editable' => $edit ? true : false,
'className' => 'channel_calendar_id_' . $rr['id'],
'is_first'=>$is_first, 'is_first'=>$is_first,
'item'=>$rr, 'item'=>$rr,
......
...@@ -45,7 +45,7 @@ class Editpost extends \Zotlabs\Web\Controller { ...@@ -45,7 +45,7 @@ class Editpost extends \Zotlabs\Web\Controller {
} }
if($itm[0]['resource_type'] === 'event' && $itm[0]['resource_id']) { if($itm[0]['resource_type'] === 'event' && $itm[0]['resource_id']) {
goaway(z_root() . '/cdav/calendar'); goaway(z_root() . '/cdav/calendar/' . $itm[0]['id']);
//goaway(z_root() . '/events/' . $itm[0]['resource_id'] . '?expandform=1'); //goaway(z_root() . '/events/' . $itm[0]['resource_id'] . '?expandform=1');
} }
......
...@@ -22,7 +22,7 @@ class Cdav { ...@@ -22,7 +22,7 @@ class Cdav {
$o = ''; $o = '';
if(argc() == 2 && argv(1) === 'calendar') { if(argc() <= 3 && argv(1) === 'calendar') {
$caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo); $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo);
......
...@@ -12,6 +12,10 @@ var group_allow = []; ...@@ -12,6 +12,10 @@ var group_allow = [];
var contact_deny = []; var contact_deny = [];
var group_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() { $(document).ready(function() {
var calendarEl = document.getElementById('calendar'); var calendarEl = document.getElementById('calendar');
calendar = new FullCalendar.Calendar(calendarEl, { calendar = new FullCalendar.Calendar(calendarEl, {
...@@ -29,6 +33,9 @@ $(document).ready(function() { ...@@ -29,6 +33,9 @@ $(document).ready(function() {
firstDay: {{$first_day}}, firstDay: {{$first_day}},
defaultView: default_view,
defaultDate: default_date,
monthNames: aStr['monthNames'], monthNames: aStr['monthNames'],
monthNamesShort: aStr['monthNamesShort'], monthNamesShort: aStr['monthNamesShort'],
dayNames: aStr['dayNames'], dayNames: aStr['dayNames'],
...@@ -69,8 +76,6 @@ $(document).ready(function() { ...@@ -69,8 +76,6 @@ $(document).ready(function() {
eventClick: function(info) { eventClick: function(info) {
//reset categories //reset categories
$('#id_categories').tagsinput('removeAll'); $('#id_categories').tagsinput('removeAll');
...@@ -254,7 +259,7 @@ $(document).ready(function() { ...@@ -254,7 +259,7 @@ $(document).ready(function() {
}); });
} }
}, },
loading: function(isLoading, view) { loading: function(isLoading, view) {
$('#events-spinner').show(); $('#events-spinner').show();
$('#today-btn > i').hide(); $('#today-btn > i').hide();
...@@ -267,7 +272,7 @@ $(document).ready(function() { ...@@ -267,7 +272,7 @@ $(document).ready(function() {
}); });
calendar.render(); calendar.render();
$('#title').text(calendar.view.title); $('#title').text(calendar.view.title);
$('#view_selector').html(views[calendar.view.type]); $('#view_selector').html(views[calendar.view.type]);
...@@ -301,6 +306,23 @@ $(document).ready(function() { ...@@ -301,6 +306,23 @@ $(document).ready(function() {
$(document).on('click','#event_more', on_more); $(document).on('click','#event_more', on_more);
$(document).on('click','#event_cancel, #event_cancel_recurrent', reset_form); $(document).on('click','#event_cancel, #event_cancel_recurrent', reset_form);
$(document).on('click','#event_delete, #event_delete_recurrent', on_delete); $(document).on('click','#event_delete, #event_delete_recurrent', on_delete);
if(resource !== null) {
console.log('{{$categories}}');
console.log(resource);
$('.section-content-tools-wrapper, #event_form_wrapper').show();
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);
$('#event_submit').html('{{$update}}');
}
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment