Browse Source

Prop fix on ListView

master
George Williams 4 years ago
parent
commit
6f3f000d6f
1 changed files with 78 additions and 69 deletions
  1. 78
    69
      src/components/shared/listView.vue

+ 78
- 69
src/components/shared/listView.vue View File

@@ -2,7 +2,7 @@
2 2
 <template>
3 3
   <div>
4 4
     <div style="height:5px"></div>
5
-    <div class="d-flex justify-content-between ">
5
+    <div class="d-flex justify-content-between">
6 6
       <div class="p-2" v-if="!hideSearch">
7 7
         <float-label label="SEARCH">
8 8
           <input v-model="searchItem" class="form-control uniInput mt-3" placeholder="Search..." />
@@ -14,9 +14,11 @@
14 14
       <div class="p-2">
15 15
         <div class="d-flex flex-row">
16 16
           <div class="p2" v-if="showColumnChooser">
17
-            <div class="btn-solid-blue cursor-pointer" data-toggle="modal" data-target="#myModal">
18
-              Column Chooser
19
-            </div>
17
+            <div
18
+              class="btn-solid-blue cursor-pointer"
19
+              data-toggle="modal"
20
+              data-target="#myModal"
21
+            >Column Chooser</div>
20 22
             <div class="col-md-12">
21 23
               <div id="myModal" class="modal fade" role="dialog">
22 24
                 <div class="modal-dialog modal-lg" style="width:500px">
@@ -35,14 +37,10 @@
35 37
             </div>
36 38
           </div>
37 39
           <div class="p2" v-if="selectedItems.length > 0">
38
-            <div class="btn-solid-blue cursor-pointer" @click="onClearSelected()">
39
-              Clear Selected
40
-            </div>
40
+            <div class="btn-solid-blue cursor-pointer" @click="onClearSelected()">Clear Selected</div>
41 41
           </div>
42 42
           <div class="p2" v-if="showNew">
43
-            <div class="btn-solid-blue cursor-pointer" @click="onNew()">
44
-              New
45
-            </div>
43
+            <div class="btn-solid-blue cursor-pointer" @click="onNew()">New</div>
46 44
           </div>
47 45
         </div>
48 46
       </div>
@@ -64,12 +62,14 @@
64 62
                 :class="{ active: hover === c }"
65 63
               >
66 64
                 <div class="d-flex bd-highlight">
67
-                  <div v-if="displayHeaders.length === 0" class="p-2 w-100 bd-highlight">
68
-                    {{ column | toProper }}
69
-                  </div>
70
-                  <div v-else class="p-2 w-100 bd-highlight">
71
-                    {{ displayHeaders[c] !== "" ? displayHeaders[c] : column | toProper }}
72
-                  </div>
65
+                  <div
66
+                    v-if="displayHeaders.length === 0"
67
+                    class="p-2 w-100 bd-highlight"
68
+                  >{{ column | toProper }}</div>
69
+                  <div
70
+                    v-else
71
+                    class="p-2 w-100 bd-highlight"
72
+                  >{{ displayHeaders[c] !== "" ? displayHeaders[c] : column | toProper }}</div>
73 73
                   <div class="p-2 flex-shrink-1 bd-highlight">
74 74
                     <img
75 75
                       src="../../../public/img/sort-up.png"
@@ -98,26 +98,28 @@
98 98
             :class="{ selected: isSelected(i), 'cursor-pointer': allowSelect }"
99 99
           >
100 100
             <td v-for="(column, c) in Columns" :key="c">
101
-              <div v-if="displayFormats.length === 0">
102
-                {{ isObject(item[column]) ? item[column].display : item[column] }}
103
-              </div>
101
+              <div
102
+                v-if="displayFormats.length === 0"
103
+              >{{ isObject(item[column]) ? item[column].display : item[column] }}</div>
104 104
               <div v-else-if="displayFormats.length > 0 && displayFormats[c] === 'date'">
