瀏覽代碼

Prevent useless refresh

tripeur 4 年之前
父節點
當前提交
8d4424c324
共有 3 個文件被更改,包括 7 次插入7 次删除
  1. 1 1
      src/components/EditeurBenevole.vue
  2. 1 1
      src/components/EditeurCreneau.vue
  3. 5 5
      src/views/Planning.vue

+ 1 - 1
src/components/EditeurBenevole.vue

@@ -115,7 +115,7 @@ export default defineComponent({
       const old_arr = this.benevole?.competenceIdList;
       const old_arr = this.benevole?.competenceIdList;
       if (
       if (
         new_arr.length !== old_arr?.length ||
         new_arr.length !== old_arr?.length ||
-        new_arr.reduce((acc: boolean, n: number) => acc && old_arr.includes(n), true)
+        !new_arr.reduce((acc: boolean, n: number) => acc && old_arr.includes(n), true)
       ) {
       ) {
         this.updateBenevole("competenceIdList", new_arr);
         this.updateBenevole("competenceIdList", new_arr);
       }
       }

+ 1 - 1
src/components/EditeurCreneau.vue

@@ -201,7 +201,7 @@ export default defineComponent({
         const old_arr = this.creneau?.competencesIdList;
         const old_arr = this.creneau?.competencesIdList;
         if (
         if (
           new_arr.length !== old_arr?.length ||
           new_arr.length !== old_arr?.length ||
-          new_arr.reduce((acc: boolean, n: number) => acc && old_arr.includes(n), true)
+          !new_arr.reduce((acc: boolean, n: number) => acc && old_arr.includes(n), true)
         ) {
         ) {
           this.updateCreneau("competencesIdList", new_arr);
           this.updateCreneau("competencesIdList", new_arr);
         }
         }

+ 5 - 5
src/views/Planning.vue

@@ -257,10 +257,10 @@ export default defineComponent({
       }
       }
     },
     },
     ressourceChangeHandler(ev: CustomEvent<{ ressources: Array<Ressource> }>) {
     ressourceChangeHandler(ev: CustomEvent<{ ressources: Array<Ressource> }>) {
-      this.commit(
-        MutationTypes.reorderCreneauGroup,
-        ev.detail.ressources.map((o) => o.id)
-      );
+      const ids = ev.detail.ressources.map((o) => o.id);
+      const current_id = this.creneauGroupList.map((o) => o.id);
+      const same_order = current_id.reduce((acc, id, idx) => acc && id == ids[idx], true);
+      if (!same_order) this.commit(MutationTypes.reorderCreneauGroup, ids);
     },
     },
     updateCreneauGroup<K extends keyof Ressource>(payload: {
     updateCreneauGroup<K extends keyof Ressource>(payload: {
       id: string;
       id: string;
@@ -394,7 +394,7 @@ export default defineComponent({
     this.timeline.setAttribute("start", this.start.toISOString());
     this.timeline.setAttribute("start", this.start.toISOString());
     this.timeline.setAttribute("end", this.end.toISOString());
     this.timeline.setAttribute("end", this.end.toISOString());
     this.timeline.addRessources(this.creneauGroupList);
     this.timeline.addRessources(this.creneauGroupList);
-    this.commit(
+    this.$store.commit(
       MutationTypes.reorderCreneauGroup,
       MutationTypes.reorderCreneauGroup,
       this.timeline.getRessources().map((o) => o.id)
       this.timeline.getRessources().map((o) => o.id)
     );
     );