Kaynağa Gözat

Listview & timeshare admin

master
Kobus 5 yıl önce
ebeveyn
işleme
dfe1290524

+ 63
- 1
src/components/admin/status/timeshareAdminPage.vue Dosyayı Görüntüle

@@ -6,8 +6,24 @@
6 6
     <br />
7 7
     <br />
8 8
     <div class="row">
9
+      <div class="offset-1 col-md-3">
10
+        <button
11
+          type="button"
12
+          :class="{'form-control btn btn-primary ': (1===1), 'my-disable': (!selectedItems || selectedItems.length === 0)}"
13
+          value="Verify Week(s)"
14
+          :disabled="selectedItems.length > 0"
15
+        >{{ButtonMessage}}</button>
16
+        <div>{{Message}}</div>
17
+      </div>
9 18
       <div class="offset-1 col-md-10">
10
-        <ListView :items="items" :editable="true" @onEdit="onEdit" />
19
+        <ListView
20
+          :items="items"
21
+          :allowMultipleSelect="true"
22
+          @onRowClick="onRowClick"
23
+          @onClearSelected="onClearSelected"
24
+          :columnsCount="15"
25
+          :title="'Pending Weeks'"
26
+        />
11 27
       </div>
12 28
     </div>
13 29
   </div>
@@ -25,6 +41,8 @@ export default {
25 41
   data() {
26 42
     return {
27 43
       user: Log.getUser(),
44
+      selectedItems: [],
45
+      showMessage: false,
28 46
     };
29 47
   },
30 48
   mounted() {
@@ -32,17 +50,61 @@ export default {
32 50
     this.getItems(this.user.id);
33 51
   },
34 52
   computed: {
53
+    SelectedItems() {
54
+      const selectedArray = [];
55
+      this.selectedItems.forEach(x => selectedArray.push(this.items[x]));
56
+      return selectedArray;
57
+    },
58
+    ButtonMessage() {
59
+      let msg = '';
60
+      if (!(this.selectedItems.length > 0)) {
61
+        msg = 'No Items selected';
62
+      } else {
63
+        msg = 'Verify item';
64
+        if (this.selectedItems.length > 1) {
65
+          msg += 's';
66
+        }
67
+      }
68
+      return msg;
69
+    },
70
+    Message() {
71
+      let msg = '';
72
+      if (!(this.selectedItems.length > 0)) {
73
+        msg = 'Please select the item(s) to verify.';
74
+      } else {
75
+        msg = `${this.selectedItems.length}`;
76
+        if (this.selectedItems.length === 1) {
77
+          msg += ' item ';
78
+        } else msg += ' items ';
79
+        msg += 'selected. Click to verify or select more...';
80
+      }
81
+      return msg;
82
+    },
35 83
     ...mapState('myWeeks', ['items']),
36 84
   },
37 85
   methods: {
38 86
     ...mapActions('myWeeks', ['getItems']),
87
+    onRowClick(items) {
88
+      this.selectedItems = items;
89
+    },
39 90
     onEdit(item) {
40 91
       this.$router.push(`/timeshare/${item.id}`);
41 92
     },
93
+    onClearSelected() {
94
+      this.selectedItems = [];
95
+    },
42 96
   },
43 97
 };
44 98
 </script>
45 99
 
46 100
 
47 101
 <style>
102
+.my-disable {
103
+  background-color: silver;
104
+  border-color: silver;
105
+}
106
+.my-disable:hover {
107
+  background-color: lightgray;
108
+  border-color: lightgray;
109
+}
48 110
 </style>

+ 67
- 13
src/components/shared/listView.vue Dosyayı Görüntüle

@@ -2,17 +2,35 @@
2 2
 /* eslint-disable guard-for-in */
3 3
 <template>
4 4
   <div>
5
-    <div class="d-flex justify-content-between">
5
+    <div style="height:5px"></div>
6
+    <div class="d-flex justify-content-between table-title">
6 7
       <div class="p-2" v-if="!hideSearch">
7
-        <input v-model="searchItem" class="form-control" placeholder="Search ..." />
8
+        <input v-model="searchItem" class="form-control" :placeholder="currentPage" />
8 9
       </div>
9
-      <div class="p-2" v-if="showNew">
10
-        <div class="btn btn-primary myBackground" @click="onNew()">New</div>
10
+      <div class="p-2" v-if="title">
11
+        <h2>{{title}}</h2>
12
+      </div>
13
+      <div class="p-2">
14
+        <div class="d-flex flex-row">
15
+          <div class="p2" v-if="selectedItems.length > 0">
16
+            <div
17
+              class="btn btn-primary myBackground btn-width"
18
+              @click="onClearSelected()"
19
+            >Clear Selected</div>
20
+          </div>
21
+          <div class="p2" v-if="showNew">
22
+            <div class="btn btn-primary myBackground btn-width" @click="onNew()">New</div>
23
+          </div>
24
+        </div>
11 25
       </div>
12 26
     </div>
27
+    <div style="height:5px"></div>
13 28
     <div v-if="items && items.length > 0" class="table-responsive">
14
-      <table id="table" class="table table-sm table-bordered table-hover">
15
-        <thead>
29
+      <table
30
+        id="table"
31
+        :class="{'table table-bordered table-hover': (1 === 1), 'table-sm': compact}"
32
+      >
33
+        <thead class="my-table table-header">
16 34
           <tr class="dnd-moved">
17 35
             <th v-for="(column, c) in Columns" :key="c">
18 36
               <div @click="sortBy(column)">{{ column }}</div>
@@ -21,7 +39,7 @@
21 39
             <th v-if="deleteable"></th>
22 40
           </tr>
23 41
         </thead>
24
-        <tbody>
42
+        <tbody class="my-table">
25 43
           <tr
26 44
             v-for="(item, i) in DisplayItems"
27 45
             :key="i"
@@ -41,7 +59,7 @@
41 59
           </tr>
42 60
         </tbody>
43 61
       </table>
44
-      <div class="d-flex justify-content-between">
62
+      <div class="d-flex justify-content-between" v-if="showPager">
45 63
         <div class="p-1">{{ currentPage + ' / ' + PageCount }}</div>
46 64
         <div class="p-1">
47 65
           <BasePagination
@@ -96,6 +114,9 @@ export default {
96 114
     }
97 115
   },
