mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
consolidate tag/category pages
This commit is contained in:
parent
5188b543e0
commit
fb5c69e1dd
4 changed files with 22 additions and 67 deletions
|
@ -22,6 +22,12 @@ export default {
|
|||
currentCategory() {
|
||||
return this.$route.params.category;
|
||||
},
|
||||
currentTag() {
|
||||
return this.$route.params.tag;
|
||||
},
|
||||
TagOrCategory() {
|
||||
return this.currentCategory || this.currentTag;
|
||||
},
|
||||
shownRecipes() {
|
||||
if (this.sortedResults.length > 0) {
|
||||
return this.sortedResults;
|
||||
|
@ -31,7 +37,8 @@ export default {
|
|||
},
|
||||
},
|
||||
watch: {
|
||||
async currentCategory() {
|
||||
async TagOrCategory() {
|
||||
console.log(this.currentCategory, this.currentTag);
|
||||
this.sortedResults = [];
|
||||
this.getRecipes();
|
||||
},
|
||||
|
@ -42,7 +49,16 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
async getRecipes() {
|
||||
let data = await api.categories.getRecipesInCategory(this.currentCategory);
|
||||
if (!this.TagOrCategory === null) return;
|
||||
console.log(this.TagOrCategory);
|
||||
|
||||
let data = {};
|
||||
if (this.currentCategory) {
|
||||
data = await api.categories.getRecipesInCategory(this.TagOrCategory);
|
||||
} else {
|
||||
data = await api.tags.getRecipesInTag(this.TagOrCategory);
|
||||
}
|
||||
console.log(data);
|
||||
this.title = data.name;
|
||||
this.recipes = data.recipes;
|
||||
},
|
|
@ -69,10 +69,7 @@ export default {
|
|||
methods: {
|
||||
async buildPage() {
|
||||
this.page = await api.siteSettings.getPage(this.pageSlug);
|
||||
},
|
||||
filterRecipe(slug) {
|
||||
const storeCategory = this.recipeStore.find(element => element.slug === slug);
|
||||
return storeCategory ? storeCategory.recipes : [];
|
||||
this.tab = this.page.categories[0];
|
||||
},
|
||||
sortRecipes(sortedRecipes, destKey) {
|
||||
this.page.categories[destKey].recipes = sortedRecipes;
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
<template>
|
||||
<v-container>
|
||||
<CardSection :sortable="true" :title="title" :recipes="shownRecipes" @sort="assignSorted" />
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { api } from "@/api";
|
||||
import CardSection from "@/components/UI/CardSection";
|
||||
export default {
|
||||
components: {
|
||||
CardSection,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: "",
|
||||
recipes: [],
|
||||
sortedResults: [],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
currentTag() {
|
||||
return this.$route.params.tag;
|
||||
},
|
||||
shownRecipes() {
|
||||
if (this.sortedResults.length > 0) {
|
||||
return this.sortedResults;
|
||||
} else {
|
||||
return this.recipes;
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
async currentTag() {
|
||||
this.getRecipes();
|
||||
this.sortedResults = [];
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getRecipes();
|
||||
this.sortedResults = [];
|
||||
},
|
||||
methods: {
|
||||
async getRecipes() {
|
||||
let data = await api.tags.getRecipesInTag(this.currentTag);
|
||||
this.title = data.name;
|
||||
this.recipes = data.recipes;
|
||||
},
|
||||
assignSorted(val) {
|
||||
console.log(val);
|
||||
this.sortedResults = val.slice();
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style></style>
|
|
@ -2,15 +2,14 @@ import ViewRecipe from "@/pages/Recipe/ViewRecipe";
|
|||
import NewRecipe from "@/pages/Recipe/NewRecipe";
|
||||
import CustomPage from "@/pages/Recipes/CustomPage";
|
||||
import AllRecipes from "@/pages/Recipes/AllRecipes";
|
||||
import CategoryPage from "@/pages/Recipes/CategoryPage";
|
||||
import TagPage from "@/pages/Recipes/TagPage";
|
||||
import CategoryTagPage from "@/pages/Recipes/CategoryTagPage";
|
||||
import { api } from "@/api";
|
||||
|
||||
export const recipeRoutes = [
|
||||
// Recipes
|
||||
{ path: "/recipes/all", component: AllRecipes },
|
||||
{ path: "/recipes/tag/:tag", component: TagPage },
|
||||
{ path: "/recipes/category/:category", component: CategoryPage },
|
||||
{ path: "/recipes/tag/:tag", component: CategoryTagPage },
|
||||
{ path: "/recipes/category/:category", component: CategoryTagPage },
|
||||
// Misc
|
||||
{ path: "/new/", component: NewRecipe },
|
||||
{ path: "/pages/:customPage", component: CustomPage },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue