Calendar: Quick add improvements

- Set slot attribute to make sure dialog adopts the preference checkbox too
- Make sure template winds up alone in the dialog (remove default content)
This commit is contained in:
nathan 2022-03-24 11:24:00 -06:00
parent 67dba61ef6
commit db44e0b754
3 changed files with 36 additions and 21 deletions

View File

@ -2085,7 +2085,9 @@ export class CalendarApp extends EgwApp
* Open a smaller dialog/popup to add a new entry
*
* This is opened inside a dialog widget, not a popup. This causes issues
* with the submission, handling of the response, and cleanup.
* with the submission, handling of the response, and cleanup. We're doing this because the server sets a lot
* of default values, but this could probably also be done more cleanly by getting the values via AJAX and passing
* them into the dialog
*
* @param {Object} options Array of values for new
* @param {et2_calendar_event} event Placeholder showing where new event goes
@ -2107,7 +2109,7 @@ export class CalendarApp extends EgwApp
this.quick_add = options;
// Open dialog to use as target
let add_dialog = Et2Dialog.show_dialog(null, '', ' ', null, [], Et2Dialog.PLAIN_MESSAGE, this.egw);
let add_dialog = Et2Dialog.show_dialog(null, '', 'Add new event', null, [], Et2Dialog.PLAIN_MESSAGE, this.egw);
add_dialog.id = "quick_add";
// Position by the event
if(event)
@ -2138,8 +2140,15 @@ export class CalendarApp extends EgwApp
{
return false;
}
// Insert the content
add_dialog._overlayContentNode._contentNode.insertAdjacentHTML("beforeend", content.html);
// Insert the content into the correct place
add_dialog._overlayContentNode._contentNode.remove();
add_dialog._overlayContentNode.insertAdjacentHTML("beforeend", content.html);
let template = add_dialog._overlayContentNode.querySelector("[id='calendar-add']");
if(template)
{
template.slot = "content";
template.addEventListener("load", add_dialog._adoptTemplateButtons);
}
}
).sendRequest();

View File

@ -29,6 +29,7 @@ add alarm calendar en Add alarm
add appointments via shortened dialog or complete edit window calendar en Add appointments via shortened dialog or complete edit window
add current view as favorite calendar en Add current view as favorite
add new alarm calendar en Add new alarm
add new event calendar en Add new event
add new participants or resource calendar en Add new participants or resource
add timesheet entry calendar en Add timesheet entry
added calendar en Added

View File

@ -17,23 +17,28 @@
<textbox id="title" size="75" maxlength="255" tabindex="1" class="et2_fullWidth" span="4" blur="Title" needed="true"/>
</row>
<row class="dialogHeader2" height="28">
<description for="start" value="Start" width="88"/>
<date-time id="start" needed="1" class="required" onchange="app.calendar.edit_start_change"/>
<description for="duration" value="Duration" id="calendar_edit_duration" />
<menulist>
<menupopup statustext="Duration of the meeting" class="et2_fullWidth" id="duration" no_lang="1" onchange="app.calendar.set_enddate_visibility" options="Use end date,,,,,,,false"/>
</menulist>
<date-time id="end" onchange="app.calendar.edit_update_participant"/>
</row>
</rows>
</grid>
<hbox class="dialogFooterToolbar">
<button statustext="saves the changes made" label="Save" id="button[save]" image="save" background_image="1" onclick="return app.calendar.add_dialog_save(ev, widget); "/>
<button statustext="Full edit dialog" label="Edit" id="button[edit]" image="edit" background_image="1" onclick="return app.calendar.add_dialog_edit(ev, widget);"/>
<button statustext="Close the window" label="Cancel" id="button[cancel]"
<description for="start" value="Start" width="88"/>
<date-time id="start" needed="1" class="required" onchange="app.calendar.edit_start_change"/>
<description for="duration" value="Duration" id="calendar_edit_duration"/>
<menulist>
<menupopup statustext="Duration of the meeting" class="et2_fullWidth" id="duration" no_lang="1"
onchange="app.calendar.set_enddate_visibility" options="Use end date,,,,,,,false"/>
</menulist>
<date-time id="end" onchange="app.calendar.edit_update_participant"/>
</row>
</rows>
</grid>
<hbox slot="buttons">
<button statustext="saves the changes made" label="Save" id="button[save]" image="save" background_image="1"
onclick="return app.calendar.add_dialog_save(ev, widget); "/>
<button statustext="Full edit dialog" label="Edit" id="button[edit]" image="edit" background_image="1"
onclick="return app.calendar.add_dialog_edit(ev, widget);"/>
<button statustext="Close the window" label="Cancel" id="button[cancel]"
onclick="document.querySelector('et2-dialog#quick_add').close()" image="cancel"
background_image="1"/>
<checkbox label="Always use full edit dialog" id="new_event_dialog" statustext="Always use the full edit dialog, not this little dialog" onchange="egw.set_preference('calendar',widget.id,widget.get_value() ? 'edit' : 'add');"/>
</hbox>
</template>
<checkbox label="Always use full edit dialog" id="new_event_dialog"
statustext="Always use the full edit dialog, not this little dialog"
onchange="egw.set_preference('calendar',widget.id,widget.get_value() ? 'edit' : 'add');"/>
</hbox>
</template>
</overlay>