|
|
@@ -174,8 +174,8 @@ class Timeline extends LitElement {
|
|
|
this.legendUnitFormat[unit] = format;
|
|
|
this.updateLegend();
|
|
|
}
|
|
|
- addRessources(list: Array<IRessource>): Array<Ressource> {
|
|
|
- return list.map((r) => this.addRessource(r));
|
|
|
+ addRessources(list: Array<IRessource>, pos = Infinity): Array<Ressource> {
|
|
|
+ return list.map((r, idx) => this.addRessource(r, idx + pos));
|
|
|
0;
|
|
|
}
|
|
|
// Ressource management
|
|
|
@@ -203,8 +203,12 @@ class Timeline extends LitElement {
|
|
|
this.rows.splice(pos, 0, r);
|
|
|
if (!alreadyChild) r.parent.children.splice(pos - idx, 0, r);
|
|
|
} else {
|
|
|
- this.rows.splice(idx + r.parent.children.length + 1, 0, r);
|
|
|
- if (!alreadyChild) r.parent.children = [...r.parent.children, r];
|
|
|
+ if (alreadyChild) {
|
|
|
+ this.rows.splice(idx + r.parent.children.indexOf(r) + 1, 0, r);
|
|
|
+ } else {
|
|
|
+ this.rows.splice(idx + r.parent.children.length + 1, 0, r);
|
|
|
+ r.parent.children = [...r.parent.children, r];
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
throw new Error("Not able to create ressource parent.\n" + r.id);
|
|
|
@@ -798,6 +802,7 @@ class Timeline extends LitElement {
|
|
|
// Update the moved ressource position
|
|
|
if (event.target.classList.contains("jc-ressource")) {
|
|
|
movedContent.ressources[0].parent = destination;
|
|
|
+ this.addRessource(src);
|
|
|
} else {
|
|
|
movedContent.ressources[0].parent = destination.parent;
|
|
|
let idx = this.rows.findIndex((v) => v.id === destinationId);
|
|
|
@@ -807,11 +812,11 @@ class Timeline extends LitElement {
|
|
|
idx += 1;
|
|
|
}
|
|
|
}
|
|
|
- const arr = this.rows;
|
|
|
- this.rows = [...arr.splice(0, idx), src, ...arr];
|
|
|
+ this.addRessource(src, idx - 1);
|
|
|
}
|
|
|
// Add moved children and associated slots
|
|
|
- this.addRessources(movedContent.ressources);
|
|
|
+ const idx = this.rows.findIndex((v) => v.id === srcId);
|
|
|
+ this.addRessources(movedContent.ressources, idx - 2);
|
|
|
this.addEvents(movedContent.items);
|
|
|
this.dispatchEvent(
|
|
|
new CustomEvent("reorder-ressource", {
|