From 4a7e5824c32d457f9d1975a6b027a86e79c384b7 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 13 Jul 2023 16:29:14 -0600 Subject: [PATCH] Calendar: further adaptations to using openDialog() Fixes canceling quick add doesn't remove placeholder, invalid event gave no feedback --- calendar/inc/class.calendar_uiforms.inc.php | 43 +-------------------- calendar/js/app.ts | 26 +++---------- 2 files changed, 7 insertions(+), 62 deletions(-) diff --git a/calendar/inc/class.calendar_uiforms.inc.php b/calendar/inc/class.calendar_uiforms.inc.php index 37ee762108..899dcfefea 100644 --- a/calendar/inc/class.calendar_uiforms.inc.php +++ b/calendar/inc/class.calendar_uiforms.inc.php @@ -33,8 +33,6 @@ 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, @@ -1025,7 +1023,7 @@ class calendar_uiforms extends calendar_ui } else { - $msg = lang('Error: saving the event !!!'); + $msg = ($msg ? $msg.'
':'') . lang('Error: saving the event !!!'); } break; @@ -1477,45 +1475,6 @@ class calendar_uiforms extends calendar_ui return strnatcasecmp($this->get_title($uid1), $this->get_title($uid2)); } - public function ajax_add() - { - // This tells etemplate to send as JSON response, not full - // This avoids errors from trying to send header again - if(Api\Json\Request::isJSONRequest()) - { - $GLOBALS['egw']->framework->response = Api\Json\Response::get(); - } - - $this->edit(); - } - - /** - * Get conflict dialog via ajax. Used by quick add. - * - */ - public function ajax_conflicts() - { - $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('save' => true); - return $this->process_edit($content); - } - /** * Edit a calendar event * diff --git a/calendar/js/app.ts b/calendar/js/app.ts index 45fdb34d96..9c023dbf9a 100644 --- a/calendar/js/app.ts +++ b/calendar/js/app.ts @@ -2062,30 +2062,16 @@ export class CalendarApp extends EgwApp { menuaction += '&'+name+'='+encodeURIComponent(options[name]); } - return this.egw.openDialog(menuaction).then(_dialog => + return this.egw.openDialog(menuaction).then(dialog => { - // it would be much nicer if openDialog returns Promise, so we can use it, without searching the dialog - // in a window.setTimeout in the DOM ... - window.setTimeout(() => + // When the dialog is closed, clean up the placeholder + dialog.getComplete().then(() => { - const dialog = document.querySelector('et2-dialog > form.dialog_content')?.parentNode; - if (dialog) + if(event) { - dialog.callback = _button => - { - if (event) - { - event.destroy(); - } - // a little quicker than waiting for the server to close it - if (_button === "calendar-add_button[cancel]") - { - dialog.hide(); - } - return false; - } + event.destroy(); } - }, 500); + }); }); }