123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- <template>
- <!-- eslint-disable max-len -->
- <main id="main" style="margin-top: -30px; padding-bottom: 50px;">
- <div class="container">
- <div class="row">
- <div class="col">
- <div class="section-header" style="">
- <h2>My Timeshare Weeks</h2>
- </div>
- </div>
- </div>
- </div>
- <div class="container-fluid">
- <div class="row justify-content-center">
- <div class="col-auto">
- <table
- class="table table-striped table-responsive"
- style="max-width: 1920px;"
- >
- <thead>
- <tr>
- <th scope="col" v-for="(col, c) in displayColumns" :key="c">
- <div @click="sortBy(columns[c])" style="cursor: pointer;">
- <div class="d-flex bd-highlight">
- <div class="w-100 bd-highlight">{{ col }}</div>
- <div class="flex-shrink-1 bd-highlight">
- <img
- src="../../../public/img/sort-up.png"
- height="8px;"
- v-if="sortKey === columns[c] && reverse"
- />
- <img
- src="../../../public/img/sort-down.png"
- height="8px;"
- v-if="sortKey === columns[c] && !reverse"
- />
- </div>
- </div>
- </div>
- </th>
- <!-- <th scope="col">Property</th>
- <th scope="col">Unit</th>
- <th scope="col">Size</th>
- <th scope="col">Price Ex VAT</th>
- <th scope="col">Region</th>
- <th scope="col">Town</th>
- <th scope="col">Suburb</th>
- <th scope="col">Status</th>
- <th scope="col">Type</th>-->
- <th scope="col">Edit</th>
- <th scope="col">Delete</th>
- </tr>
- </thead>
-
- <tbody>
- <tr v-for="(item, i) in DisplayItems" :key="i">
- <td>#{{ item.id }}</td>
- <td>{{ item.owner }}</td>
- <td>{{ item.agent }}</td>
- <td>{{ item.resort.resortName }}</td>
- <td>{{ item.module }}</td>
- <td>{{ item.unitNumber }}</td>
- <td>{{ item.bedrooms }}</td>
- <td>{{ item.season }}</td>
- <td>{{ item.region.regionName }}</td>
- <td>{{ item.sellPrice | toCurrency }}</td>
- <td>{{ item.pulbishedDate | toDate }}</td>
- <td>{{ item.status.description }}</td>
- <td>{{ item.consent }}</td>
- <!-- <td v-if="!item.publish">
- <a v-on:click="Publish(item)">
- <img src="../../../public/img/icons/Upload.png" height="25" width="25" />
- </a>
- </td>
- <td v-else>
- <a v-on:click="Unpublish(item)">
- <img src="../../../public/img/icons/Download-grey.png" height="25" width="25" />
- </a>
- </td> -->
- <td>
- <a v-on:click="Edit(item)">
- <img
- src="../../../public/img/icons/Edit.png"
- height="25"
- width="25"
- />
- </a>
- </td>
- <td>
- <a v-on:click="Delete(item)">
- <img
- src="../../../public/img/icons/delete.png"
- height="25"
- width="25"
- />
- </a>
- </td>
- </tr>
- </tbody>
- </table>
- <div class="d-flex justify-content-between" v-if="showPager">
- <div class="p-1">
- {{
- currentPage +
- ' / ' +
- PageCount +
- (' - (' + FilteredListings.length + ' items)')
- }}
- </div>
- <div class="p-1">
- <BasePagination
- :currentPage="currentPage"
- :pageCount="PageCount"
- @nextPage="pageChangeHandle('next')"
- @previousPage="pageChangeHandle('previous')"
- @loadPage="pageChangeHandle"
- />
- </div>
- <div class="p-2">
- <div class="d-flex flex-row">
- <div>
- <select
- class="form-control uniSelect"
- v-model="visibleItemsPerPageCount"
- @change="onChangeItemsPerPage()"
- >
- <option v-for="(item, i) in itemsPerPageList" :key="i">
- {{ item }}
- </option>
- </select>
- </div>
- </div>
- </div>
- </div>
- <div class="p-2">
- <div class="d-flex flex-row">
- <div>
- <button
- v-if="sortKey !== 'id'"
- class="btn-solid-blue"
- @click="ClearSort"
- >
- Clear Sort
- </button>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div v-if="wait" id="preloader"></div>
- </div>
-
- <!-- <div class="row">
- <div class="offset-1 col-md-3">
- {{ items[selectedItems] }}
- <button
- type="button"
- :class="{
- 'form-control btn-solid-blue ': 1 === 1,
- 'my-disable':
- !(selectedItems.length == 1) ||
- !items[selectedItems] ||
- items[selectedItems].status.code !== 'A2'
- }"
- value="Publish Week"
- :disabled="!(items.length == 1)"
- >
- Publish selected week
- </button>
- </div>
- <div class="offset-1 col-md-10">
- <ListView
- :items="items"
- @onNew="onNew"
- @onRowClick="onRowClick"
- @onClearSelected="onClearSelected"
- />
- </div>
- </div> -->
- </main>
- </template>
- <script>
- /* eslint-disable */
- import { mapState, mapActions, mapGetters } from 'vuex'
- import Log from '../../assets/Log'
- import ListView from '../shared/listView.vue'
- import BasePagination from '../shared/basePagination'
- import ItemsPerPageList from '../../assets/staticData/itemsPerPageFive'
- import _ from 'lodash'
-
- export default {
- components: {
- ListView,
- BasePagination,
- },
- data() {
- return {
- filter: undefined,
- wait: true,
- showPager: true,
- visibleItemsPerPageCount: 10,
- itemsPerPageList: ItemsPerPageList,
- reverse: true,
- currentPage: 1,
- sortKey: 'id',
- displayColumns: [
- 'Ref',
- 'Owner',
- 'Agent',
- 'Resort',
- 'Week Module',
- 'Unit',
- 'Beds',
- 'Season',
- 'Region',
- 'Amount',
- 'Submitted',
- 'Status',
- 'Consent',
- ],
- columns: [
- 'id',
- 'owner',
- 'agent',
- 'resort',
- 'module',
- 'unitNumber',
- 'bedrooms',
- 'season',
- 'region',
- 'sellPrice',
- 'weekStatus',
- 'consent',
- ],
- }
- },
- created() {
- this.getItems(Log.getUser().id).then(() => {
- this.wait = false
- })
- },
- mounted() {},
- computed: {
- ...mapGetters({ getNeedsVerify: 'myWeeks/getNeedsVerify' }),
- ...mapState('myWeeks', ['items']),
- FilteredListings() {
- if (this.filter) {
- const list = _.filter(this.getNeedsVerify, (item) =>
- Object.values(item).some(
- (i) =>
- JSON.stringify(i)
- .toLowerCase()
- .indexOf(this.filter.toLowerCase()) > -1,
- ),
- )
- return _.orderBy(list, this.sortKey, this.SortDirection)
- } else {
- return _.orderBy(this.getNeedsVerify, this.sortKey, this.SortDirection)
- }
- },
- PageCount() {
- return this.visibleItemsPerPageCount !== 0
- ? Math.ceil(this.items.length / this.visibleItemsPerPageCount)
- : 1
- },
- DisplayItems() {
- const list = this.FilteredListings
- const startSlice = (this.currentPage - 1) * this.visibleItemsPerPageCount
- let endSlice = this.currentPage * this.visibleItemsPerPageCount
- if (endSlice > list.length) {
- endSlice = list.length
- }
- return list.slice(startSlice, endSlice)
- },
- SortDirection() {
- return this.reverse ? 'desc' : 'asc'
- },
- },
- methods: {
- ...mapActions('myWeeks', ['getItems']),
- onEdit(item) {
- this.$router.push(`/timeshare/${item.id}`)
- },
- onNew() {
- this.$router.push('/timeshare/sell')
- },
- onRowClick(items) {
- this.selectedItems = items
- },
- onClearSelected() {
- this.selectedItems = []
- },
- Edit(item) {
- this.$router.push({ name: 'EditTimeshare', params: { weekParam: item } })
- // this.$router.push(`/editTimeShare/${item.id}`);
- },
- Delete(item) {
- this.deleteListing(item.id)
- },
- async pageChangeHandle(value) {
- switch (value) {
- case 'next':
- this.currentPage += 1
- break
- case 'previous':
- this.currentPage -= 1
- break
- default:
- this.currentPage = value
- }
- },
- sortBy(sortKey) {
- this.reverse = this.sortKey === sortKey ? !this.reverse : false
- this.sortKey = sortKey
- },
- ClearSort() {
- this.reverse = true
- this.sortKey = 'id'
- },
- },
- }
- </script>
- <style scoped>
- .my-disable {
- background-color: silver;
- border-color: silver;
- }
- .my-disable:hover {
- background-color: lightgray;
- border-color: lightgray;
- }
- </style>
|