mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
improved search ui
This commit is contained in:
parent
e978e2978b
commit
a1e6252508
4 changed files with 66 additions and 42 deletions
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<v-app>
|
<v-app>
|
||||||
<v-app-bar dense app color="primary" dark class="d-print-none">
|
<v-app-bar dense app color="primary" dark class="d-print-none">
|
||||||
<v-btn @click="$router.push('/')" icon class="d-flex align-center">
|
<v-btn @click="$router.push('/')" icon>
|
||||||
<v-icon size="40"> mdi-silverware-variant </v-icon>
|
<v-icon size="40"> mdi-silverware-variant </v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<div btn class="pl-2">
|
<div btn class="pl-2">
|
||||||
|
@ -9,8 +9,15 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
|
<v-expand-x-transition>
|
||||||
<v-btn icon @click="$router.push('/search')">
|
<SearchBar
|
||||||
|
class="mt-7"
|
||||||
|
v-if="search"
|
||||||
|
:show-results="true"
|
||||||
|
@selected="navigateFromSearch"
|
||||||
|
/>
|
||||||
|
</v-expand-x-transition>
|
||||||
|
<v-btn icon @click="toggleSearch">
|
||||||
<v-icon>mdi-magnify</v-icon>
|
<v-icon>mdi-magnify</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
|
||||||
|
@ -28,6 +35,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Menu from "./components/UI/Menu";
|
import Menu from "./components/UI/Menu";
|
||||||
|
import SearchBar from "./components/UI/SearchBar";
|
||||||
import AddRecipeFab from "./components/UI/AddRecipeFab";
|
import AddRecipeFab from "./components/UI/AddRecipeFab";
|
||||||
import SnackBar from "./components/UI/SnackBar";
|
import SnackBar from "./components/UI/SnackBar";
|
||||||
import Vuetify from "./plugins/vuetify";
|
import Vuetify from "./plugins/vuetify";
|
||||||
|
@ -38,6 +46,7 @@ export default {
|
||||||
Menu,
|
Menu,
|
||||||
AddRecipeFab,
|
AddRecipeFab,
|
||||||
SnackBar,
|
SnackBar,
|
||||||
|
SearchBar,
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -83,6 +92,9 @@ export default {
|
||||||
this.search = true;
|
this.search = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
navigateFromSearch(slug) {
|
||||||
|
this.$router.push(`/recipe/${slug}`);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,40 +1,42 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<v-text-field
|
<v-autocomplete
|
||||||
label="Search"
|
:items="autoResults"
|
||||||
v-model="search"
|
item-value="item.slug"
|
||||||
|
item-text="item.name"
|
||||||
|
dense
|
||||||
|
light
|
||||||
|
label="Search Mealie"
|
||||||
|
:search-input.sync="search"
|
||||||
|
hide-no-data
|
||||||
|
cache-items
|
||||||
solo
|
solo
|
||||||
></v-text-field>
|
|
||||||
<v-card v-if="search && showResults">
|
|
||||||
<v-hover
|
|
||||||
square
|
|
||||||
v-for="(item, index) in result.slice(0, 5)"
|
|
||||||
:key="index"
|
|
||||||
v-slot="{ hover }"
|
|
||||||
>
|
>
|
||||||
<v-card
|
<template
|
||||||
class="color-transition"
|
v-if="showResults"
|
||||||
@click="$router.push(`/recipe/${item.item.slug}`)"
|
v-slot:item="{ item }"
|
||||||
:color="hover ? highlightColor : null"
|
style="max-width: 750px"
|
||||||
>
|
>
|
||||||
<v-row dense no-gutters>
|
<v-list-item-avatar>
|
||||||
<v-col cols="12" md="2" sm="6">
|
<v-img :src="getImage(item.item.image)"></v-img>
|
||||||
<v-img
|
</v-list-item-avatar>
|
||||||
:src="getImage(item.item.image)"
|
<v-list-item-content @click="selected(item.item.slug)">
|
||||||
width="100%"
|
<v-list-item-title>
|
||||||
height="100%"
|
{{ item.item.name }}
|
||||||
rounded
|
<v-rating
|
||||||
|
dense
|
||||||
|
v-if="item.item.rating"
|
||||||
|
:value="item.item.rating"
|
||||||
|
size="12"
|
||||||
>
|
>
|
||||||
</v-img>
|
</v-rating>
|
||||||
</v-col>
|
</v-list-item-title>
|
||||||
<v-col cols="12" md="10" sm="6">
|
<v-list-item-subtitle>
|
||||||
<v-card-title> {{ item.item.name }}</v-card-title>
|
{{ item.item.description }}
|
||||||
<v-card-text> {{ item.item.description }}</v-card-text></v-col
|
</v-list-item-subtitle>
|
||||||
>
|
</v-list-item-content>
|
||||||
</v-row>
|
</template>
|
||||||
</v-card>
|
</v-autocomplete>
|
||||||
</v-hover>
|
|
||||||
</v-card>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -52,6 +54,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
search: "",
|
search: "",
|
||||||
result: [],
|
result: [],
|
||||||
|
autoResults: [],
|
||||||
isDark: false,
|
isDark: false,
|
||||||
options: {
|
options: {
|
||||||
shouldSort: true,
|
shouldSort: true,
|
||||||
|
@ -74,21 +77,26 @@ export default {
|
||||||
fuse() {
|
fuse() {
|
||||||
return new Fuse(this.data, this.options);
|
return new Fuse(this.data, this.options);
|
||||||
},
|
},
|
||||||
highlightColor() {
|
|
||||||
return this.isDark ? "primary lighten-5" : "primary lighten-5";
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
search() {
|
search() {
|
||||||
if (this.search.trim() === "") this.result = this.list;
|
if (this.search.trim() === "") this.result = this.list;
|
||||||
else this.result = this.fuse.search(this.search.trim());
|
else this.result = this.fuse.search(this.search.trim());
|
||||||
|
console.log("test");
|
||||||
|
|
||||||
this.$emit("results", this.result);
|
this.$emit("results", this.result);
|
||||||
|
if (this.showResults === true) {
|
||||||
|
this.autoResults = this.result;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getImage(image) {
|
getImage(image) {
|
||||||
return utils.getImageURL(image);
|
return utils.getImageURL(image);
|
||||||
},
|
},
|
||||||
|
selected(slug) {
|
||||||
|
this.$emit("selected", slug);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<v-row justify="center">
|
<v-row justify="center">
|
||||||
<v-col cols="1"> </v-col>
|
<v-col cols="1"> </v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<SearchBar @results="updateResults" />
|
<SearchBar @results="updateResults" :show-results="false" />
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="2">
|
<v-col cols="2">
|
||||||
<v-btn icon>
|
<v-btn icon>
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
<v-row v-if="searchResults">
|
<v-row v-if="searchResults">
|
||||||
<v-col
|
<v-col
|
||||||
:sm="6"
|
:sm="6"
|
||||||
|
|
|
@ -6,7 +6,7 @@ from db.sql.model_base import SqlAlchemyBase
|
||||||
|
|
||||||
|
|
||||||
class RecipeModel(SqlAlchemyBase):
|
class RecipeModel(SqlAlchemyBase):
|
||||||
__tablename__ = 'recipes'
|
__tablename__ = "recipes"
|
||||||
# id = mongoengine.UUIDField(primary_key=True)
|
# id = mongoengine.UUIDField(primary_key=True)
|
||||||
name = sa.Column(sa.String)
|
name = sa.Column(sa.String)
|
||||||
description = sa.Column(sa.String)
|
description = sa.Column(sa.String)
|
||||||
|
@ -24,8 +24,11 @@ class RecipeModel(SqlAlchemyBase):
|
||||||
notes = orm.relation("Note")
|
notes = orm.relation("Note")
|
||||||
rating = sa.Column(sa.Integer)
|
rating = sa.Column(sa.Integer)
|
||||||
orgURL = sa.Column(sa.String)
|
orgURL = sa.Column(sa.String)
|
||||||
# extras =
|
extras = orm.relation("ApiExtras")
|
||||||
|
|
||||||
|
class ApiExtras(SqlAlchemyBase):
|
||||||
|
key: sa.Column(sa.String)
|
||||||
|
value: sa.Column(sa.String)
|
||||||
|
|
||||||
class Category(SqlAlchemyBase):
|
class Category(SqlAlchemyBase):
|
||||||
name = sa.Column(sa.String, index=True)
|
name = sa.Column(sa.String, index=True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue