From 5e9cace2bc014a4543de45fc064f83a113a17862 Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 13 Dec 2018 14:35:26 -0700 Subject: [PATCH] * Calendar - Quick add dialog for new events --- calendar/inc/class.calendar_hooks.inc.php | 19 +++++++++++ calendar/inc/class.calendar_uiforms.inc.php | 15 +++++++++ calendar/js/app.js | 10 ++++-- calendar/templates/default/add.xet | 37 +++++++++++++++++++++ 4 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 calendar/templates/default/add.xet diff --git a/calendar/inc/class.calendar_hooks.inc.php b/calendar/inc/class.calendar_hooks.inc.php index dfb9b13e6e..ca8960c7fd 100644 --- a/calendar/inc/class.calendar_hooks.inc.php +++ b/calendar/inc/class.calendar_hooks.inc.php @@ -45,6 +45,7 @@ class calendar_hooks ), 'add' => array( 'menuaction' => 'calendar.calendar_uiforms.edit', + 'template' => 'calendar.add' ), 'add_app' => 'link_app', 'add_id' => 'link_id', @@ -243,6 +244,14 @@ class calendar_hooks 'admin' => False, 'default'=> '1', // 1 = week ),*/ + 'new_event_dialog' => array( + 'type' => 'select', + 'label' => 'New event dialog', + 'name' => 'new_event_dialog', + 'values'=> array('add' => lang('Quick add'), 'edit' => lang('Regular edit')), + 'help' => 'Use quick add or full edit dialog when creating a new event', + 'default' => 'add', + ), 'multiple_weeks' => array( 'type' => 'select', 'label' => 'Weeks in multiple week view', @@ -354,6 +363,16 @@ class calendar_hooks 'xmlrpc' => False, 'admin' => False ), + 'default_category' => array( + 'type' => 'multiselect', + 'label' => 'New event category', + 'name' => 'default_category', + 'help' => 'Category automatically added to new events', + 'values' => Api\Etemplate\Widget\Select::typeOptions('select-cat', ',,,calendar'), + 'default' => '', + 'xmlrpc' => False, + 'admin' => False + ), 'default-alarm' => array( 'type' => 'date-duration',//'select', 'label' => lang('Default alarm for regular events').' ('.lang('empty = no alarm').')', diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index ccf632a191..5b3d6102fc 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -208,6 +208,10 @@ class calendar_uiforms extends calendar_ui $cat = (int)$cat; } } + else + { + $cat_id = $this->cal_prefs['default_category']; + } $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int) $this->bo->cal_prefs['defaultlength']*60; if(isset($_GET['end'])) { @@ -635,6 +639,11 @@ class calendar_uiforms extends calendar_ui case 'exception': // create an exception in a recuring event $msg = $this->_create_exception($event,$preserv); break; + case 'edit': + // Going from add dialog to full edit dialog + unset($preserv['template']); + unset($event['template']); + break; case 'copy': // create new event with copied content, some content need to be unset to make a "new" event unset($event['id']); @@ -1478,6 +1487,12 @@ class calendar_uiforms extends calendar_ui 'no_popup' => isset($_GET['no_popup']), 'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'), ); + if($preserv['template'] && ($registry = Link::get_registry('calendar', 'add')) && $registry['template'] == $preserv['template'] && + $this->cal_prefs['new_event_dialog'] == 'edit') + { + // User wants full thing + unset($preserv['template']); + } $cal_id = (int) $_GET['cal_id']; if($_GET['action']) { diff --git a/calendar/js/app.js b/calendar/js/app.js index 7151dc0249..a39172c4e6 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -215,6 +215,7 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( this.state = content.data; break; + case 'calendar.add': case 'calendar.edit': if (typeof content.data['conflicts'] == 'undefined') { @@ -223,9 +224,12 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( { this.set_enddate_visibility(); this.check_recur_type(); - this.edit_start_change(); - this.et2.getWidgetById('recur_exception').set_disabled(!content.data.recur_exception || - typeof content.data.recur_exception[0] == 'undefined'); + this.edit_start_change(null, this.et2.getWidgetById('start')); + if(this.et2.getWidgetById('recur_exception')) + { + this.et2.getWidgetById('recur_exception').set_disabled(!content.data.recur_exception || + typeof content.data.recur_exception[0] == 'undefined'); + } } else { diff --git a/calendar/templates/default/add.xet b/calendar/templates/default/add.xet new file mode 100644 index 0000000000..84f0491fc6 --- /dev/null +++ b/calendar/templates/default/add.xet @@ -0,0 +1,37 @@ + + + + + +