You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

myWeeksPage.vue 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <!-- eslint-disable max-len -->
  3. <main id="main" style="margin-top: -30px; padding-bottom: 50px;">
  4. <div class="container">
  5. <div class="row">
  6. <div class="col">
  7. <div class="section-header" style="">
  8. <h2>My Timeshare Weeks</h2>
  9. </div>
  10. </div>
  11. </div>
  12. </div>
  13. <div class="container-fluid">
  14. <div class="row justify-content-center">
  15. <div class="col-auto">
  16. <table
  17. class="table table-striped table-responsive"
  18. style="max-width: 1920px;"
  19. >
  20. <thead>
  21. <tr>
  22. <th scope="col" v-for="(col, c) in displayColumns" :key="c">
  23. <div @click="sortBy(columns[c])" style="cursor: pointer;">
  24. <div class="d-flex bd-highlight">
  25. <div class="w-100 bd-highlight">{{ col }}</div>
  26. <div class="flex-shrink-1 bd-highlight">
  27. <img
  28. src="../../../public/img/sort-up.png"
  29. height="8px;"
  30. v-if="sortKey === columns[c] && reverse"
  31. />
  32. <img
  33. src="../../../public/img/sort-down.png"
  34. height="8px;"
  35. v-if="sortKey === columns[c] && !reverse"
  36. />
  37. </div>
  38. </div>
  39. </div>
  40. </th>
  41. <!-- <th scope="col">Property</th>
  42. <th scope="col">Unit</th>
  43. <th scope="col">Size</th>
  44. <th scope="col">Price Ex VAT</th>
  45. <th scope="col">Region</th>
  46. <th scope="col">Town</th>
  47. <th scope="col">Suburb</th>
  48. <th scope="col">Status</th>
  49. <th scope="col">Type</th>-->
  50. <th scope="col">Edit</th>
  51. <th scope="col">Delete</th>
  52. </tr>
  53. </thead>
  54. <tbody>
  55. <tr v-for="(item, i) in DisplayItems" :key="i">
  56. <td>#{{ item.id }}</td>
  57. <td>{{ item.owner }}</td>
  58. <td>{{ item.agent }}</td>
  59. <td>{{ item.resort.resortName }}</td>
  60. <td>{{ item.module }}</td>
  61. <td>{{ item.unitNumber }}</td>
  62. <td>{{ item.bedrooms }}</td>
  63. <td>{{ item.season }}</td>
  64. <td>{{ item.region.regionName }}</td>
  65. <td>{{ item.sellPrice | toCurrency }}</td>
  66. <td>{{ item.pulbishedDate | toDate }}</td>
  67. <td>{{ item.status.description }}</td>
  68. <td>{{ item.consent }}</td>
  69. <!-- <td v-if="!item.publish">
  70. <a v-on:click="Publish(item)">
  71. <img src="../../../public/img/icons/Upload.png" height="25" width="25" />
  72. </a>
  73. </td>
  74. <td v-else>
  75. <a v-on:click="Unpublish(item)">
  76. <img src="../../../public/img/icons/Download-grey.png" height="25" width="25" />
  77. </a>
  78. </td> -->
  79. <td>
  80. <a v-on:click="Edit(item)">
  81. <img
  82. src="../../../public/img/icons/Edit.png"
  83. height="25"
  84. width="25"
  85. />
  86. </a>
  87. </td>
  88. <td>
  89. <a v-on:click="Delete(item)">
  90. <img
  91. src="../../../public/img/icons/delete.png"
  92. height="25"
  93. width="25"
  94. />
  95. </a>
  96. </td>
  97. </tr>
  98. </tbody>
  99. </table>
  100. <div class="d-flex justify-content-between" v-if="showPager">
  101. <div class="p-1">
  102. {{
  103. currentPage +
  104. ' / ' +
  105. PageCount +
  106. (' - (' + FilteredListings.length + ' items)')
  107. }}
  108. </div>
  109. <div class="p-1">
  110. <BasePagination
  111. :currentPage="currentPage"
  112. :pageCount="PageCount"
  113. @nextPage="pageChangeHandle('next')"
  114. @previousPage="pageChangeHandle('previous')"
  115. @loadPage="pageChangeHandle"
  116. />
  117. </div>
  118. <div class="p-2">
  119. <div class="d-flex flex-row">
  120. <div>
  121. <select
  122. class="form-control uniSelect"
  123. v-model="visibleItemsPerPageCount"
  124. @change="onChangeItemsPerPage()"
  125. >
  126. <option v-for="(item, i) in itemsPerPageList" :key="i">
  127. {{ item }}
  128. </option>
  129. </select>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. <div class="p-2">
  135. <div class="d-flex flex-row">
  136. <div>
  137. <button
  138. v-if="sortKey !== 'id'"
  139. class="btn-solid-blue"
  140. @click="ClearSort"
  141. >
  142. Clear Sort
  143. </button>
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. <div v-if="wait" id="preloader"></div>
  150. </div>
  151. <!-- <div class="row">
  152. <div class="offset-1 col-md-3">
  153. {{ items[selectedItems] }}
  154. <button
  155. type="button"
  156. :class="{
  157. 'form-control btn-solid-blue ': 1 === 1,
  158. 'my-disable':
  159. !(selectedItems.length == 1) ||
  160. !items[selectedItems] ||
  161. items[selectedItems].status.code !== 'A2'
  162. }"
  163. value="Publish Week"
  164. :disabled="!(items.length == 1)"
  165. >
  166. Publish selected week
  167. </button>
  168. </div>
  169. <div class="offset-1 col-md-10">
  170. <ListView
  171. :items="items"
  172. @onNew="onNew"
  173. @onRowClick="onRowClick"
  174. @onClearSelected="onClearSelected"
  175. />
  176. </div>
  177. </div> -->
  178. </main>
  179. </template>
  180. <script>
  181. /* eslint-disable */
  182. import { mapState, mapActions, mapGetters } from 'vuex'
  183. import Log from '../../assets/Log'
  184. import ListView from '../shared/listView.vue'
  185. import BasePagination from '../shared/basePagination'
  186. import ItemsPerPageList from '../../assets/staticData/itemsPerPageFive'
  187. import _ from 'lodash'
  188. export default {
  189. components: {
  190. ListView,
  191. BasePagination,
  192. },
  193. data() {
  194. return {
  195. filter: undefined,
  196. wait: true,
  197. showPager: true,
  198. visibleItemsPerPageCount: 10,
  199. itemsPerPageList: ItemsPerPageList,
  200. reverse: true,
  201. currentPage: 1,
  202. sortKey: 'id',
  203. displayColumns: [
  204. 'Ref',
  205. 'Owner',
  206. 'Agent',
  207. 'Resort',
  208. 'Week Module',
  209. 'Unit',
  210. 'Beds',
  211. 'Season',
  212. 'Region',
  213. 'Amount',
  214. 'Submitted',
  215. 'Status',
  216. 'Consent',
  217. ],
  218. columns: [
  219. 'id',
  220. 'owner',
  221. 'agent',
  222. 'resort',
  223. 'module',
  224. 'unitNumber',
  225. 'bedrooms',
  226. 'season',
  227. 'region',
  228. 'sellPrice',
  229. 'weekStatus',
  230. 'consent',
  231. ],
  232. }
  233. },
  234. created() {
  235. this.getItems(Log.getUser().id).then(() => {
  236. this.wait = false
  237. })
  238. },
  239. mounted() {},
  240. computed: {
  241. ...mapGetters({ getNeedsVerify: 'myWeeks/getNeedsVerify' }),
  242. ...mapState('myWeeks', ['items']),
  243. FilteredListings() {
  244. if (this.filter) {
  245. const list = _.filter(this.getNeedsVerify, (item) =>
  246. Object.values(item).some(
  247. (i) =>
  248. JSON.stringify(i)
  249. .toLowerCase()
  250. .indexOf(this.filter.toLowerCase()) > -1,
  251. ),
  252. )
  253. return _.orderBy(list, this.sortKey, this.SortDirection)
  254. } else {
  255. return _.orderBy(this.getNeedsVerify, this.sortKey, this.SortDirection)
  256. }
  257. },
  258. PageCount() {
  259. return this.visibleItemsPerPageCount !== 0
  260. ? Math.ceil(this.items.length / this.visibleItemsPerPageCount)
  261. : 1
  262. },
  263. DisplayItems() {
  264. const list = this.FilteredListings
  265. const startSlice = (this.currentPage - 1) * this.visibleItemsPerPageCount
  266. let endSlice = this.currentPage * this.visibleItemsPerPageCount
  267. if (endSlice > list.length) {
  268. endSlice = list.length
  269. }
  270. return list.slice(startSlice, endSlice)
  271. },
  272. SortDirection() {
  273. return this.reverse ? 'desc' : 'asc'
  274. },
  275. },
  276. methods: {
  277. ...mapActions('myWeeks', ['getItems']),
  278. onEdit(item) {
  279. this.$router.push(`/timeshare/${item.id}`)
  280. },
  281. onNew() {
  282. this.$router.push('/timeshare/sell')
  283. },
  284. onRowClick(items) {
  285. this.selectedItems = items
  286. },
  287. onClearSelected() {
  288. this.selectedItems = []
  289. },
  290. Edit(item) {
  291. this.$router.push({ name: 'EditTimeshare', params: { weekParam: item } })
  292. // this.$router.push(`/editTimeShare/${item.id}`);
  293. },
  294. Delete(item) {
  295. this.deleteListing(item.id)
  296. },
  297. async pageChangeHandle(value) {
  298. switch (value) {
  299. case 'next':
  300. this.currentPage += 1
  301. break
  302. case 'previous':
  303. this.currentPage -= 1
  304. break
  305. default:
  306. this.currentPage = value
  307. }
  308. },
  309. sortBy(sortKey) {
  310. this.reverse = this.sortKey === sortKey ? !this.reverse : false
  311. this.sortKey = sortKey
  312. },
  313. ClearSort() {
  314. this.reverse = true
  315. this.sortKey = 'id'
  316. },
  317. },
  318. }
  319. </script>
  320. <style scoped>
  321. .my-disable {
  322. background-color: silver;
  323. border-color: silver;
  324. }
  325. .my-disable:hover {
  326. background-color: lightgray;
  327. border-color: lightgray;
  328. }
  329. </style>