Browse Source

add debug msg for reorder

tripeur 4 years ago
parent
commit
e0661e6abe
2 changed files with 25 additions and 5 deletions
  1. 2 2
      package-lock.json
  2. 23 3
      src/views/Planning.vue

+ 2 - 2
package-lock.json

@@ -10362,7 +10362,7 @@
     },
     "node_modules/jc-timeline": {
       "version": "0.2.11",
-      "resolved": "git+http://gitlab.jaquin.fr/clovis/jc-timeline.git#25498b11e4235e9b74cae8f0826521bde90de5af",
+      "resolved": "git+http://gitlab.jaquin.fr/clovis/jc-timeline.git#ec8c240ba55e7cd78497395ca569df8d20c2fd2f",
       "license": "ISC",
       "dependencies": {
         "dayjs": "^1.10.4",
@@ -30560,7 +30560,7 @@
       "dev": true
     },
     "jc-timeline": {
-      "version": "git+http://gitlab.jaquin.fr/clovis/jc-timeline.git#25498b11e4235e9b74cae8f0826521bde90de5af",
+      "version": "git+http://gitlab.jaquin.fr/clovis/jc-timeline.git#ec8c240ba55e7cd78497395ca569df8d20c2fd2f",
       "from": "jc-timeline@git+http://gitlab.jaquin.fr/clovis/jc-timeline.git",
       "requires": {
         "dayjs": "^1.10.4",

+ 23 - 3
src/views/Planning.vue

@@ -168,9 +168,10 @@ export default defineComponent({
       this.timeline.clearSelectedItems();
       this.currentCreneauGroup = this.timeline.addRessource(ressource, pos);
       this.currentCreneauGroup.selected = true;
-
+      const finalPos = this.timeline.getRessources().findIndex((o) => o.id == ressource.id);
+      console.log("Position " + finalPos);
       this.commit(MutationTypes.addCreneauGroupAt, {
-        pos: this.timeline.getRessources().indexOf(this.currentCreneauGroup),
+        pos: finalPos,
         r: this.currentCreneauGroup,
       });
     },
@@ -294,9 +295,27 @@ export default defineComponent({
       this.zoomLevel += lvl;
       this.zoomLevel = Math.min(Math.max(0, this.zoomLevel), durations.length - 1);
 
+      const scrollContainer = this.timeline.shadowRoot?.querySelector(
+        ".jc-timeline-grid-container  .simplebar-content-wrapper"
+      ) as HTMLDivElement;
+      const newScroll =
+        ((scrollContainer.scrollLeft + scrollContainer.offsetWidth / 2) *
+          (this.slotduration / this.slotwidth)) /
+          (durations[this.zoomLevel] / slotWidths[this.zoomLevel]) -
+        scrollContainer.offsetWidth / 2;
+
       this.slotduration = durations[this.zoomLevel];
       this.slotwidth = slotWidths[this.zoomLevel];
       this.legendspan = legendSpans[this.zoomLevel];
+      setTimeout(() => {
+        const root = this.timeline.shadowRoot;
+        if (root) {
+          root
+            .querySelector(".jc-timeline-grid-container .simplebar-content-wrapper")
+            ?.scrollTo(newScroll, 0);
+          root.querySelector(".jc-timeline-grid-title-container")?.scrollTo(newScroll, 0);
+        }
+      }, 0);
     },
     openContextMenu(e: MouseEvent) {
       e.preventDefault();
@@ -365,10 +384,11 @@ export default defineComponent({
             const ressource = this.$store.getters.getCreneauGroupById(ressourceId ?? "");
 
             if (ressource) {
-              const pos = this.creneauGroupList.indexOf(ressource);
+              const pos = this.timeline.getRessources().findIndex((o) => o.id == ressourceId);
               const newRessource = (pos: number) => {
                 const r = new Ressource({ id: uuidv4(), title: "Nouvelle ligne" });
                 if (ressource.parent) r.parent = ressource.parent;
+                console.log("Nouvelle ligne en position " + pos);
                 this.registerRessource(r, pos);
               };
               this.contextActions = [