mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
fix tag auto completes
This commit is contained in:
parent
214964131e
commit
af046b515d
9 changed files with 50 additions and 14 deletions
|
@ -86,6 +86,7 @@ export default {
|
|||
this.$store.dispatch("refreshToken");
|
||||
this.$store.dispatch("requestCurrentGroup");
|
||||
this.$store.dispatch("requestCategories");
|
||||
this.$store.dispatch("requestTags");
|
||||
this.darkModeSystemCheck();
|
||||
this.darkModeAddEventListener();
|
||||
},
|
||||
|
|
|
@ -9,12 +9,12 @@ const categoryURLs = {
|
|||
delete_category: category => `${prefix}/${category}`,
|
||||
};
|
||||
|
||||
export default {
|
||||
export const categoryAPI = {
|
||||
async getAll() {
|
||||
let response = await apiReq.get(categoryURLs.get_all);
|
||||
return response.data;
|
||||
},
|
||||
async get_recipes_in_category(category) {
|
||||
async getRecipesInCategory(category) {
|
||||
let response = await apiReq.get(categoryURLs.get_category(category));
|
||||
return response.data;
|
||||
},
|
||||
|
@ -23,3 +23,26 @@ export default {
|
|||
return response.data;
|
||||
},
|
||||
};
|
||||
|
||||
const tagPrefix = baseURL + "tags";
|
||||
|
||||
const tagURLs = {
|
||||
getAll: `${tagPrefix}`,
|
||||
getTag: tag => `${tagPrefix}/${tag}`,
|
||||
deleteTag: tag => `${tagPrefix}/${tag}`,
|
||||
};
|
||||
|
||||
export const tagAPI = {
|
||||
async getAll() {
|
||||
let response = await apiReq.get(tagURLs.getAll);
|
||||
return response.data;
|
||||
},
|
||||
async getRecipesInTag(tag) {
|
||||
let response = await apiReq.get(tagURLs.getTag(tag));
|
||||
return response.data;
|
||||
},
|
||||
async delete(tag) {
|
||||
let response = await apiReq.delete(tagURLs.deleteTag(tag));
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@ import settings from "./settings";
|
|||
import themes from "./themes";
|
||||
import migration from "./migration";
|
||||
import myUtils from "./upload";
|
||||
import category from "./category";
|
||||
import { categoryAPI, tagAPI } from "./category";
|
||||
import meta from "./meta";
|
||||
import users from "./users";
|
||||
import signUps from "./signUps";
|
||||
|
@ -24,7 +24,8 @@ export const api = {
|
|||
themes: themes,
|
||||
migrations: migration,
|
||||
utils: myUtils,
|
||||
categories: category,
|
||||
categories: categoryAPI,
|
||||
tags: tagAPI,
|
||||
meta: meta,
|
||||
users: users,
|
||||
signUps: signUps,
|
||||
|
|
|
@ -148,7 +148,7 @@
|
|||
deletable-chips
|
||||
v-model="value.tags"
|
||||
hide-selected
|
||||
:items="tags"
|
||||
:items="allTags"
|
||||
:search-input.sync="tagsSearchInput"
|
||||
@change="tagssSearchInput = ''"
|
||||
>
|
||||
|
@ -284,8 +284,6 @@ export default {
|
|||
},
|
||||
categoriesSearchInput: "",
|
||||
tagsSearchInput: "",
|
||||
categories: [],
|
||||
tags: [],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
@ -293,6 +291,10 @@ export default {
|
|||
const categories = this.$store.getters.getAllCategories;
|
||||
return categories.map(cat => cat.name);
|
||||
},
|
||||
allTags() {
|
||||
const tags = this.$store.getters.getAllTags;
|
||||
return tags.map(cat => cat.name);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
uploadImage() {
|
||||
|
|
|
@ -59,7 +59,7 @@ export default {
|
|||
});
|
||||
},
|
||||
async getRecipeByCategory(category) {
|
||||
return await api.categories.get_recipes_in_category(category);
|
||||
return await api.categories.getRecipesInCategory(category);
|
||||
},
|
||||
getRecentRecipes() {
|
||||
this.$store.dispatch("requestRecentRecipes");
|
||||
|
|
|
@ -42,7 +42,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
async getRecipes() {
|
||||
let data = await api.categories.get_recipes_in_category(
|
||||
let data = await api.categories.getRecipesInCategory(
|
||||
this.currentCategory
|
||||
);
|
||||
this.title = data.name;
|
||||
|
|
|
@ -76,7 +76,7 @@ export default {
|
|||
});
|
||||
},
|
||||
async getRecipeByCategory(category) {
|
||||
return await api.categories.get_recipes_in_category(category);
|
||||
return await api.categories.getRecipesInCategory(category);
|
||||
},
|
||||
filterRecipe(slug) {
|
||||
const storeCategory = this.recipeStore.find(
|
||||
|
|
|
@ -27,19 +27,22 @@ const store = new Vuex.Store({
|
|||
allRecipes: [],
|
||||
mealPlanCategories: [],
|
||||
allCategories: [],
|
||||
allTags: [],
|
||||
},
|
||||
|
||||
mutations: {
|
||||
setRecentRecipes(state, payload) {
|
||||
state.recentRecipes = payload;
|
||||
},
|
||||
|
||||
setMealPlanCategories(state, payload) {
|
||||
state.mealPlanCategories = payload;
|
||||
},
|
||||
setAllCategories(state, payload) {
|
||||
state.allCategories = payload;
|
||||
},
|
||||
setAllTags(state, payload) {
|
||||
state.allTags = payload;
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
@ -60,6 +63,10 @@ const store = new Vuex.Store({
|
|||
const categories = await api.categories.getAll();
|
||||
commit("setAllCategories", categories);
|
||||
},
|
||||
async requestTags({ commit }) {
|
||||
const tags = await api.tags.getAll();
|
||||
commit("setAllTags", tags);
|
||||
},
|
||||
},
|
||||
|
||||
getters: {
|
||||
|
@ -67,6 +74,8 @@ const store = new Vuex.Store({
|
|||
getMealPlanCategories: state => state.mealPlanCategories,
|
||||
getAllCategories: state =>
|
||||
state.allCategories.sort((a, b) => (a.slug > b.slug ? 1 : -1)),
|
||||
getAllTags: state =>
|
||||
state.allTags.sort((a, b) => (a.slug > b.slug ? 1 : -1)),
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -8,15 +8,15 @@ from sqlalchemy.orm.session import Session
|
|||
router = APIRouter(tags=["Recipes"])
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/api/recipes/tags",
|
||||
prefix="/api/tags",
|
||||
tags=["Recipe Tags"],
|
||||
)
|
||||
|
||||
|
||||
@router.get("/")
|
||||
@router.get("")
|
||||
async def get_all_recipe_tags(session: Session = Depends(generate_session)):
|
||||
""" Returns a list of available tags in the database """
|
||||
return db.tags.get_all_primary_keys(session)
|
||||
return db.tags.get_all_limit_columns(session, ["slug", "name"])
|
||||
|
||||
|
||||
@router.get("/{tag}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue