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.

191 lines
5.7 KiB

2 years ago
  1. <template>
  2. <v-card class="border-radius-20" flat min-width="900px" max-width="900px">
  3. <v-spacer class="px-7 pt-7">
  4. <v-spacer class="d-flex align-center mb-7">
  5. <div class="circle-decoration me-2"></div>
  6. <div class="circle-decoration me-2"></div>
  7. <span class="font-weight-bold text-size-20 ms-7 text-height-26">{{ $t("userProfile.savedExhibitions") }}</span>
  8. </v-spacer>
  9. <v-spacer>
  10. <v-spacer class="mb-2">
  11. <span class="filter-title-font">{{ $t("userProfile.savedExhibitionsFilter") }}</span>
  12. </v-spacer>
  13. <v-spacer class="d-flex mb-7">
  14. <div class="input-country-wrap me-5">
  15. <v-autocomplete
  16. solo flat
  17. hide-details
  18. dense
  19. :items="countryOptions"
  20. item-text="name"
  21. item-value="id"
  22. v-model="countrySelect"
  23. class="input-border"
  24. ></v-autocomplete>
  25. </div>
  26. </v-spacer>
  27. <v-spacer class="d-flex justify-center mt-15 mb-7">
  28. <div v-if="userRenderList.length === 0">
  29. <v-img
  30. :src="require('~/assets/img/savedExhibitionEmpty.png')"
  31. contain
  32. max-width="210px"
  33. max-height="153px"
  34. ></v-img>
  35. <div class="d-flex justify-center">
  36. <span class="empty-exhibitions-font">{{ $t("userProfile.noSavedExhibitions") }}</span>
  37. </div>
  38. </div>
  39. <v-spacer v-else>
  40. <ExhibitionListCard
  41. v-for="(exhibition,index) in userRenderList.slice((this.page-1)*6,this.page*6)" :key="index"
  42. :item="exhibition"
  43. @toggle-favorite="removeExhibitionRelation(index)"
  44. ></ExhibitionListCard>
  45. </v-spacer>
  46. </v-spacer>
  47. </v-spacer>
  48. <v-spacer
  49. class="d-flex justify-center pb-7 pt-5"
  50. v-if="userRenderList.length === 0"
  51. >
  52. <v-btn
  53. class="border-radius-12 text-capitalize"
  54. color="primary"
  55. :to="localePath('/')"
  56. >
  57. {{ $t("Explore with ShowEasy") }}
  58. </v-btn>
  59. </v-spacer>
  60. <v-spacer
  61. v-else
  62. class="d-flex justify-end pb-15"
  63. >
  64. <v-pagination
  65. class="mt-15"
  66. :total-visible="7"
  67. :length="userRenderListLength"
  68. v-model="page"
  69. ></v-pagination>
  70. </v-spacer>
  71. </v-spacer>
  72. </v-card>
  73. </template>
  74. <script>
  75. import ExhibitionListCard from "~/components/exhibition/ExhibitionListCard.vue";
  76. export default {
  77. props: {
  78. userVisibleExhibitionList: {
  79. type: Array,
  80. required: true,
  81. default: []
  82. },
  83. pageLength: {
  84. type: Number,
  85. required: true,
  86. default: 0
  87. }
  88. },
  89. data() {
  90. return {
  91. page:1,
  92. countryOptions: [],
  93. countryOptionsCopy: [],
  94. countrySelect: 999,
  95. statusOptions: [],
  96. statusSelect: 100,
  97. userRenderList: [],
  98. userRenderListLength: 0,
  99. buildCountryOptions: true,
  100. }
  101. },
  102. created() {
  103. // this.$axios.get(`users/countries?lang=${this.$i18n.locale.replace('-','')}`)
  104. // .then((result) => {
  105. // const initial = {
  106. // name: this.$t('userProfile.allCountries'),
  107. // id: 999
  108. // }
  109. // this.countryOptions = JSON.parse(JSON.stringify(result.data.result))
  110. // this.countryOptions.splice(0,0,initial)
  111. // }).catch((err) => {
  112. // console.log(err)
  113. // });
  114. // this.$axios.get(`exhibitions/filters?lang=${this.$i18n.locale.replace('-','')}`)
  115. // .then((result) => {
  116. // this.statusOptions = result.data.filters.statuses
  117. // }).catch((err) => {
  118. // console.log(err)
  119. // });
  120. },
  121. methods: {
  122. removeExhibitionRelation(index) {
  123. this.$axios.put(`/member/exhibitions?jwt=${this.$auth.$storage.getUniversal('jwt') ? this.$auth.$storage.getUniversal('jwt').token : ''}&exhibition_id=${this.userRenderList[index].id}&delete=true`)
  124. .then((result) => {
  125. if (this.countrySelect.toString() !== '999') {
  126. this.countrySelect = 999
  127. }
  128. this.$emit('refetch-user')
  129. this.userRenderList.splice((this.page-1)*6+index,1)
  130. this.userRenderListLength = Math.ceil(this.userRenderList.length/6)
  131. if ( this.page > this.userRenderListLength ) {
  132. this.page = this.userRenderListLength
  133. }
  134. }).catch((err) => {
  135. console.log(err)
  136. });
  137. },
  138. },
  139. watch: {
  140. countrySelect: {
  141. handler:function() {
  142. if (this.countrySelect) {
  143. this.$emit('filter-list',this.countrySelect.toString())
  144. }
  145. }
  146. },
  147. userVisibleExhibitionList: {
  148. handler:function() {
  149. this.userRenderList = JSON.parse(JSON.stringify(this.$props.userVisibleExhibitionList))
  150. this.userRenderListLength = this.$props.pageLength
  151. if (this.buildCountryOptions) {
  152. const locationList = []
  153. this.userVisibleExhibitionList.forEach(element => {
  154. locationList.push(element.country.name)
  155. });
  156. const options = this.countryOptions.filter(item => locationList.includes(item.name))
  157. const initial = {
  158. name: this.$t('userProfile.allCountries'),
  159. id: 999
  160. }
  161. options.splice(0,0,initial)
  162. this.countryOptions = JSON.parse(JSON.stringify(options))
  163. this.buildCountryOptions = !this.buildCountryOptions
  164. }
  165. }
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .filter-title-font {
  172. font-weight: 700;
  173. font-size: 16px;
  174. line-height: 21px;
  175. letter-spacing: 0.02em;
  176. }
  177. .input-country-wrap {
  178. width: 160px;
  179. }
  180. .input-status-wrap {
  181. width: 142px;
  182. }
  183. .empty-exhibitions-font {
  184. font-size: 20px;
  185. line-height: 26px;
  186. letter-spacing: 0.02em;
  187. color: #504F4F;
  188. }
  189. </style>