105
-                <div v-if="item[column] !== '0001-01-01T00:00:00'">
106
-                  {{ isObject(item[column]) ? item[column].display : item[column] | toDate }}
107
-                </div>
108
-              </div>
109
-              <div v-else-if="displayFormats.length > 0 && displayFormats[c] === 'money'">
110
-                {{ isObject(item[column]) ? item[column].display : item[column] | toCurrency }}
105
+                <div
106
+                  v-if="item[column] !== '0001-01-01T00:00:00'"
107
+                >{{ isObject(item[column]) ? item[column].display : item[column] | toDate }}</div>
111 108
               </div>
109
+              <div
110
+                v-else-if="displayFormats.length > 0 && displayFormats[c] === 'money'"
111
+              >{{ isObject(item[column]) ? item[column].display : item[column] | toCurrency }}</div>
112 112
               <div v-else-if="displayFormats.length > 0 && displayFormats[c] === 'image'">
113 113
                 <img :src="item[column]" style="height:100px; width:100px; object-fit: cover;" />
114 114
               </div>
115 115
               <div v-else>{{ isObject(item[column]) ? item[column].display : item[column] }}</div>
116 116
             </td>
117 117
             <td v-if="showCustomAction" class="my-width">
118
-              <button type="button" class="btn my-btn" @click="onCustomClick(item)">
119
-                {{ CustomActionHeading }}
120
-              </button>
118
+              <button
119
+                type="button"
120
+                class="btn my-btn"
121
+                @click="onCustomClick(item)"
122
+              >{{ CustomActionHeading }}</button>
121 123
             </td>
122 124
             <td v-if="editable" class="my-width">
123 125
               <a @click="onEdit(item)" class="p-3">
@@ -137,10 +139,10 @@
137 139
       <div class="d-flex justify-content-between" v-if="showPager">
138 140
         <div class="p-1">
139 141
           {{
140
-            currentPage +
141
-              " / " +
142
-              PageCount +
143
-              (!hideItemCount ? " - (" + FilteredItems.length + " items)" : "")
142
+          currentPage +
143
+          " / " +
144
+          PageCount +
145
+          (!hideItemCount ? " - (" + FilteredItems.length + " items)" : "")
144 146
           }}
145 147
         </div>
146 148
         <div class="p-1">
