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.

propertyList.vue 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <section id="contact2">
  3. <div class="container">
  4. <div class="section-header">
  5. <h1>Property Admin</h1>
  6. </div>
  7. <div class="row">
  8. <div class="col-lg-6 offset-3">
  9. <input class="form-control uniSelect" type="text" placeholder="SEARCH" v-model="filter" />
  10. </div>
  11. </div>
  12. <div class="row">
  13. <br />
  14. </div>
  15. <div class="row">
  16. <div class="col-lg-12">
  17. <table class="table table-striped table-responsive">
  18. <thead>
  19. <tr>
  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>
  40. <th scope="col">Unit</th>
  41. <th scope="col">Size</th>
  42. <th scope="col">Price Ex VAT</th>
  43. <th scope="col">Region</th>
  44. <th scope="col">Town</th>
  45. <th scope="col">Suburb</th>
  46. <th scope="col">Status</th>
  47. <th scope="col">Type</th>
  48. <th scope="col">Publish</th>-->
  49. <th scope="col">Edit</th>
  50. <th scope="col">Delete</th>
  51. </tr>
  52. </thead>
  53. <tbody>
  54. <tr v-for="(item, i) in DisplayItems" :key="i">
  55. <td>{{ item.owner }}</td>
  56. <td>{{ item.reference }}</td>
  57. <td>{{ item.property }}</td>
  58. <td>{{ item.unit }}</td>
  59. <td>{{ item.size }}</td>
  60. <td>{{ item.price | toCurrency }}</td>
  61. <td>{{ item.region }}</td>
  62. <td>{{ item.town }}</td>
  63. <td>{{ item.suburb }}</td>
  64. <td>{{ item.status }}</td>
  65. <td>{{ item.type }}</td>
  66. <td v-if="!item.isPublished">
  67. <a v-on:click="Publish(item)">
  68. <img src="../../../../public/img/icons/Upload.png" height="25" width="25" />
  69. </a>
  70. </td>
  71. <td v-else>
  72. <a v-on:click="Unpublish(item)">
  73. <img
  74. src="../../../../public/img/icons/Download-grey.png"
  75. height="25"
  76. width="25"
  77. />
  78. </a>
  79. </td>
  80. <td>
  81. <a v-on:click="Edit(item)">
  82. <img src="../../../../public/img/icons/Edit.png" height="25" width="25" />
  83. </a>
  84. </td>
  85. <td>
  86. <a v-on:click="Delete(item)">
  87. <img src="../../../../public/img/icons/delete.png" height="25" width="25" />
  88. </a>
  89. </td>
  90. </tr>
  91. </tbody>
  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>
  132. </div>
  133. </div>
  134. <div v-if="wait" id="preloader"></div>
  135. </div>
  136. </section>
  137. </template>
  138. <script>
  139. import { mapState, mapActions } from "vuex";
  140. import Log from "../../../assets/Log";
  141. import BasePagination from "../../shared/basePagination";
  142. import ItemsPerPageList from "../../../assets/staticData/itemsPerPageFive";
  143. import _ from "lodash";
  144. export default {
  145. components: {
  146. BasePagination,
  147. },
  148. data() {
  149. return {
  150. hover: -1,
  151. filter: undefined,
  152. userId: Log.getUser().id,
  153. wait: true,
  154. showPager: true,
  155. visibleItemsPerPageCount: 10,
  156. itemsPerPageList: ItemsPerPageList,
  157. currentPage: 1,
  158. reverse: true,
  159. sortKey: "id",
  160. displayColumns: [
  161. "Owner",
  162. "Reference",
  163. "Property",
  164. "Unit",
  165. "Size",
  166. "Price Ex VAT",
  167. "Region",
  168. "Town",
  169. "Suburb",
  170. "Status",
  171. "Type",
  172. "Publish",
  173. ],
  174. columns: [
  175. "owner",
  176. "reference",
  177. "property",
  178. "unit",
  179. "size",
  180. "price",
  181. "region",
  182. "town",
  183. "suburb",
  184. "status",
  185. "type",
  186. "isPublished",
  187. ],
  188. };
  189. },
  190. methods: {
  191. ...mapActions("propertyList", [
  192. "getAdminProperties",
  193. "deleteProperty",
  194. "publishProperty",
  195. "unpublishProperty",
  196. ]),
  197. Publish(item) {
  198. this.publishProperty(item);
  199. },
  200. Unpublish(item) {
  201. this.unpublishProperty(item);
  202. },
  203. Edit(item) {
  204. this.$router.push(`/property/edit/${item.id}`);
  205. },
  206. Delete(item) {
  207. this.deleteProperty(item.id);
  208. },
  209. async pageChangeHandle(value) {
  210. switch (value) {
  211. case "next":
  212. this.currentPage += 1;
  213. break;
  214. case "previous":
  215. this.currentPage -= 1;
  216. break;
  217. default:
  218. this.currentPage = value;
  219. }
  220. },
  221. sortBy(sortKey) {
  222. this.reverse = this.sortKey === sortKey ? !this.reverse : false;
  223. this.sortKey = sortKey;
  224. },
  225. ClearSort() {
  226. this.reverse = true;
  227. this.sortKey = "id";
  228. },
  229. },
  230. computed: {
  231. ...mapState("propertyList", ["properties"]),
  232. FilteredProperties() {
  233. if (this.filter) {
  234. const list = _.filter(this.properties, (item) =>
  235. Object.values(item).some(
  236. (i) =>
  237. JSON.stringify(i)
  238. .toLowerCase()
  239. .indexOf(this.filter.toLowerCase()) > -1
  240. )
  241. );
  242. return _.orderBy(list, this.sortKey, this.SortDirection);
  243. } else {
  244. return _.orderBy(this.properties, this.sortKey, this.SortDirection);
  245. }
  246. },
  247. PageCount() {
  248. return this.visibleItemsPerPageCount !== 0
  249. ? Math.ceil(
  250. this.FilteredProperties.length / this.visibleItemsPerPageCount
  251. )
  252. : 1;
  253. },
  254. DisplayItems() {
  255. const list = this.FilteredProperties;
  256. const startSlice = (this.currentPage - 1) * this.visibleItemsPerPageCount;
  257. let endSlice = this.currentPage * this.visibleItemsPerPageCount;
  258. if (endSlice > list.length) {
  259. endSlice = list.length;
  260. }
  261. return list.slice(startSlice, endSlice);
  262. },
  263. SortDirection() {
  264. return this.reverse ? "desc" : "asc";
  265. },
  266. },
  267. mounted() {
  268. this.wait = true;
  269. this.getAdminProperties(this.userId).then((fulfuilled) => {
  270. this.wait = false;
  271. if (this.itemsPerPageList && this.itemsPerPageList.length > 0) {
  272. const [startItem] = this.itemsPerPageList;
  273. this.visibleItemsPerPageCount = startItem;
  274. }
  275. });
  276. },
  277. // watch: {
  278. // sortKey: {
  279. // immediate: true,
  280. // handler(val, oldVal) {
  281. // return this.FilteredProperties;
  282. // },
  283. // },
  284. // },
  285. };
  286. </script>
  287. <style lang="scss" scoped>
  288. .refbyAgent {
  289. will-change: transform;
  290. transition: height 500ms;
  291. height: 0px;
  292. }
  293. .refbyAgent--clicked {
  294. height: 150px;
  295. }
  296. .spacebanked1 {
  297. will-change: transform;
  298. transition: height 500ms;
  299. height: 0px;
  300. }
  301. .spacebanked1--clicked {
  302. height: 150px;
  303. }
  304. .custom-file-label {
  305. border-width: 2px;
  306. border-color: rgb(27, 117, 187);
  307. margin-bottom: 20px;
  308. }
  309. .custom-file-label::after {
  310. border-left: none;
  311. border-bottom: solid;
  312. border-width: 2px;
  313. border-color: rgb(27, 117, 187);
  314. font-family: "Muli";
  315. }
  316. </style>