mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
set initial selection for category button
This commit is contained in:
parent
b21a6f54d5
commit
81c74d407f
9 changed files with 42 additions and 34 deletions
|
@ -78,6 +78,7 @@ export default {
|
||||||
this.$store.dispatch("requestRecentRecipes");
|
this.$store.dispatch("requestRecentRecipes");
|
||||||
this.$store.dispatch("refreshToken");
|
this.$store.dispatch("refreshToken");
|
||||||
this.$store.dispatch("requestCurrentGroup");
|
this.$store.dispatch("requestCurrentGroup");
|
||||||
|
this.$store.dispatch("requestCategories");
|
||||||
this.darkModeSystemCheck();
|
this.darkModeSystemCheck();
|
||||||
this.darkModeAddEventListener();
|
this.darkModeAddEventListener();
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,7 +10,7 @@ const categoryURLs = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async get_all() {
|
async getAll() {
|
||||||
let response = await apiReq.get(categoryURLs.get_all);
|
let response = await apiReq.get(categoryURLs.get_all);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,7 +16,6 @@ const mealPlanURLs = {
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async create(postBody) {
|
async create(postBody) {
|
||||||
console.log(postBody);
|
|
||||||
let response = await apiReq.post(mealPlanURLs.create, postBody);
|
let response = await apiReq.post(mealPlanURLs.create, postBody);
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
|
|
|
@ -141,7 +141,6 @@ export default {
|
||||||
return numbers;
|
return numbers;
|
||||||
},
|
},
|
||||||
open(importData) {
|
open(importData) {
|
||||||
console.log(importData);
|
|
||||||
this.recipeData = importData.recipeImports;
|
this.recipeData = importData.recipeImports;
|
||||||
this.themeData = importData.themeImports;
|
this.themeData = importData.themeImports;
|
||||||
this.settingsData = importData.settingsImports;
|
this.settingsData = importData.settingsImports;
|
||||||
|
|
|
@ -12,14 +12,18 @@
|
||||||
|
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
</v-app-bar>
|
</v-app-bar>
|
||||||
<v-form ref="newGroup" @submit="submitForm">
|
<v-form ref="newGroup" @submit.prevent="submitForm">
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
autofocus
|
autofocus
|
||||||
v-model="page.name"
|
v-model="page.name"
|
||||||
label="Page Name"
|
label="Page Name"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
<CategorySelector v-model="page.categories" />
|
<CategorySelector
|
||||||
|
v-model="page.categories"
|
||||||
|
ref="categoryFormSelector"
|
||||||
|
@mounted="catMounted = true"
|
||||||
|
/>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
|
@ -46,6 +50,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
catMounted: false,
|
||||||
title: "",
|
title: "",
|
||||||
buttonText: "",
|
buttonText: "",
|
||||||
create: false,
|
create: false,
|
||||||
|
@ -57,16 +62,9 @@ export default {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
this.page = {
|
|
||||||
name: "",
|
|
||||||
position: 0,
|
|
||||||
categories: [],
|
|
||||||
};
|
|
||||||
},
|
|
||||||
watch: {
|
watch: {
|
||||||
page() {
|
catMounted(val) {
|
||||||
console.log(this.page);
|
if (val) this.pushSelected();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -76,6 +74,11 @@ export default {
|
||||||
this.buttonText = parameters.buttonText;
|
this.buttonText = parameters.buttonText;
|
||||||
this.title = parameters.title;
|
this.title = parameters.title;
|
||||||
this.pageDialog = true;
|
this.pageDialog = true;
|
||||||
|
|
||||||
|
if (this.catMounted) this.pushSelected();
|
||||||
|
},
|
||||||
|
pushSelected() {
|
||||||
|
this.$refs.categoryFormSelector.setInit(this.page.categories);
|
||||||
},
|
},
|
||||||
async submitForm() {
|
async submitForm() {
|
||||||
if (this.create) {
|
if (this.create) {
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
</v-icon>
|
</v-icon>
|
||||||
|
|
||||||
<v-toolbar-title class="headline">
|
<v-toolbar-title class="headline">
|
||||||
{{$t('settings.homepage.home-page-sections')}}
|
{{ $t("settings.homepage.home-page-sections") }}
|
||||||
</v-toolbar-title>
|
</v-toolbar-title>
|
||||||
|
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
</v-icon>
|
</v-icon>
|
||||||
|
|
||||||
<v-toolbar-title class="headline">
|
<v-toolbar-title class="headline">
|
||||||
{{$t('settings.homepage.all-categories')}}
|
{{ $t("settings.homepage.all-categories") }}
|
||||||
</v-toolbar-title>
|
</v-toolbar-title>
|
||||||
|
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
|
@ -153,13 +153,12 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
allCategories() {
|
allCategories() {
|
||||||
return this.$store.getters.getCategories;
|
return this.$store.getters.getAllCategories;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
writeLang(val) {
|
writeLang(val) {
|
||||||
console.log(val);
|
|
||||||
this.settings.language = val;
|
this.settings.language = val;
|
||||||
},
|
},
|
||||||
deleteCategoryfromDatabase(category) {
|
deleteCategoryfromDatabase(category) {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import api from "@/api";
|
const MOUNTED_EVENT = "mounted";
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
value: Array,
|
value: Array,
|
||||||
|
@ -24,21 +24,24 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
selected: [],
|
selected: [],
|
||||||
allCategories: [],
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
mounted() {
|
||||||
value() {
|
this.$emit(MOUNTED_EVENT);
|
||||||
this.selected = this.value;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
async created() {
|
|
||||||
this.allCategories = await api.categories.get_all();
|
computed: {
|
||||||
|
allCategories() {
|
||||||
|
return this.$store.getters.getAllCategories;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
emitChange() {
|
emitChange() {
|
||||||
this.$emit("input", this.selected);
|
this.$emit("input", this.selected);
|
||||||
},
|
},
|
||||||
|
setInit(val) {
|
||||||
|
this.selected = val;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<div class="mt-n5" v-if="recipes">
|
<div class="mt-n5" v-if="recipes">
|
||||||
<v-card flat class="transparent" height="60px">
|
<v-card flat class="transparent" height="60px">
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-row v-if="title != null">
|
<v-row v-if="title != null">
|
||||||
<v-col >
|
<v-col>
|
||||||
<v-btn-toggle group>
|
<v-btn-toggle group>
|
||||||
<v-btn text :to="`/recipes/${title.toLowerCase()}`">
|
<v-btn text :to="`/recipes/${title.toLowerCase()}`">
|
||||||
{{ title.toUpperCase() }}
|
{{ title.toUpperCase() }}
|
||||||
|
@ -92,18 +92,13 @@ export default {
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
default: null
|
default: null,
|
||||||
},
|
},
|
||||||
recipes: Array,
|
recipes: Array,
|
||||||
cardLimit: {
|
cardLimit: {
|
||||||
default: 999,
|
default: 999,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
recipes(val) {
|
|
||||||
console.log(val)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
viewScale() {
|
viewScale() {
|
||||||
switch (this.$vuetify.breakpoint.name) {
|
switch (this.$vuetify.breakpoint.name) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ const store = new Vuex.Store({
|
||||||
recentRecipes: [],
|
recentRecipes: [],
|
||||||
allRecipes: [],
|
allRecipes: [],
|
||||||
mealPlanCategories: [],
|
mealPlanCategories: [],
|
||||||
|
allCategories: [],
|
||||||
},
|
},
|
||||||
|
|
||||||
mutations: {
|
mutations: {
|
||||||
|
@ -36,6 +37,9 @@ const store = new Vuex.Store({
|
||||||
setMealPlanCategories(state, payload) {
|
setMealPlanCategories(state, payload) {
|
||||||
state.mealPlanCategories = payload;
|
state.mealPlanCategories = payload;
|
||||||
},
|
},
|
||||||
|
setAllCategories(state, payload) {
|
||||||
|
state.allCategories = payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -52,11 +56,16 @@ const store = new Vuex.Store({
|
||||||
|
|
||||||
this.commit("setRecentRecipes", payload);
|
this.commit("setRecentRecipes", payload);
|
||||||
},
|
},
|
||||||
|
async requestCategories({ commit }) {
|
||||||
|
const categories = await api.categories.getAll();
|
||||||
|
commit("setAllCategories", categories);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
getters: {
|
getters: {
|
||||||
getRecentRecipes: state => state.recentRecipes,
|
getRecentRecipes: state => state.recentRecipes,
|
||||||
getMealPlanCategories: state => state.mealPlanCategories,
|
getMealPlanCategories: state => state.mealPlanCategories,
|
||||||
|
getAllCategories: state => state.allCategories,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue