aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-04-30 00:09:57 +0200
committerMario Vavti <mario@mariovavti.com>2019-04-30 00:09:57 +0200
commit327e5d06e12b3ddad0a83a223c1673a4d0dafb15 (patch)
treed5ae844d7f1498e1552df4cd4ffd4df00b30815b
parent674215e9e6632ac22a1b87f9996f0323f5949d94 (diff)
downloadvolse-hubzilla-327e5d06e12b3ddad0a83a223c1673a4d0dafb15.tar.gz
volse-hubzilla-327e5d06e12b3ddad0a83a223c1673a4d0dafb15.tar.bz2
volse-hubzilla-327e5d06e12b3ddad0a83a223c1673a4d0dafb15.zip
calendar merge: implement single event editing UI
-rw-r--r--Zotlabs/Module/Cdav.php44
-rw-r--r--Zotlabs/Module/Channel_calendar.php1
-rw-r--r--Zotlabs/Module/Editpost.php2
-rw-r--r--Zotlabs/Widget/Cdav.php2
-rw-r--r--view/tpl/cdav_calendar.tpl30
5 files changed, 71 insertions, 8 deletions
diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php
index 8985e257a..ce5b777f5 100644
--- a/Zotlabs/Module/Cdav.php
+++ b/Zotlabs/Module/Cdav.php
@@ -890,7 +890,7 @@ class Cdav extends Controller {
}
//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/daygrid/main.min.css');
@@ -905,6 +905,43 @@ class Cdav extends Controller {
head_add_js('/library/fullcalendar/packages/list/main.min.js');
$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')) {
$sources .= '{
@@ -1005,7 +1042,10 @@ class Cdav extends Controller {
'$deny_cid' => acl2json($permissions['deny_cid']),
'$deny_gid' => acl2json($permissions['deny_gid']),
'$catsenabled' => $catsenabled,
- '$categories_label' => t('Categories')
+ '$categories_label' => t('Categories'),
+
+ '$resource' => json_encode($resource),
+ '$categories' => $categories
]);
return $o;
diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php
index ee7c722c3..538951d32 100644
--- a/Zotlabs/Module/Channel_calendar.php
+++ b/Zotlabs/Module/Channel_calendar.php
@@ -565,6 +565,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
'd' => $d,
'editable' => $edit ? true : false,
+ 'className' => 'channel_calendar_id_' . $rr['id'],
'is_first'=>$is_first,
'item'=>$rr,
diff --git a/Zotlabs/Module/Editpost.php b/Zotlabs/Module/Editpost.php
index 85882bf0a..77f139467 100644
--- a/Zotlabs/Module/Editpost.php
+++ b/Zotlabs/Module/Editpost.php
@@ -45,7 +45,7 @@ class Editpost extends \Zotlabs\Web\Controller {
}
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');
}
diff --git a/Zotlabs/Widget/Cdav.php b/Zotlabs/Widget/Cdav.php
index c88530c0b..20c70903f 100644
--- a/Zotlabs/Widget/Cdav.php
+++ b/Zotlabs/Widget/Cdav.php
@@ -22,7 +22,7 @@ class Cdav {
$o = '';
- if(argc() == 2 && argv(1) === 'calendar') {
+ if(argc() <= 3 && argv(1) === 'calendar') {
$caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo);
diff --git a/view/tpl/cdav_calendar.tpl b/view/tpl/cdav_calendar.tpl
index dd0f3ff7b..a86b61d3b 100644
--- a/view/tpl/cdav_calendar.tpl
+++ b/view/tpl/cdav_calendar.tpl
@@ -12,6 +12,10 @@ 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, {
@@ -29,6 +33,9 @@ $(document).ready(function() {
firstDay: {{$first_day}},
+ defaultView: default_view,
+ defaultDate: default_date,
+
monthNames: aStr['monthNames'],
monthNamesShort: aStr['monthNamesShort'],
dayNames: aStr['dayNames'],
@@ -69,8 +76,6 @@ $(document).ready(function() {
eventClick: function(info) {
-
-
//reset categories
$('#id_categories').tagsinput('removeAll');
@@ -254,7 +259,7 @@ $(document).ready(function() {
});
}
},
-
+
loading: function(isLoading, view) {
$('#events-spinner').show();
$('#today-btn > i').hide();
@@ -267,7 +272,7 @@ $(document).ready(function() {
});
calendar.render();
-
+
$('#title').text(calendar.view.title);
$('#view_selector').html(views[calendar.view.type]);
@@ -301,6 +306,23 @@ $(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) {
+
+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}}');
+ }
});