|
@@ -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>
|