mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Make clone dashlet ask for a rendered dashlet to the backend
This commit is contained in:
@@ -89,7 +89,7 @@ class IboGrid extends HTMLElement {
|
||||
const oParser = new DOMParser();
|
||||
const oDocument = oParser.parseFromString(sDashlet, 'text/html');
|
||||
const oNewDashlet = oDocument.body.firstChild;
|
||||
debugger;
|
||||
|
||||
// Can't use oNewDashet.sDashletId as it's not in the DOM yet and connectedCallback hasn't been called yet
|
||||
const oExistingDashlet = this.GetDashletElement(oNewDashlet.getAttribute('data-dashlet-id') );
|
||||
oExistingDashlet.replaceWith(oNewDashlet);
|
||||
@@ -103,11 +103,9 @@ class IboGrid extends HTMLElement {
|
||||
const sWidth = oSlot.iWidth;
|
||||
const sHeight = oSlot.iHeight;
|
||||
|
||||
// TODO 3.3: Should ask a rendered dashlet for its content to avoid duplicating IDs
|
||||
// Still we'll position it automatically and take care of height/width
|
||||
|
||||
const sDashletContent = oSlot.oDashlet.innerHTML;
|
||||
this.AddDashlet(sDashletContent, {
|
||||
// Ask a new rendered dashlet to avoid duplicating IDs
|
||||
// Still we'll copy width and height
|
||||
this.closest('ibo-dashboard')?.AddNewDashlet(oSlot.oDashlet.sType, oSlot.oDashlet.formData, {
|
||||
'w': sWidth,
|
||||
'h': sHeight
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@ class IboDashboard extends HTMLElement {
|
||||
}
|
||||
}
|
||||
|
||||
AddNewDashlet(sDashletClass, aDashletOptions = {}) {
|
||||
AddNewDashlet(sDashletClass, sDashletValues, aDashletOptions = {}) {
|
||||
const sNewDashletUrl = GetAbsoluteUrlAppRoot() + '/pages/UI.php?route=dashboard.get_dashlet&dashlet_class='+encodeURIComponent(sDashletClass);
|
||||
fetch(sNewDashletUrl)
|
||||
.then(async data => {
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
$('#{{ oUIBlock.GetId() }} .ibo-dashlet-entry').on('click', (event) => {
|
||||
const sDashletClass = event.currentTarget.getAttribute('data-dashlet-class');
|
||||
const oDashboard = document.querySelector('ibo-dashboard');
|
||||
oDashboard.AddNewDashlet(sDashletClass, {
|
||||
'minW': event.currentTarget.getAttribute('data-min-width'),
|
||||
'minH': event.currentTarget.getAttribute('data-min-height'),
|
||||
'w': event.currentTarget.getAttribute('data-preferred-width'),
|
||||
'h': event.currentTarget.getAttribute('data-preferred-height')
|
||||
});
|
||||
oDashboard.AddNewDashlet(sDashletClass,
|
||||
{},
|
||||
{
|
||||
'minW': event.currentTarget.getAttribute('data-min-width'),
|
||||
'minH': event.currentTarget.getAttribute('data-min-height'),
|
||||
'w': event.currentTarget.getAttribute('data-preferred-width'),
|
||||
'h': event.currentTarget.getAttribute('data-preferred-height')
|
||||
}
|
||||
);
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user