Explorar el Código

Add 'all' as first category

sbkwgh hace 8 años
padre
commit
8dc5a210b6
Se han modificado 2 ficheros con 6 adiciones y 7 borrados
  1. 2 5
      src/App.vue
  2. 4 2
      src/store/index.js

+ 2 - 5
src/App.vue

@@ -306,11 +306,8 @@
 				})
 
 			this.axios.get('/api/v1/category')
-				.then(res => {
-					res.data.push({ name: 'All', value: 'ALL' })
-
-					this.$store.commit('addCategories', res.data)
-				}).catch(this.ajaxErrorHandler)
+				.then(res => this.$store.commit('addCategories', res.data))
+				.catch(this.ajaxErrorHandler)
 		}
 	}
 </script>

+ 4 - 2
src/store/index.js

@@ -10,7 +10,9 @@ export default new Vuex.Store({
 	state: {
 		meta: {
 			name: '',
-			categories: []
+			categories: [
+				{ name: 'All', value: 'ALL' }
+			]
 		},
 		accountTabs: 0,
 		accountModal: false,
@@ -57,7 +59,7 @@ export default new Vuex.Store({
 		},
 		addCategories (state, value) {
 			if(Array.isArray(value)) {
-				state.meta.categories = value
+				state.meta.categories.push(...value)
 			} else {
 				state.meta.categories.push(value)
 			}