98 116
   props: {
117
+    compact: {
118
+      default: true,
119
+    },
99 120
     allowSelect: {
100 121
       default: true,
101 122
     },
@@ -118,6 +139,12 @@ export default {
118 139
     columnsCount: {
119 140
       default: 6,
120 141
     },
142
+    showPager: {
143
+      default: true,
144
+    },
145
+    title: {
146
+      default: undefined,
147
+    },
121 148
   },
122 149
   data() {
123 150
     return {
@@ -132,8 +159,13 @@ export default {
132 159
     };
133 160
   },
134 161
   methods: {
162
+    onClearSelected() {
163
+      this.selectedItems = [];
164
+      this.$emit('onClearSelected');
165
+    },
135 166
     isSelected(i) {
136
-      return _.some(this.selectedItems, x => x === i);
167
+      const ind = this.getActualIndex(i);
168
+      return _.some(this.selectedItems, x => x === ind);
137 169
     },
138 170
     onNew() {
139 171
       this.$emit('onNew');
@@ -148,15 +180,19 @@ export default {
148 180
       this.$emit('onDelete', item);
149 181
     },
150 182
     onRowClick(item, i) {
151
-      if (_.some(this.selectedItems, x => x === i)) {
152
-        this.selectedItems = this.selectedItems.filter(value => value !== i);
183
+      const ind = this.getActualIndex(i);
184
+      if (_.some(this.selectedItems, x => x === ind)) {
185
+        this.selectedItems = this.selectedItems.filter(x => x !== ind);
153 186
       } else {
154 187
         if (!this.allowMultipleSelect) {
155 188
           this.selectedItems = [];
156 189
         }
157
-        this.selectedItems.push(i);
190
+        this.selectedItems.push(ind);
158 191
       }
159
-      this.$emit('onRowClick', item);
192
+      this.$emit('onRowClick', this.selectedItems);
193
+    },
194
+    getActualIndex(index) {
195
+      return (this.currentPage - 1) * this.visibleItemsPerPageCount + index;
160 196
     },
161 197
     changeColumn(title, checked) {
162 198
       if (checked) {
@@ -285,4 +321,22 @@ th[draggable] a {
285 321
 .selected:hover {
286 322
   background-color: rgba(96, 203, 235, 0.85);
287 323
 }
324
+.btn-width {
325
+  width: 125px;
326
+}
327
+.table-title {
328
+  padding: 5px;
329
+  border: rgba(200, 200, 200, 0.66) double 2px;
330
+  border-radius: 5px;
331
+  background-color: rgba(96, 203, 235, 0.25);
332
+}
333
+.table-title:hover {
334
+  background-color: rgba(96, 203, 235, 0.4);
335
+}
336
+.table-header {
337
+  background-color: rgba(200, 200, 200, 0.66);
338
+}
339
+.my-table {
340
+  border: rgba(150, 150, 150, 0.75) 3px double;
341
+}
288 342
 </style>

Loading…
İptal
Kaydet