From cd76cccf8b945088c9c8f45ab2058b5602b95b29 Mon Sep 17 00:00:00 2001 From: nathangray Date: Mon, 17 Jun 2019 10:24:36 -0600 Subject: [PATCH] *Calendar - Quick add dialog now shows conflict warning instead of quietly stopping --- calendar/inc/class.calendar_uiforms.inc.php | 27 +++++++++++++++++ calendar/js/app.js | 32 +++++++++++++++++---- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index 87a960ad54..4268be3615 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -34,6 +34,7 @@ class calendar_uiforms extends calendar_ui var $public_functions = array( 'freetimesearch' => True, 'ajax_add' => true, + 'ajax_conflicts' => true, 'edit' => true, 'process_edit' => true, 'export' => true, @@ -1469,6 +1470,32 @@ class calendar_uiforms extends calendar_ui $this->edit(); } + public function ajax_conflicts() + { + $participants = json_decode($_GET['participants'],true); + unset($_GET['participants']); + + $content = $this->default_add_event(); + + // Process edit wants to see input values + $participants = array(1=> false); + $participants['cal_resources'] = ''; + foreach($content['participants'] as $id => $status) + { + $quantity = $role = ''; + calendar_so::split_status($status,$quantity,$role); + $participants[] = array( + 'uid' => $id, + 'status' => $status, + 'quantity' => $quantity, + 'role' => $role + ); + } + $content['participants'] = $participants; + $content['button'] = array('apply' => true); + return $this->process_edit($content); + } + /** * Edit a calendar event * diff --git a/calendar/js/app.js b/calendar/js/app.js index 5bab26465f..91c54e5409 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -1655,7 +1655,6 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( // Open dialog to use as target var add_dialog = et2_dialog.show_dialog(null, '', ' ', null, [], et2_dialog.PLAIN_MESSAGE, this.egw); - // Call the server, get it into the dialog options = jQuery.extend({menuaction: 'calendar.calendar_uiforms.ajax_add', template: 'calendar.add'}, options); this.egw.json( @@ -1699,16 +1698,36 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( // Wait a bit to make sure etemplate button finishes processing, or it will error window.setTimeout(function() { var template = etemplate2.getById('calendar-add'); - if(template) + if(template && template.name === 'calendar.add') { template.clear(); + this.dialog.destroy(); + delete app.calendar.quick_add; } - this.dialog.destroy(); - if(this.event) + else if (template) { - this.event.destroy(); + // Open conflicts + var data = jQuery.extend({},template.widgetContainer.getArrayMgr('content').data, app.calendar.quick_add); + + egw.openPopup( + egw.link( + '/index.php?menuaction=calendar.calendar_uiforms.ajax_conflicts', + data + ), + 850, 300, + 'conflicts', 'calendar' + ); + + delete app.calendar.quick_add; + + // Close the JS dialog + this.dialog.destroy(); + + // Do not submit this etemplate + return false; } - }.bind({dialog: add_dialog, event: event}), 100); + + }.bind({dialog: add_dialog, event: ev}), 1000); } }); }, @@ -1722,6 +1741,7 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend( */ add_dialog_save: function(event, widget) { + this.quick_add = widget.getInstanceManager().getValues(widget.getRoot()); // Close the dialog jQuery(widget.getInstanceManager().DOMContainer.parentNode).dialog('close');