mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
Get calendar quick-add working with Ralf's changes to open an etemplate in a dialog (c63784d7e8
), fix buttons from those etemplates weren't adopted
This commit is contained in:
parent
d21eb1c1e6
commit
50e3a1b204
@ -948,7 +948,7 @@ export class Et2Dialog extends Et2Widget(SlotMixin(SlDialog))
|
|||||||
_adoptTemplateButtons()
|
_adoptTemplateButtons()
|
||||||
{
|
{
|
||||||
// Check for something with buttons slot set
|
// Check for something with buttons slot set
|
||||||
let search_in = <HTMLElement>(this._template_widget?.DOMContainer || this._contentNode);
|
let search_in = <HTMLElement>(this._template_widget?.DOMContainer ?? this._contentNode);
|
||||||
if(!search_in)
|
if(!search_in)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -1022,7 +1022,7 @@ export class Et2Dialog extends Et2Widget(SlotMixin(SlDialog))
|
|||||||
|
|
||||||
get _contentNode() : HTMLElement
|
get _contentNode() : HTMLElement
|
||||||
{
|
{
|
||||||
return this.querySelector('.dialog_content');
|
return this.querySelector('.dialog_content') ?? this.querySelector("*");
|
||||||
}
|
}
|
||||||
|
|
||||||
_setupMoveResize()
|
_setupMoveResize()
|
||||||
|
@ -1617,7 +1617,14 @@ export class etemplate2
|
|||||||
uniqueId = data.DOMNodeID.replace('.', '-') + '-' + data['open_target'];
|
uniqueId = data.DOMNodeID.replace('.', '-') + '-' + data['open_target'];
|
||||||
}
|
}
|
||||||
const et2 = new etemplate2(node, data.data.menuaction, uniqueId);
|
const et2 = new etemplate2(node, data.data.menuaction, uniqueId);
|
||||||
return et2.load(data.name, data.url, data.data, null, null, null, data['fw-target']);
|
return et2.load(data.name, data.url, data.data, null, null, null, data['fw-target'])
|
||||||
|
.then(() =>
|
||||||
|
{
|
||||||
|
if(dialog)
|
||||||
|
{
|
||||||
|
dialog._adoptTemplateButtons();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2061,45 +2061,21 @@ export class CalendarApp extends EgwApp
|
|||||||
this.quick_add = options;
|
this.quick_add = options;
|
||||||
|
|
||||||
// Open dialog to use as target
|
// Open dialog to use as target
|
||||||
let add_dialog = Et2Dialog.show_dialog(null, '', 'Add new event', null, [], Et2Dialog.PLAIN_MESSAGE, "", this.egw);
|
let add_dialog;
|
||||||
add_dialog.id = "quick_add";
|
|
||||||
// Position by the event
|
|
||||||
if(event)
|
|
||||||
{
|
|
||||||
add_dialog.config = {...add_dialog.config, referenceNode: event.getDOMNode()};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call the server, get it into the dialog
|
// Call the server, get it into the dialog
|
||||||
options = jQuery.extend({menuaction: 'calendar.calendar_uiforms.ajax_add', template: 'calendar.add'}, options);
|
options = jQuery.extend({menuaction: 'calendar.calendar_uiforms.ajax_add', template: 'calendar.add'}, options);
|
||||||
this.egw.json(
|
this.egw.json(
|
||||||
this.egw.link('/json.php', options),
|
this.egw.link('/json.php', options),
|
||||||
[options],
|
[options],
|
||||||
function(data)
|
(data) =>
|
||||||
{
|
{
|
||||||
if(data.type)
|
if(Array.isArray(data) && typeof data[0] === 'string')
|
||||||
{
|
{
|
||||||
return false;
|
jQuery(data[0]).appendTo(document.body);
|
||||||
}
|
|
||||||
var content = {
|
|
||||||
html: data[0],
|
|
||||||
js: ''
|
|
||||||
};
|
|
||||||
|
|
||||||
egw_seperateJavaScript(content);
|
|
||||||
|
|
||||||
// Check for right template in the response
|
|
||||||
if(content.html.indexOf('calendar-add') <= 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Insert the content into the correct place
|
|
||||||
add_dialog._contentNode.replaceChildren();
|
|
||||||
add_dialog._contentNode.insertAdjacentHTML("beforeend", content.html);
|
|
||||||
let template = add_dialog.querySelector("[id='calendar-add']");
|
|
||||||
if(template)
|
|
||||||
{
|
|
||||||
template.addEventListener("load", add_dialog._adoptTemplateButtons);
|
|
||||||
}
|
}
|
||||||
|
add_dialog = document.body.querySelector("et2-dialog");
|
||||||
|
add_dialog.id = "quick-add";
|
||||||
}
|
}
|
||||||
).sendRequest();
|
).sendRequest();
|
||||||
|
|
||||||
@ -2162,7 +2138,7 @@ export class CalendarApp extends EgwApp
|
|||||||
if(invalid.filter((widget) => widget).length == 0)
|
if(invalid.filter((widget) => widget).length == 0)
|
||||||
{
|
{
|
||||||
// Close the dialog, if everything is OK
|
// Close the dialog, if everything is OK
|
||||||
(<Et2Dialog><unknown>document.querySelector('et2-dialog#quick_add')).hide();
|
(<Et2Dialog><unknown>document.querySelector('et2-dialog')).hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
</grid>
|
</grid>
|
||||||
<et2-button statustext="saves the changes made" label="Save" id="button[save]" image="save" onclick="return app.calendar.add_dialog_save(ev, widget); " slot="footer" default="true"></et2-button>
|
<et2-button statustext="saves the changes made" label="Save" id="button[save]" image="save" onclick="return app.calendar.add_dialog_save(ev, widget); " slot="footer" default="true"></et2-button>
|
||||||
<et2-button statustext="Full edit dialog" label="Edit" id="button[edit]" image="edit" onclick="return app.calendar.add_dialog_edit(ev, widget);" slot="footer"></et2-button>
|
<et2-button statustext="Full edit dialog" label="Edit" id="button[edit]" image="edit" onclick="return app.calendar.add_dialog_edit(ev, widget);" slot="footer"></et2-button>
|
||||||
<et2-button statustext="Close the window" label="Cancel" id="button[cancel]" onclick="document.querySelector('et2-dialog#quick_add').hide()" image="cancel" slot="footer"></et2-button>
|
<et2-button statustext="Close the window" label="Cancel" id="button[cancel]" onclick="document.querySelector('et2-dialog').hide()" image="cancel" slot="footer"></et2-button>
|
||||||
<et2-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"></et2-checkbox>
|
<et2-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" align="right"></et2-checkbox>
|
||||||
</template>
|
</template>
|
||||||
</overlay>
|
</overlay>
|
Loading…
Reference in New Issue
Block a user