Bläddra i källkod

Fixes note orientation reversal code

Still triggers a warning about potentially infinite loops in Javascript console, need to find a better solution.
Christopher Leggett 5 år sedan
förälder
incheckning
fa388423ea
3 ändrade filer med 29 tillägg och 18 borttagningar
  1. 14 8
      public/js/app.js
  2. 13 8
      resources/js/components/notes.vue
  3. 2 2
      resources/views/workorders/show.blade.php

+ 14 - 8
public/js/app.js

@@ -2626,16 +2626,22 @@ __webpack_require__.r(__webpack_exports__);
   data: function data() {
     return {
       notes: Object.values(this.initialnotes),
-      noteWoid: this.woid
+      currentOrder: 'order-first'
     };
   },
   methods: {
-    userChanged: function userChanged(index) {
+    setOrder: function setOrder(index) {
       if (index === 0) {
-        return false;
-      } else {
-        return this.notes[index].noteuser !== this.notes[index - 1].noteuser;
+        this.currentOrder = 'order-first';
+      } else if (this.notes[index].noteuser !== this.notes[index - 1].noteuser) {
+        if (this.currentOrder === 'order-first') {
+          this.currentOrder = 'order-last';
+        } else {
+          this.currentOrder = 'order-first';
+        }
       }
+
+      return this.currentOrder;
     }
   }
 });
@@ -50091,7 +50097,7 @@ var render = function() {
         attrs: {
           "modal-id": "note" + _vm.noteType + "CreateModal",
           "note-type": _vm.noteType,
-          woid: _vm.noteWoid,
+          woid: _vm.woid,
           "note-user": _vm.authusername
         }
       }),
@@ -50112,7 +50118,7 @@ var render = function() {
       _vm._l(this.notes, function(note, index) {
         return _c(
           "li",
-          { key: note.noteid, staticClass: "row no-gutters mb-2" },
+          { key: index, staticClass: "row no-gutters mb-2" },
           [
             _c("note-form-modal", {
               attrs: {
@@ -50125,7 +50131,7 @@ var render = function() {
               "div",
               {
                 staticClass: "col-md-1 d-flex flex-column mx-md-3",
-                class: { "order-last": _vm.userChanged(index) }
+                class: _vm.setOrder(index)
               },
               [
                 _c("div", { staticClass: "text-center p-0 m-0" }, [

+ 13 - 8
resources/js/components/notes.vue

@@ -1,10 +1,10 @@
 <template>
     <ul class="list-unstyled">
-        <note-form-modal :modal-id="'note'+noteType+'CreateModal'" :note-type="noteType" :woid="noteWoid" :note-user="authusername"></note-form-modal>
+        <note-form-modal :modal-id="'note'+noteType+'CreateModal'" :note-type="noteType" :woid="woid" :note-user="authusername"></note-form-modal>
         <button type="button" data-toggle="modal" :data-target="'#note'+noteType+'CreateModal'" class="btn btn-primary"><i class="fas fa-fw fa-plus"></i> Add New Note</button>
-        <li class="row no-gutters mb-2" v-bind:key="note.noteid" v-for="(note, index) in this.notes">
+        <li class="row no-gutters mb-2" v-bind:key="index" v-for="(note, index) in this.notes">
             <note-form-modal :modal-id="'note'+note.noteid+'editModal'" :populate-with="note"></note-form-modal>
-            <div class="col-md-1 d-flex flex-column mx-md-3" :class="{ 'order-last': userChanged(index) }">
+            <div class="col-md-1 d-flex flex-column mx-md-3" :class="setOrder(index)">
                 <div class="text-center p-0 m-0">{{note.noteuser}}</div>
                 <div class="text-muted text-small text-center p-0 m-0">{{getHRDate(note.notetime)}}</div>
                 <div class="btn-group justify-content-center p-0 m-0">
@@ -33,16 +33,21 @@ export default {
     data () {
         return {
             notes: Object.values(this.initialnotes),
-            noteWoid: this.woid
+            currentOrder: 'order-first'
         }
     },
     methods: {
-        userChanged (index) {
+        setOrder (index) {
             if (index === 0) {
-                return false
-            } else {
-                return this.notes[index].noteuser !== this.notes[index-1].noteuser
+                this.currentOrder = 'order-first'
+            } else if (this.notes[index].noteuser !== this.notes[index-1].noteuser) {
+                if (this.currentOrder === 'order-first') {
+                    this.currentOrder = 'order-last'
+                } else {
+                    this.currentOrder = 'order-first'
+                }
             }
+            return this.currentOrder
         }
     }
 }

+ 2 - 2
resources/views/workorders/show.blade.php

@@ -81,7 +81,7 @@
             <div class="card">
                 <div class="card-body">
                     <h5 class="card-title">Customer Notes</h5>
-                    <notes :initialnotes="{{$workOrder->notes->where('notetype', '0')}}" authusername="{{Auth::user()->username}}" :note-type="0" woid="{{$workOrder->woid}}"></notes>
+                    <notes :initialnotes="{{$workOrder->notes->where('notetype', '0')}}" authusername="{{Auth::user()->username}}" :note-type="0" :woid="{{$workOrder->woid}}"></notes>
                 </div>
             </div>
         </div>
@@ -91,7 +91,7 @@
             <div class="card">
                 <div class="card-body">
                     <h5 class="card-title">Private/Billing Notes</h5>
-                    <notes :initialnotes="{{$workOrder->notes->where('notetype', '1')}}" authusername="{{Auth::user()->username}}" :note-type="1" woid="{{$workOrder->woid}}"></notes>
+                    <notes :initialnotes="{{$workOrder->notes->where('notetype', '1')}}" authusername="{{Auth::user()->username}}" :note-type="1" :woid="{{$workOrder->woid}}"></notes>
                 </div>
             </div>
         </div>