@@ -185,7 +187,7 @@ export default {
185 187
   components: {
186 188
     BasePagination,
187 189
     Alert,
188
-    ListViewControl
190
+    ListViewControl,
189 191
   },
190 192
   mounted() {
191 193
     try {
@@ -201,72 +203,75 @@ export default {
201 203
   },
202 204
   props: {
203 205
     compact: {
204
-      default: true
206
+      default: true,
205 207
     },
206 208
     allowSelect: {
207
-      default: true
209
+      default: true,
208 210
     },
209 211
     allowMultipleSelect: {
210
-      default: false
212
+      default: false,
211 213
     },
212 214
     hideSearch: {
213
-      default: false
215
+      default: false,
214 216
     },
215 217
     showNew: {
216
-      default: true
218
+      default: true,
217 219
     },
218 220
     items: undefined,
219 221
     editable: {
220
-      default: false
222
+      default: false,
221 223
     },
222 224
     deleteable: {
223
-      default: false
225
+      default: false,
224 226
     },
225 227
     columnCount: {
226
-      default: 6
228
+      default: 6,
227 229
     },
228 230
     showPager: {
229
-      default: true
231
+      default: true,
230 232
     },
231 233
     title: {
232
-      default: undefined
234
+      default: undefined,
233 235
     },
234 236
     sortKey: {
235
-      default: "id"
237
+      default: "id",
236 238
     },
237 239
     hideItemCount: {
238
-      default: false
240
+      default: false,
239 241
     },
240 242
     currentPage: {
241
-      default: 1
243
+      default: 1,
242 244
     },
243 245
     bordered: {
244
-      default: true
246
+      default: true,
245 247
     },
246 248
     striped: {
247
-      default: true
249
+      default: true,
248 250
     },
249 251
     showColumnChooser: {
250
-      default: true
252
+      default: true,
251 253
     },
252 254
     displayColumns: {
253
-      default: []
255
+      type: Array,
256
+      default: () => [],
254 257
     },
255 258
     displayFormats: {
256
-      default: []
259
+      type: Array,
260
+      default: () => [],
257 261
     },
258 262
     displayHeaders: {
259
-      default: []
263
+      type: Array,
264
+      default: () => [],
260 265
     },
261 266
     showCustomAction: {
262
-      default: false
267
+      default: false,
263 268
     },
264 269
     CustomActionHeading: {
265
-      default: ""
270
+      default: "",
266 271
     },
267 272
     CustomActionCondition: {
268
-      default: ""
269
-    }
273
+      default: "",
274
+    },
270 275
   },
271 276
   data() {
272 277
     return {
@@ -279,7 +284,7 @@ export default {
279 284
       visibleItemsPerPageCount: 20,
280 285
       itemsPerPageList: ItemsPerPageList,
281 286
       visibleColumn: [],
282
-      allColumn: []
287
+      allColumn: [],
283 288
     };
284 289
   },
285 290
   methods: {
@@ -301,12 +306,16 @@ export default {
301 306
         for (const i in Object.keys(this.items)) {
302 307
           const item = this.items[i];
303 308
           for (const o in Object.keys(item)) {
304
-            if (!listAll.includes(Object.keys(item)[o]) && !Array.isArray(Object.values(item)[o])) {
309
+            if (
310
+              !listAll.includes(Object.keys(item)[o]) &&
311
+              !Array.isArray(Object.values(item)[o])
312
+            ) {
305 313
               const columnName = Object.keys(item)[o];
306
-              if (!listAll.some(x => x.column === columnName)) {
314
+              if (!listAll.some((x) => x.column === columnName)) {
307 315
                 listAll.push({
308 316
                   column: columnName,
309
-                  show: _.filter(listAll, x => x.show).length < this.columnCount
317
+                  show:
318
+                    _.filter(listAll, (x) => x.show).length < this.columnCount,
310 319
                 });
311 320
               }
312 321
             }
@@ -321,7 +330,7 @@ export default {
321 330
     },
322 331
     isSelected(i) {
323 332
       const ind = this.getActualIndex(i);
324
-      return _.some(this.selectedItems, x => x === ind);
333
+      return _.some(this.selectedItems, (x) => x === ind);
325 334
     },
326 335
     onNew() {
327 336
       this.$emit("onNew");
@@ -357,8 +366,8 @@ export default {
357 366
     },
358 367
     onRowClick(item, i) {
359 368
       const ind = this.getActualIndex(i);
360
-      if (_.some(this.selectedItems, x => x === ind)) {
361
-        this.selectedItems = this.selectedItems.filter(x => x !== ind);
369
+      if (_.some(this.selectedItems, (x) => x === ind)) {
370
+        this.selectedItems = this.selectedItems.filter((x) => x !== ind);
362 371
       } else {
363 372
         if (!this.allowMultipleSelect) {
364 373
           this.selectedItems = [];
@@ -411,7 +420,7 @@ export default {
411 420
         if (array[i] === value) return true;
412 421
       }
413 422
       return false;
414
-    }
423
+    },
415 424
   },
416 425
   computed: {
417 426
     ListWidth() {
@@ -438,7 +447,7 @@ export default {
438 447
           listColumns.push(this.displayColumns[i]);
439 448
         }
440 449
       } else {
441
-        const list = _.filter(this.allColumn, x => x.show);
450
+        const list = _.filter(this.allColumn, (x) => x.show);
442 451
         for (const i in list) {
443 452
           const item = list[i];
444 453
           if (item) {
@@ -455,9 +464,9 @@ export default {
455 464
       return list;
456 465
     },
457 466
     FilteredItems() {
458
-      const list = _.filter(this.items, item =>
467
+      const list = _.filter(this.items, (item) =>
459 468
         Object.values(item).some(
460
-          i =>
469
+          (i) =>
461 470
             JSON.stringify(i)
462 471
               .toLowerCase()
463 472
               .indexOf(this.searchItem.toLowerCase()) > -1
@@ -475,8 +484,8 @@ export default {
475 484
       return list.slice(startSlice, endSlice);
476 485
     },
477 486
 
478
-    GetAllColumn() {}
479
-  }
487
+    GetAllColumn() {},
488
+  },
480 489
 };
481 490
 </script>
482 491
 <style scoped>

Loading…
Cancel
Save