make +/- search fields not clickable
This commit is contained in:
@ -617,7 +617,7 @@ class RecipeFacet():
|
|||||||
nodes = food.get_ancestors()
|
nodes = food.get_ancestors()
|
||||||
except Food.DoesNotExist:
|
except Food.DoesNotExist:
|
||||||
return self.get_facets()
|
return self.get_facets()
|
||||||
foods = self._food_queryset(Food.objects.filter(path__startswith=food.path, depth=food.depth+1), food)
|
foods = self._food_queryset(food.get_children(), food)
|
||||||
deep_search = self.Foods
|
deep_search = self.Foods
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
index = next((i for i, x in enumerate(deep_search) if x["id"] == node.id), None)
|
index = next((i for i, x in enumerate(deep_search) if x["id"] == node.id), None)
|
||||||
@ -633,7 +633,7 @@ class RecipeFacet():
|
|||||||
nodes = keyword.get_ancestors()
|
nodes = keyword.get_ancestors()
|
||||||
except Keyword.DoesNotExist:
|
except Keyword.DoesNotExist:
|
||||||
return self.get_facets()
|
return self.get_facets()
|
||||||
keywords = self._keyword_queryset(Keyword.objects.filter(path__startswith=keyword.path, depth=keyword.depth+1), keyword)
|
keywords = self._keyword_queryset(keyword.get_children(), keyword)
|
||||||
deep_search = self.Keywords
|
deep_search = self.Keywords
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
index = next((i for i, x in enumerate(deep_search) if x["id"] == node.id), None)
|
index = next((i for i, x in enumerate(deep_search) if x["id"] == node.id), None)
|
||||||
@ -645,7 +645,7 @@ class RecipeFacet():
|
|||||||
|
|
||||||
def _recipe_count_queryset(self, field, depth=1, steplen=4):
|
def _recipe_count_queryset(self, field, depth=1, steplen=4):
|
||||||
return Recipe.objects.filter(**{f'{field}__path__startswith': OuterRef('path')}, id__in=self._recipe_list, space=self._request.space
|
return Recipe.objects.filter(**{f'{field}__path__startswith': OuterRef('path')}, id__in=self._recipe_list, space=self._request.space
|
||||||
).values(child=Substr(f'{field}__path', 1, steplen*depth)
|
).values(child=Substr(f'{field}__path', 1, steplen)
|
||||||
).annotate(count=Count('pk', distinct=True)).values('count')
|
).annotate(count=Count('pk', distinct=True)).values('count')
|
||||||
|
|
||||||
def _keyword_queryset(self, queryset, keyword=None):
|
def _keyword_queryset(self, queryset, keyword=None):
|
||||||
|
@ -189,17 +189,10 @@
|
|||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<b-input-group class="mt-2" v-for="(k, a) in keywordFields" :key="a">
|
<b-input-group class="mt-2" v-for="(k, a) in keywordFields" :key="a">
|
||||||
<template #prepend v-if="search.expert_mode">
|
<template #prepend v-if="search.expert_mode">
|
||||||
<b-input-group-text style="width: 3em" @click="search.keywords_fields = search.keywords_fields + 1">
|
<b-input-group-text style="width: 3em" @click="addField('keywords', k)">
|
||||||
<i class="fas fa-plus-circle text-primary" v-if="k == search.keywords_fields && k < 4" />
|
<i class="fas fa-plus-circle text-primary" v-if="k == search.keywords_fields && k < 4" />
|
||||||
</b-input-group-text>
|
</b-input-group-text>
|
||||||
<b-input-group-text
|
<b-input-group-text style="width: 3em" @click="removeField('keywords', k)">
|
||||||
style="width: 3em"
|
|
||||||
@click="
|
|
||||||
search.keywords_fields = search.keywords_fields - 1
|
|
||||||
search.search_keywords[a].items = []
|
|
||||||
refreshData(false)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<i class="fas fa-minus-circle text-primary" v-if="k == search.keywords_fields && k > 1" />
|
<i class="fas fa-minus-circle text-primary" v-if="k == search.keywords_fields && k > 1" />
|
||||||
</b-input-group-text>
|
</b-input-group-text>
|
||||||
</template>
|
</template>
|
||||||
@ -257,20 +250,13 @@
|
|||||||
<h6 class="mt-2 mb-0" v-if="search.expert_mode && search.foods_fields > 1">{{ $t("Foods") }}</h6>
|
<h6 class="mt-2 mb-0" v-if="search.expert_mode && search.foods_fields > 1">{{ $t("Foods") }}</h6>
|
||||||
<div class="row" v-if="ui.show_foods">
|
<div class="row" v-if="ui.show_foods">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<b-input-group class="mt-2" v-for="(x, i) in foodFields" :key="i">
|
<b-input-group class="mt-2" v-for="(f, i) in foodFields" :key="i">
|
||||||
<template #prepend v-if="search.expert_mode">
|
<template #prepend v-if="search.expert_mode">
|
||||||
<b-input-group-text style="width: 3em" @click="search.foods_fields = search.foods_fields + 1">
|
<b-input-group-text style="width: 3em" @click="addField('foods', f)">
|
||||||
<i class="fas fa-plus-circle text-primary" v-if="x == search.foods_fields && x < 4" />
|
<i class="fas fa-plus-circle text-primary" v-if="f == search.foods_fields && f < 4" />
|
||||||
</b-input-group-text>
|
</b-input-group-text>
|
||||||
<b-input-group-text
|
<b-input-group-text style="width: 3em" @click="removeField('foods', f)">
|
||||||
style="width: 3em"
|
<i class="fas fa-minus-circle text-primary" v-if="f == search.foods_fields && f > 1" />
|
||||||
@click="
|
|
||||||
search.foods_fields = search.foods_fields - 1
|
|
||||||
search.search_foods[i].items = []
|
|
||||||
refreshData(false)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<i class="fas fa-minus-circle text-primary" v-if="x == search.foods_fields && x > 1" />
|
|
||||||
</b-input-group-text>
|
</b-input-group-text>
|
||||||
</template>
|
</template>
|
||||||
<treeselect
|
<treeselect
|
||||||
@ -320,20 +306,13 @@
|
|||||||
<h6 class="mt-2 mb-0" v-if="search.expert_mode && search.books_fields > 1">{{ $t("Books") }}</h6>
|
<h6 class="mt-2 mb-0" v-if="search.expert_mode && search.books_fields > 1">{{ $t("Books") }}</h6>
|
||||||
<div class="row" v-if="ui.show_books">
|
<div class="row" v-if="ui.show_books">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<b-input-group class="mt-2" v-for="(x, i) in bookFields" :key="i">
|
<b-input-group class="mt-2" v-for="(b, i) in bookFields" :key="i">
|
||||||
<template #prepend v-if="search.expert_mode">
|
<template #prepend v-if="search.expert_mode">
|
||||||
<b-input-group-text style="width: 3em" @click="search.books_fields = search.books_fields + 1">
|
<b-input-group-text style="width: 3em" @click="addField('books', b)">
|
||||||
<i class="fas fa-plus-circle text-primary" v-if="x == search.books_fields && x < 4" />
|
<i class="fas fa-plus-circle text-primary" v-if="b == search.books_fields && b < 4" />
|
||||||
</b-input-group-text>
|
</b-input-group-text>
|
||||||
<b-input-group-text
|
<b-input-group-text style="width: 3em" @click="removeField('books', b)">
|
||||||
style="width: 3em"
|
<i class="fas fa-minus-circle text-primary" v-if="b == search.books_fields && b > 1" />
|
||||||
@click="
|
|
||||||
search.books_fields = search.books_fields - 1
|
|
||||||
search.search_books[i].items = []
|
|
||||||
refreshData(false)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<i class="fas fa-minus-circle text-primary" v-if="x == search.books_fields && x > 1" />
|
|
||||||
</b-input-group-text>
|
</b-input-group-text>
|
||||||
</template>
|
</template>
|
||||||
<generic-multiselect
|
<generic-multiselect
|
||||||
@ -1105,6 +1084,19 @@ export default {
|
|||||||
StandardToasts.makeStandardToast(StandardToasts.FAIL_CREATE)
|
StandardToasts.makeStandardToast(StandardToasts.FAIL_CREATE)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
addField: function (field, count) {
|
||||||
|
if (count == this.search[`${field}_fields`] && count < 4) {
|
||||||
|
this.search[`${field}_fields`] = this.search[`${field}_fields`] + 1
|
||||||
|
this.refreshData(false)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
removeField: function (field, count) {
|
||||||
|
if (count == this.search[`${field}_fields`] && count > 1) {
|
||||||
|
this.search[`${field}_fields`] = this.search[`${field}_fields`] - 1
|
||||||
|
this.search[`search_${field}`][count - 1].items = []
|
||||||
|
this.refreshData(false)
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user