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