Dialog work

Get calendar quick add working again
This commit is contained in:
nathan 2022-12-01 11:20:58 -07:00
parent 83ab58329e
commit 634e00f948
3 changed files with 26 additions and 18 deletions

View File

@ -847,8 +847,12 @@ export class Et2Dialog extends Et2Widget(SlotMixin(SlDialog))
{
// Check for something with buttons slot set
let search_in = <HTMLElement>(this._template_widget?.DOMContainer || this._contentNode);
if(!search_in)
{
return;
}
let template_buttons = [
...search_in.querySelectorAll('[slot="buttons"]'),
...search_in.querySelectorAll('[slot="footer"],[slot="buttons"]'),
// Look for a dialog footer, which will contain several buttons and possible other widgets
...search_in.querySelectorAll(".dialogFooterToolbar"),
// Look for buttons at high level (not everywhere, otherwise we can't have other buttons in the template)
@ -856,11 +860,17 @@ export class Et2Dialog extends Et2Widget(SlotMixin(SlDialog))
];
if(template_buttons)
{
if(template_buttons[0].instanceOf(Et2Button))
{
template_buttons[0].variant = "primary";
template_buttons[0].outline = true;
}
template_buttons.forEach((button) =>
{
button.setAttribute("slot", "footer");
this.appendChild(button);
})
});
this.requestUpdate();
}
// do NOT submit dialog, if it has no etemplate_exec_id, it only gives and error on server-side
if (this._template_widget && !this._template_widget.widgetContainer.getInstanceManager().etemplate_exec_id)

View File

@ -2088,12 +2088,11 @@ export class CalendarApp extends EgwApp
return false;
}
// Insert the content into the correct place
add_dialog._contentNode.remove();
add_dialog.insertAdjacentHTML("beforeend", content.html);
add_dialog._contentNode.replaceChildren();
add_dialog._contentNode.insertAdjacentHTML("beforeend", content.html);
let template = add_dialog.querySelector("[id='calendar-add']");
if(template)
{
template.slot = "";
template.addEventListener("load", add_dialog._adoptTemplateButtons);
}
}
@ -2158,7 +2157,7 @@ export class CalendarApp extends EgwApp
if(invalid.filter((widget) => widget).length == 0)
{
// Close the dialog, if everything is OK
(<Et2Dialog><unknown>document.querySelector('et2-dialog#quick_add')).close();
(<Et2Dialog><unknown>document.querySelector('et2-dialog#quick_add')).hide();
}
});

View File

@ -28,17 +28,16 @@
</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>
<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); " slot="footer" default="true"/>
<button statustext="Full edit dialog" label="Edit" id="button[edit]" image="edit" background_image="1"
onclick="return app.calendar.add_dialog_edit(ev, widget);" slot="footer"/>
<button statustext="Close the window" label="Cancel" id="button[cancel]"
onclick="document.querySelector('et2-dialog#quick_add').hide()" image="cancel"
background_image="1" slot="footer"/>
<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');"
slot="footer"/>
</template>
</overlay>