Calendar: further adaptations to using openDialog()

Fixes canceling quick add doesn't remove placeholder, invalid event gave no feedback
This commit is contained in:
nathan 2023-07-13 16:29:14 -06:00 committed by ralf
parent 5b401feb85
commit 38d7a3ca9e
2 changed files with 7 additions and 62 deletions

View File

@ -33,8 +33,6 @@ class calendar_uiforms extends calendar_ui
{ {
var $public_functions = array( var $public_functions = array(
'freetimesearch' => True, 'freetimesearch' => True,
'ajax_add' => true,
'ajax_conflicts' => true,
'edit' => true, 'edit' => true,
'process_edit' => true, 'process_edit' => true,
'export' => true, 'export' => true,
@ -1025,7 +1023,7 @@ class calendar_uiforms extends calendar_ui
} }
else else
{ {
$msg = lang('Error: saving the event !!!'); $msg = ($msg ? $msg.'<br />':'') . lang('Error: saving the event !!!');
} }
break; break;
@ -1477,45 +1475,6 @@ class calendar_uiforms extends calendar_ui
return strnatcasecmp($this->get_title($uid1), $this->get_title($uid2)); 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 * Edit a calendar event
* *

View File

@ -2062,30 +2062,16 @@ export class CalendarApp extends EgwApp
{ {
menuaction += '&'+name+'='+encodeURIComponent(options[name]); 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<ET2Dialog>, so we can use it, without searching the dialog // When the dialog is closed, clean up the placeholder
// in a window.setTimeout in the DOM ... dialog.getComplete().then(() =>
window.setTimeout(() =>
{ {
const dialog = document.querySelector('et2-dialog > form.dialog_content')?.parentNode; if(event)
if (dialog)
{ {
dialog.callback = _button => event.destroy();
{
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;
}
} }
}, 500); });
}); });
} }