From 81c74d407f801ae1333a201bd3edaac840422b64 Mon Sep 17 00:00:00 2001 From: hay-kot Date: Sun, 28 Mar 2021 10:30:41 -0800 Subject: [PATCH] set initial selection for category button --- frontend/src/App.vue | 1 + frontend/src/api/category.js | 2 +- frontend/src/api/mealplan.js | 1 - .../Backup/ImportSummaryDialog/index.vue | 1 - .../Admin/General/CreatePageDialog.vue | 25 +++++++++++-------- .../Admin/General/HomePageSettings.vue | 7 +++--- .../FormHelpers/CategorySelector.vue | 19 ++++++++------ frontend/src/components/UI/CardSection.vue | 11 +++----- frontend/src/store/index.js | 9 +++++++ 9 files changed, 42 insertions(+), 34 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 5dc73ef67..3584609a3 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -78,6 +78,7 @@ export default { this.$store.dispatch("requestRecentRecipes"); this.$store.dispatch("refreshToken"); this.$store.dispatch("requestCurrentGroup"); + this.$store.dispatch("requestCategories"); this.darkModeSystemCheck(); this.darkModeAddEventListener(); }, diff --git a/frontend/src/api/category.js b/frontend/src/api/category.js index 22054058b..6855a822b 100644 --- a/frontend/src/api/category.js +++ b/frontend/src/api/category.js @@ -10,7 +10,7 @@ const categoryURLs = { }; export default { - async get_all() { + async getAll() { let response = await apiReq.get(categoryURLs.get_all); return response.data; }, diff --git a/frontend/src/api/mealplan.js b/frontend/src/api/mealplan.js index 4de5d7a85..0271f51de 100644 --- a/frontend/src/api/mealplan.js +++ b/frontend/src/api/mealplan.js @@ -16,7 +16,6 @@ const mealPlanURLs = { export default { async create(postBody) { - console.log(postBody); let response = await apiReq.post(mealPlanURLs.create, postBody); return response; }, diff --git a/frontend/src/components/Admin/Backup/ImportSummaryDialog/index.vue b/frontend/src/components/Admin/Backup/ImportSummaryDialog/index.vue index a0bdfb9ae..491ba2843 100644 --- a/frontend/src/components/Admin/Backup/ImportSummaryDialog/index.vue +++ b/frontend/src/components/Admin/Backup/ImportSummaryDialog/index.vue @@ -141,7 +141,6 @@ export default { return numbers; }, open(importData) { - console.log(importData); this.recipeData = importData.recipeImports; this.themeData = importData.themeImports; this.settingsData = importData.settingsImports; diff --git a/frontend/src/components/Admin/General/CreatePageDialog.vue b/frontend/src/components/Admin/General/CreatePageDialog.vue index 9333421dd..a6eff9709 100644 --- a/frontend/src/components/Admin/General/CreatePageDialog.vue +++ b/frontend/src/components/Admin/General/CreatePageDialog.vue @@ -12,14 +12,18 @@ - + - + @@ -46,6 +50,7 @@ export default { }, data() { return { + catMounted: false, title: "", buttonText: "", create: false, @@ -57,16 +62,9 @@ export default { }, }; }, - mounted() { - this.page = { - name: "", - position: 0, - categories: [], - }; - }, watch: { - page() { - console.log(this.page); + catMounted(val) { + if (val) this.pushSelected(); }, }, methods: { @@ -76,6 +74,11 @@ export default { this.buttonText = parameters.buttonText; this.title = parameters.title; this.pageDialog = true; + + if (this.catMounted) this.pushSelected(); + }, + pushSelected() { + this.$refs.categoryFormSelector.setInit(this.page.categories); }, async submitForm() { if (this.create) { diff --git a/frontend/src/components/Admin/General/HomePageSettings.vue b/frontend/src/components/Admin/General/HomePageSettings.vue index 30a2b2c18..eeb956dc3 100644 --- a/frontend/src/components/Admin/General/HomePageSettings.vue +++ b/frontend/src/components/Admin/General/HomePageSettings.vue @@ -38,7 +38,7 @@ - {{$t('settings.homepage.home-page-sections')}} + {{ $t("settings.homepage.home-page-sections") }} @@ -80,7 +80,7 @@ - {{$t('settings.homepage.all-categories')}} + {{ $t("settings.homepage.all-categories") }} @@ -153,13 +153,12 @@ export default { }, computed: { allCategories() { - return this.$store.getters.getCategories; + return this.$store.getters.getAllCategories; }, }, methods: { writeLang(val) { - console.log(val); this.settings.language = val; }, deleteCategoryfromDatabase(category) { diff --git a/frontend/src/components/FormHelpers/CategorySelector.vue b/frontend/src/components/FormHelpers/CategorySelector.vue index 4bc154a52..390bd60d6 100644 --- a/frontend/src/components/FormHelpers/CategorySelector.vue +++ b/frontend/src/components/FormHelpers/CategorySelector.vue @@ -16,7 +16,7 @@ diff --git a/frontend/src/components/UI/CardSection.vue b/frontend/src/components/UI/CardSection.vue index 3d53ee6a5..82ff6c141 100644 --- a/frontend/src/components/UI/CardSection.vue +++ b/frontend/src/components/UI/CardSection.vue @@ -2,8 +2,8 @@
- - + + {{ title.toUpperCase() }} @@ -92,18 +92,13 @@ export default { default: false, }, title: { - default: null + default: null, }, recipes: Array, cardLimit: { default: 999, }, }, - watch: { - recipes(val) { - console.log(val) - } - }, computed: { viewScale() { switch (this.$vuetify.breakpoint.name) { diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index a538bed6e..3ee9a449a 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -26,6 +26,7 @@ const store = new Vuex.Store({ recentRecipes: [], allRecipes: [], mealPlanCategories: [], + allCategories: [], }, mutations: { @@ -36,6 +37,9 @@ const store = new Vuex.Store({ setMealPlanCategories(state, payload) { state.mealPlanCategories = payload; }, + setAllCategories(state, payload) { + state.allCategories = payload; + }, }, actions: { @@ -52,11 +56,16 @@ const store = new Vuex.Store({ this.commit("setRecentRecipes", payload); }, + async requestCategories({ commit }) { + const categories = await api.categories.getAll(); + commit("setAllCategories", categories); + }, }, getters: { getRecentRecipes: state => state.recentRecipes, getMealPlanCategories: state => state.mealPlanCategories, + getAllCategories: state => state.allCategories, }, });