improve draggable item generalization
This commit is contained in:
parent
948868af73
commit
2ec4ac30fc
@ -760,10 +760,12 @@ function addBootLine (container, data, before = null) {
|
||||
const item = document.createElement("draggable-item");
|
||||
item.data = data;
|
||||
item.innerHTML = `
|
||||
<div style="display: grid; grid-template-columns: auto auto 8ch 1fr; column-gap: 10px; align-items: center;">
|
||||
<img src="images/actions/drag.svg" id="drag">
|
||||
<img src="${bootMetaData[data.prefix].icon}">
|
||||
<p style="margin: 0px;">${data.id}</p>
|
||||
<p style="margin: 0px; overflow-x: hidden; white-space: nowrap;">${data.detail}</p>
|
||||
</div>
|
||||
`;
|
||||
item.draggable = true;
|
||||
item.classList.add("drop-target");
|
||||
|
@ -64,12 +64,6 @@ class DraggableItem extends HTMLElement {
|
||||
// for whatever reason, only grid layout seems to respect the parent's content bounds
|
||||
this.shadowRoot.innerHTML = `
|
||||
<style>
|
||||
#wrapper {
|
||||
grid-template-columns: auto auto 8ch 1fr;
|
||||
display: grid;
|
||||
column-gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
#drag {
|
||||
cursor: move;
|
||||
}
|
||||
@ -86,7 +80,7 @@ class DraggableItem extends HTMLElement {
|
||||
// add drag and drop listeners
|
||||
this.addEventListener("dragstart", (event) => {
|
||||
this.content.style.opacity = "0.5";
|
||||
const data = { data: this.data, content: this.content.innerHTML, value: this.value };
|
||||
const data = { id: this.id, data: this.data, content: this.content.innerHTML, value: this.value };
|
||||
event.dataTransfer.setData("application/json", JSON.stringify(data));
|
||||
event.dataTransfer.effectAllowed = "move";
|
||||
});
|
||||
@ -127,7 +121,7 @@ class DraggableItem extends HTMLElement {
|
||||
item.innerHTML = transfer.content;
|
||||
item.draggable = true;
|
||||
item.classList.add("drop-target");
|
||||
item.id = `boot-${transfer.data.id}`;
|
||||
item.id = transfer.id;
|
||||
item.value = transfer.data.value;
|
||||
event.target.parentElement.insertBefore(item, event.target);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user