ソースを参照

Listview & timeshare admin

master
Kobus 5年前
コミット
dfe1290524
2個のファイルの変更130行の追加14行の削除
  1. 63
    1
      src/components/admin/status/timeshareAdminPage.vue
  2. 67
    13
      src/components/shared/listView.vue

+ 63
- 1
src/components/admin/status/timeshareAdminPage.vue ファイルの表示

6
     <br />
6
     <br />
7
     <br />
7
     <br />
8
     <div class="row">
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
       <div class="offset-1 col-md-10">
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
       </div>
27
       </div>
12
     </div>
28
     </div>
13
   </div>
29
   </div>
25
   data() {
41
   data() {
26
     return {
42
     return {
27
       user: Log.getUser(),
43
       user: Log.getUser(),
44
+      selectedItems: [],
45
+      showMessage: false,
28
     };
46
     };
29
   },
47
   },
30
   mounted() {
48
   mounted() {
32
     this.getItems(this.user.id);
50
     this.getItems(this.user.id);
33
   },
51
   },
34
   computed: {
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
     ...mapState('myWeeks', ['items']),
83
     ...mapState('myWeeks', ['items']),
36
   },
84
   },
37
   methods: {
85
   methods: {
38
     ...mapActions('myWeeks', ['getItems']),
86
     ...mapActions('myWeeks', ['getItems']),
87
+    onRowClick(items) {
88
+      this.selectedItems = items;
89
+    },
39
     onEdit(item) {
90
     onEdit(item) {
40
       this.$router.push(`/timeshare/${item.id}`);
91
       this.$router.push(`/timeshare/${item.id}`);
41
     },
92
     },
93
+    onClearSelected() {
94
+      this.selectedItems = [];
95
+    },
42
   },
96
   },
43
 };
97
 };
44
 </script>
98
 </script>
45
 
99
 
46
 
100
 
47
 <style>
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
 </style>
110
 </style>

+ 67
- 13
src/components/shared/listView.vue ファイルの表示

2
 /* eslint-disable guard-for-in */
2
 /* eslint-disable guard-for-in */
3
 <template>
3
 <template>
4
   <div>
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
       <div class="p-2" v-if="!hideSearch">
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
       </div>
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
       </div>
25
       </div>
12
     </div>
26
     </div>
27
+    <div style="height:5px"></div>
13
     <div v-if="items && items.length > 0" class="table-responsive">
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
           <tr class="dnd-moved">
34
           <tr class="dnd-moved">
17
             <th v-for="(column, c) in Columns" :key="c">
35
             <th v-for="(column, c) in Columns" :key="c">
18
               <div @click="sortBy(column)">{{ column }}</div>
36
               <div @click="sortBy(column)">{{ column }}</div>
21
             <th v-if="deleteable"></th>
39
             <th v-if="deleteable"></th>
22
           </tr>
40
           </tr>
23
         </thead>
41
         </thead>
24
-        <tbody>
42
+        <tbody class="my-table">
25
           <tr
43
           <tr
26
             v-for="(item, i) in DisplayItems"
44
             v-for="(item, i) in DisplayItems"
27
             :key="i"
45
             :key="i"
41
           </tr>
59
           </tr>
42
         </tbody>
60
         </tbody>
43
       </table>
61
       </table>
44
-      <div class="d-flex justify-content-between">
62
+      <div class="d-flex justify-content-between" v-if="showPager">
45
         <div class="p-1">{{ currentPage + ' / ' + PageCount }}</div>
63
         <div class="p-1">{{ currentPage + ' / ' + PageCount }}</div>
46
         <div class="p-1">
64
         <div class="p-1">
47
           <BasePagination
65
           <BasePagination
96
     }
114
     }
97
   },
115
   },
98
   props: {
116
   props: {
117
+    compact: {
118
+      default: true,
119
+    },
99
     allowSelect: {
120
     allowSelect: {
100
       default: true,
121
       default: true,
101
     },
122
     },
118
     columnsCount: {
139
     columnsCount: {
119
       default: 6,
140
       default: 6,
120
     },
141
     },
142
+    showPager: {
143
+      default: true,
144
+    },
145
+    title: {
146
+      default: undefined,
147
+    },
121
   },
148
   },
122
   data() {
149
   data() {
123
     return {
150
     return {
132
     };
159
     };
133
   },
160
   },
134
   methods: {
161
   methods: {
162
+    onClearSelected() {
163
+      this.selectedItems = [];
164
+      this.$emit('onClearSelected');
165
+    },
135
     isSelected(i) {
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
     onNew() {
170
     onNew() {
139
       this.$emit('onNew');
171
       this.$emit('onNew');
148
       this.$emit('onDelete', item);
180
       this.$emit('onDelete', item);
149
     },
181
     },
150
     onRowClick(item, i) {
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
       } else {
186
       } else {
154
         if (!this.allowMultipleSelect) {
187
         if (!this.allowMultipleSelect) {
155
           this.selectedItems = [];
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
     changeColumn(title, checked) {
197
     changeColumn(title, checked) {
162
       if (checked) {
198
       if (checked) {
285
 .selected:hover {
321
 .selected:hover {
286
   background-color: rgba(96, 203, 235, 0.85);
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
 </style>
342
 </style>

読み込み中…
キャンセル
保存