Skip to content

Commit

Permalink
refactor: homogeize detail page init with route params. fixes. ref #844
Browse files Browse the repository at this point in the history
…, #858, #856
  • Loading branch information
raphodn committed Sep 27, 2024
1 parent cb00fb8 commit a65ae6b
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 36 deletions.
13 changes: 6 additions & 7 deletions src/views/BrandDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ export default {
data() {
return {
brandId: this.$route.params.id,
// filter & order
currentFilter: '',
currentOrder: constants.PRODUCT_ORDER_LIST[1].key,
// data
brand: null, // see init
brandProductList: [],
brandProductTotal: null,
brandProductPage: 0,
loading: false,
// filter & order
currentFilter: '',
currentOrder: constants.PRODUCT_ORDER_LIST[0].key, // price_count
}
},
computed: {
Expand All @@ -67,9 +66,8 @@ export default {
},
},
watch: {
$route (newBrand, oldBrand) {
if (oldBrand && newBrand && newBrand.name == 'brand-detail' && oldBrand.fullPath != newBrand.fullPath) {
this.brandId = newBrand.params.id
$route (newRoute, oldRoute) {
if (oldRoute && newRoute && newRoute.name == 'brand-detail' && oldRoute.fullPath != newRoute.fullPath) {
this.initBrand()
}
}
Expand All @@ -87,6 +85,7 @@ export default {
},
methods: {
initBrand() {
this.brandId = this.$route.params.id
this.brandProductList = []
this.brandProductTotal = null
this.brandProductPage = 0
Expand Down
12 changes: 6 additions & 6 deletions src/views/CategoryDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export default {
data() {
return {
categoryId: this.$route.params.id,
// filter & order
currentFilter: '',
currentOrder: constants.PRODUCT_ORDER_LIST[1].key,
// data
category: null, // see init
categoryProductList: [],
categoryProductTotal: null,
categoryProductPage: 0,
loading: false,
// filter & order
currentFilter: '',
currentOrder: constants.PRODUCT_ORDER_LIST[0].key, // price_count
}
},
computed: {
Expand All @@ -67,9 +67,8 @@ export default {
},
},
watch: {
$route (newCategory, oldCategory) {
if (oldCategory && newCategory && newCategory.name == 'category-detail' && oldCategory.fullPath != newCategory.fullPath) {
this.categoryId = newCategory.params.id
$route (newRoute, oldRoute) {
if (oldRoute && newRoute && newRoute.name == 'category-detail' && oldRoute.fullPath != newRoute.fullPath) {
this.initCategory()
}
}
Expand All @@ -87,6 +86,7 @@ export default {
},
methods: {
initCategory() {
this.categoryId = this.$route.params.id
this.category = {'id': this.categoryId, 'name': this.categoryId}
this.categoryProductList = []
this.categoryProductTotal = null
Expand Down
10 changes: 5 additions & 5 deletions src/views/CountryCityDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ export default {
},
data() {
return {
// order & display
currentOrder: '-price_count',
currentDisplay: constants.LOCATION_DISPLAY_LIST[0].key,
country: this.$route.params.country,
countryCity: this.$route.params.city,
// data
country: null, // see init
countryCity: null, // see init
countryCityLocationList: [],
countryCityLocationTotal: null,
countryCityLocationPage: 0,
loading: false,
// order & display
currentOrder: '-price_count',
currentDisplay: constants.LOCATION_DISPLAY_LIST[0].key,
}
},
computed: {
Expand Down
8 changes: 4 additions & 4 deletions src/views/CountryDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ export default {
},
data() {
return {
// order & display
currentOrder: '-price_count',
currentDisplay: constants.LOCATION_DISPLAY_LIST[0].key,
country: this.$route.params.country,
// data
country: null, // see init
countryLocationList: [],
countryLocationTotal: null,
countryLocationPage: 0,
loading: false,
// order & display
currentOrder: '-price_count',
currentDisplay: constants.LOCATION_DISPLAY_LIST[0].key,
}
},
computed: {
Expand Down
8 changes: 4 additions & 4 deletions src/views/DateDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ export default {
},
data() {
return {
date: this.$route.params.date,
// data
date: null, // see init
datePriceList: [],
datePriceTotal: null,
datePricePage: 0,
loading: false,
// filter & order
currentOrder: constants.PRICE_ORDER_LIST[1].key,
currentOrder: constants.PRICE_ORDER_LIST[1].key, // date
}
},
computed: {
Expand All @@ -75,8 +75,8 @@ export default {
},
},
watch: {
$route (newDate, oldDate) {
if (oldDate && newDate && newDate.name == 'date-detail' && oldDate.fullPath != newDate.fullPath) {
$route (newRoute, oldRoute) {
if (oldRoute && newRoute && newRoute.name == 'date-detail' && oldRoute.fullPath != newRoute.fullPath) {
this.initDate()
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/views/LabelDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export default {
data() {
return {
labelId: this.$route.params.id,
// filter & order
currentFilter: '',
currentOrder: constants.PRODUCT_ORDER_LIST[1].key,
// data
label: null, // see init
labelProductList: [],
labelProductTotal: null,
labelProductPage: 0,
loading: false,
// filter & order
currentFilter: '',
currentOrder: constants.PRODUCT_ORDER_LIST[0].key, // price_count
}
},
computed: {
Expand All @@ -69,7 +69,6 @@ export default {
watch: {
$route (newRoute, oldRoute) {
if (oldRoute && newRoute && newRoute.name == 'label-detail' && oldRoute.fullPath != newRoute.fullPath) {
this.labelId = this.$route.params.id
this.initLabel()
}
}
Expand All @@ -87,6 +86,7 @@ export default {
},
methods: {
initLabel() {
this.labelId = this.$route.params.id
this.label = {'id': this.labelId, 'name': this.labelId}
this.labelProductList = []
this.labelProductTotal = null
Expand Down
2 changes: 2 additions & 0 deletions src/views/LocationDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default {
data() {
return {
locationId: this.$route.params.id,
// data
location: null,
locationPriceList: [],
locationPriceTotal: null,
Expand Down Expand Up @@ -99,6 +100,7 @@ export default {
},
methods: {
initLocationPrices() {
this.locationId = this.$route.params.id
this.locationPriceList = []
this.locationPriceTotal = null
this.locationPricePage = 0
Expand Down
1 change: 1 addition & 0 deletions src/views/PriceDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default {
data() {
return {
priceId: this.$route.params.id,
// data
price: null,
loading: false,
}
Expand Down
2 changes: 2 additions & 0 deletions src/views/ProductDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default {
return {
OFF_NAME: constants.OFF_NAME,
productId: this.$route.params.id, // product_code or product_category
// data
product: null,
category: null,
productPriceList: [],
Expand Down Expand Up @@ -162,6 +163,7 @@ export default {
},
methods: {
initProductPrices() {
this.productId = this.$route.params.id
this.productPriceList = []
this.productPriceTotal = 0
this.productPricePage = 0
Expand Down
1 change: 1 addition & 0 deletions src/views/ProofDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default {
data() {
return {
proofId: this.$route.params.id,
// data
proof: null,
proofPriceList: [],
proofPriceTotal: null,
Expand Down
9 changes: 3 additions & 6 deletions src/views/UserDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

<script>
import { defineAsyncComponent } from 'vue'
import { mapStores } from 'pinia'
import { useAppStore } from '../store'
import api from '../services/api'
import constants from '../constants'
import utils from '../utils.js'
Expand All @@ -47,6 +45,8 @@ export default {
},
data() {
return {
username: this.$route.params.username,
// data
userPriceList: [],
userPriceTotal: null,
userPricePage: 0,
Expand All @@ -57,10 +57,6 @@ export default {
}
},
computed: {
...mapStores(useAppStore),
username() {
return this.$route.params.username
},
getPricesParams() {
let defaultParams = { owner: this.username, order_by: `${this.currentOrder}`, page: this.userPricePage }
if (this.currentFilter === 'show_last_month') {
Expand Down Expand Up @@ -91,6 +87,7 @@ export default {
},
methods: {
initUserPrices() {
this.username = this.$route.params.username
this.userPriceList = []
this.userPriceTotal = null
this.userPricePage = 0
Expand Down

0 comments on commit a65ae6b

Please sign in to comment.