|
@@ -17,9 +17,26 @@
|
17
|
17
|
<table class="table table-striped table-responsive">
|
18
|
18
|
<thead>
|
19
|
19
|
<tr>
|
20
|
|
- <th scope="col">Owner</th>
|
21
|
|
- <th scope="col">Reference</th>
|
22
|
|
- <th scope="col">Property</th>
|
|
20
|
+ <th scope="col" v-for="(col, c) in displayColumns" :key="c">
|
|
21
|
+ <div @click="sortBy(columns[c])" style="cursor: pointer;">
|
|
22
|
+ <div class="d-flex bd-highlight">
|
|
23
|
+ <div class="w-100 bd-highlight">{{ col }}</div>
|
|
24
|
+ <div class="flex-shrink-1 bd-highlight">
|
|
25
|
+ <img
|
|
26
|
+ src="../../../../public/img/sort-up.png"
|
|
27
|
+ height="8px;"
|
|
28
|
+ v-if="sortKey === columns[c] && reverse"
|
|
29
|
+ />
|
|
30
|
+ <img
|
|
31
|
+ src="../../../../public/img/sort-down.png"
|
|
32
|
+ height="8px;"
|
|
33
|
+ v-if="sortKey === columns[c] && !reverse"
|
|
34
|
+ />
|
|
35
|
+ </div>
|
|
36
|
+ </div>
|
|
37
|
+ </div>
|
|
38
|
+ </th>
|
|
39
|
+ <!-- <th scope="col">Property</th>
|
23
|
40
|
<th scope="col">Unit</th>
|
24
|
41
|
<th scope="col">Size</th>
|
25
|
42
|
<th scope="col">Price Ex VAT</th>
|
|
@@ -28,13 +45,13 @@
|
28
|
45
|
<th scope="col">Suburb</th>
|
29
|
46
|
<th scope="col">Status</th>
|
30
|
47
|
<th scope="col">Type</th>
|
31
|
|
- <th scope="col">Publish</th>
|
|
48
|
+ <th scope="col">Publish</th>-->
|
32
|
49
|
<th scope="col">Edit</th>
|
33
|
50
|
<th scope="col">Delete</th>
|
34
|
51
|
</tr>
|
35
|
52
|
</thead>
|
36
|
53
|
<tbody>
|
37
|
|
- <tr v-for="(item, i) in FilteredProperties" :key="i">
|
|
54
|
+ <tr v-for="(item, i) in DisplayItems" :key="i">
|
38
|
55
|
<td>{{ item.owner }}</td>
|
39
|
56
|
<td>{{ item.reference }}</td>
|
40
|
57
|
<td>{{ item.property }}</td>
|
|
@@ -73,6 +90,45 @@
|
73
|
90
|
</tr>
|
74
|
91
|
</tbody>
|
75
|
92
|
</table>
|
|
93
|
+ <div class="d-flex justify-content-between" v-if="showPager">
|
|
94
|
+ <div class="p-1">
|
|
95
|
+ {{
|
|
96
|
+ currentPage +
|
|
97
|
+ " / " +
|
|
98
|
+ PageCount +
|
|
99
|
+ (" - (" + FilteredProperties.length + " items)")
|
|
100
|
+ }}
|
|
101
|
+ </div>
|
|
102
|
+ <div class="p-1">
|
|
103
|
+ <BasePagination
|
|
104
|
+ :currentPage="currentPage"
|
|
105
|
+ :pageCount="PageCount"
|
|
106
|
+ @nextPage="pageChangeHandle('next')"
|
|
107
|
+ @previousPage="pageChangeHandle('previous')"
|
|
108
|
+ @loadPage="pageChangeHandle"
|
|
109
|
+ />
|
|
110
|
+ </div>
|
|
111
|
+ <div class="p-2">
|
|
112
|
+ <div class="d-flex flex-row">
|
|
113
|
+ <div>
|
|
114
|
+ <select
|
|
115
|
+ class="form-control uniSelect"
|
|
116
|
+ v-model="visibleItemsPerPageCount"
|
|
117
|
+ @change="onChangeItemsPerPage()"
|
|
118
|
+ >
|
|
119
|
+ <option v-for="(item, i) in itemsPerPageList" :key="i">{{ item }}</option>
|
|
120
|
+ </select>
|
|
121
|
+ </div>
|
|
122
|
+ </div>
|
|
123
|
+ </div>
|
|
124
|
+ </div>
|
|
125
|
+ <div class="p-2">
|
|
126
|
+ <div class="d-flex flex-row">
|
|
127
|
+ <div>
|
|
128
|
+ <button v-if="sortKey !== 'id'" class="btn-solid-blue" @click="ClearSort">Clear Sort</button>
|
|
129
|
+ </div>
|
|
130
|
+ </div>
|
|
131
|
+ </div>
|
76
|
132
|
</div>
|
77
|
133
|
</div>
|
78
|
134
|
<div v-if="wait" id="preloader"></div>
|
|
@@ -83,14 +139,54 @@
|
83
|
139
|
<script>
|
84
|
140
|
import { mapState, mapActions } from "vuex";
|
85
|
141
|
import Log from "../../../assets/Log";
|
|
142
|
+import BasePagination from "../../shared/basePagination";
|
|
143
|
+import ItemsPerPageList from "../../../assets/staticData/itemsPerPageFive";
|
86
|
144
|
import _ from "lodash";
|
87
|
145
|
|
88
|
146
|
export default {
|
|
147
|
+ components: {
|
|
148
|
+ BasePagination,
|
|
149
|
+ },
|
89
|
150
|
data() {
|
90
|
151
|
return {
|
|
152
|
+ hover: -1,
|
91
|
153
|
filter: undefined,
|
92
|
154
|
userId: Log.getUser().id,
|
93
|
155
|
wait: true,
|
|
156
|
+ showPager: true,
|
|
157
|
+ visibleItemsPerPageCount: 10,
|
|
158
|
+ itemsPerPageList: ItemsPerPageList,
|
|
159
|
+ currentPage: 1,
|
|
160
|
+ reverse: true,
|
|
161
|
+ sortKey: "id",
|
|
162
|
+ displayColumns: [
|
|
163
|
+ "Owner",
|
|
164
|
+ "Reference",
|
|
165
|
+ "Property",
|
|
166
|
+ "Unit",
|
|
167
|
+ "Size",
|
|
168
|
+ "Price Ex VAT",
|
|
169
|
+ "Region",
|
|
170
|
+ "Town",
|
|
171
|
+ "Suburb",
|
|
172
|
+ "Status",
|
|
173
|
+ "Type",
|
|
174
|
+ "Publish",
|
|
175
|
+ ],
|
|
176
|
+ columns: [
|
|
177
|
+ "owner",
|
|
178
|
+ "reference",
|
|
179
|
+ "property",
|
|
180
|
+ "unit",
|
|
181
|
+ "size",
|
|
182
|
+ "price",
|
|
183
|
+ "region",
|
|
184
|
+ "town",
|
|
185
|
+ "suburb",
|
|
186
|
+ "status",
|
|
187
|
+ "type",
|
|
188
|
+ "isPublished",
|
|
189
|
+ ],
|
94
|
190
|
};
|
95
|
191
|
},
|
96
|
192
|
methods: {
|
|
@@ -112,6 +208,26 @@ export default {
|
112
|
208
|
Delete(item) {
|
113
|
209
|
this.deleteProperty(item.id);
|
114
|
210
|
},
|
|
211
|
+ async pageChangeHandle(value) {
|
|
212
|
+ switch (value) {
|
|
213
|
+ case "next":
|
|
214
|
+ this.currentPage += 1;
|
|
215
|
+ break;
|
|
216
|
+ case "previous":
|
|
217
|
+ this.currentPage -= 1;
|
|
218
|
+ break;
|
|
219
|
+ default:
|
|
220
|
+ this.currentPage = value;
|
|
221
|
+ }
|
|
222
|
+ },
|
|
223
|
+ sortBy(sortKey) {
|
|
224
|
+ this.reverse = this.sortKey === sortKey ? !this.reverse : false;
|
|
225
|
+ this.sortKey = sortKey;
|
|
226
|
+ },
|
|
227
|
+ ClearSort() {
|
|
228
|
+ this.reverse = true;
|
|
229
|
+ this.sortKey = "id";
|
|
230
|
+ },
|
115
|
231
|
},
|
116
|
232
|
computed: {
|
117
|
233
|
...mapState("propertyList", ["properties"]),
|
|
@@ -125,18 +241,49 @@ export default {
|
125
|
241
|
.indexOf(this.filter.toLowerCase()) > -1
|
126
|
242
|
)
|
127
|
243
|
);
|
128
|
|
- return list;
|
|
244
|
+ return _.orderBy(list, this.sortKey, this.SortDirection);
|
129
|
245
|
} else {
|
130
|
|
- return this.properties;
|
|
246
|
+ return _.orderBy(this.properties, this.sortKey, this.SortDirection);
|
131
|
247
|
}
|
132
|
248
|
},
|
|
249
|
+ PageCount() {
|
|
250
|
+ return this.visibleItemsPerPageCount !== 0
|
|
251
|
+ ? Math.ceil(
|
|
252
|
+ this.FilteredProperties.length / this.visibleItemsPerPageCount
|
|
253
|
+ )
|
|
254
|
+ : 1;
|
|
255
|
+ },
|
|
256
|
+ DisplayItems() {
|
|
257
|
+ const list = this.FilteredProperties;
|
|
258
|
+ const startSlice = (this.currentPage - 1) * this.visibleItemsPerPageCount;
|
|
259
|
+ let endSlice = this.currentPage * this.visibleItemsPerPageCount;
|
|
260
|
+ if (endSlice > list.length) {
|
|
261
|
+ endSlice = list.length;
|
|
262
|
+ }
|
|
263
|
+ return list.slice(startSlice, endSlice);
|
|
264
|
+ },
|
|
265
|
+ SortDirection() {
|
|
266
|
+ return this.reverse ? "desc" : "asc";
|
|
267
|
+ },
|
133
|
268
|
},
|
134
|
269
|
mounted() {
|
135
|
270
|
this.wait = true;
|
136
|
271
|
this.getAdminProperties(this.userId).then((fulfuilled) => {
|
137
|
272
|
this.wait = false;
|
|
273
|
+ if (this.itemsPerPageList && this.itemsPerPageList.length > 0) {
|
|
274
|
+ const [startItem] = this.itemsPerPageList;
|
|
275
|
+ this.visibleItemsPerPageCount = startItem;
|
|
276
|
+ }
|
138
|
277
|
});
|
139
|
278
|
},
|
|
279
|
+ // watch: {
|
|
280
|
+ // sortKey: {
|
|
281
|
+ // immediate: true,
|
|
282
|
+ // handler(val, oldVal) {
|
|
283
|
+ // return this.FilteredProperties;
|
|
284
|
+ // },
|
|
285
|
+ // },
|
|
286
|
+ // },
|
140
|
287
|
};
|
141
|
288
|
</script>
|
142
|
289
|
|