Skip to content
Snippets Groups Projects
Commit d5dd3da3 authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

working filter

parent 662aef63
No related branches found
No related tags found
2 merge requests!131Merge relevant Abstract and references,!123Resolve "Wizzard to create db filters"
Pipeline #117301 failed
This commit is part of merge request !131. Comments created here will be created in the context of that merge request.
......@@ -22,6 +22,7 @@ export interface FilterItem {
value: string
title: string
count?: number
deletable: boolean
props: {
[key: string]: any
// title: string
......@@ -60,6 +61,7 @@ const computedTableHeight = computed(() => {
const filterInputValues = computed(() => {
console.log("recompouted FILTER value")
if (filterOrSearch.value != null) {
return filterOrSearch.value.filter(({ props }) => props.type !== 'text')
} else {
......@@ -68,17 +70,20 @@ const filterInputValues = computed(() => {
})
const queryInputValue = computed(() => {
console.log("recompouted TEXT value")
if (filterOrSearch.value !== null) {
const phrase = filterOrSearch.value
.filter((f) => {
console.log(f)
return f.props.type === 'text'
})
.map((f) => {
return f.value
})
.join(" ")
return `'${phrase}'`
if (phrase.length > 1) {
return `${phrase.join(" ")}`
}
else { return phrase[0] }
} else {
return null
}
......@@ -107,6 +112,7 @@ const reactiveParams = reactive({
facets: ["*"],
filter: [],
sort: ["type:asc"],
// prefix_length: 3,
// attributesToHighlight: ["*"]
})
......@@ -158,7 +164,6 @@ watch(msFilter, async (fos) => {
})
watch(msResult, (newRes) => {
console.log("facets disti changed !!!!!!!!!!!!!")
console.log(msResult)
console.log(newRes)
facetStore.setFacets({ facetDistribution: newRes.facetDistribution, facetStat: newRes.facetStat })
......@@ -169,59 +174,73 @@ watch(msResult, (newRes) => {
watch(filterInputValues, (newSoF) => {
if (isFilter.value && filterInputValues.value !== null && filterInputValues.value?.length % 3 === 0) {
msFilter.value = filterInputValues.value.map((it, index) => {
const sanitizedValue = it.value.split("-")[0]
if (index >= 1 && (index + 1) % 3 === 1) {
return ` AND ${it.value}`
return ` AND ${sanitizedValue}`
} else if ((index + 1) % 3 === 0) {
return `"${it.value}"`
return `"${sanitizedValue}"`
} else {
return `${it.value}`
return `${sanitizedValue}`
}
}).join("")
}
})
watch(queryInputValue, (newQuery) => {
searchOrFilter()
})
const filterStep = computed(() => {
return filterInputValues.value !== null && filterInputValues.value.length > 0 ? filterInputValues.value?.length % 3 : null
})
const operatorItems = ref([
{
type: "operator", value: '=', title: "is", props: {
type: "operator"
type: "operator", value: '=', title: "is", deletable: false, props: {
type: "operator", deletable: false
}
}, {
type: "operator", value: '!=', title: "is not", props: {
type: "operator"
type: "operator", value: '!=', title: "is not", deletable: false, props: {
type: "operator",
deletable: false
}
}
])
const autocompleteItems = computed(() => {
const index = filterOrSearch.value?.length ?? 0
console.log(index)
if (filterStep.value === null || filterStep.value === 0) {
return props.facets.map(value => {
return {
type: "facet",
value,
value: `${value}-${index}`,
title: value,
deletable: false,
props: {
deletable: false,
type: "facet"
}
}
})
}
if (filterStep.value === 1) {
return operatorItems.value
return operatorItems.value.map(it => { return { ...it, value: `${it.value}-${index}`, } })
}
if (filterStep.value === 2) {
// get the facet value
if (Array.isArray(filterOrSearch.value)) {
const { type, value } = filterOrSearch.value?.slice(-2, -1)[0]
const sanitizedValue = value.split("-")[0]
console.log("compute new facets")
const facetDistri = facetStore.facets?.facetDistribution
console.log(facetDistri)
return facetDistri?.[value] ? Object.entries(facetDistri[value]).map(([key, val]) => {
return facetDistri?.[sanitizedValue] ? Object.entries(facetDistri[sanitizedValue]).map(([key, val]) => {
return {
type: "value", value: key, title: key, count: val, props: {
type: 'value', count: val
type: "value", value: `${key}-${index}`, title: key, count: val, deletable: true, props: {
type: "value", count: val, deletable: true
}
}
}) : []
......@@ -247,7 +266,29 @@ function deleteOneFilter(index: number) {
console.log(isFilter.value)
console.log(filterOrSearch)
if (isFilter.value) {
filterOrSearch.value?.splice(index - 2, 2)
console.log(filterOrSearch.value)
}
}
function deleteTextFilter(index: number) {
console.log("delete text filter")
console.log(index)
console.log(isFilter.value)
console.log(filterOrSearch)
console.log(filterOrSearch.value?.length)
if (isFilter.value) {
if (index === 0) {
filterOrSearch.value?.shift()
} else {
filterOrSearch.value?.splice(index, 1)
}
console.log(filterOrSearch.value?.length)
console.log(filterOrSearch.value)
}
}
......@@ -261,9 +302,9 @@ function clearSearch() {
function runTextSearch() {
if (canAddTextSearch) {
const item: FilterItem = {
type: 'text', title: search.value, value: search.value, props: { type: "text" }
}
const item: FilterItem = reactive({
type: 'text', title: search.value, value: search.value, deletable: true, props: { type: "text", deletable: true, }
})
if (Array.isArray(filterOrSearch.value)) {
filterOrSearch.value = [
...filterOrSearch.value, item
......@@ -273,6 +314,8 @@ function runTextSearch() {
filterOrSearch.value = [item]
}
search.value = ""
console.log(filterOrSearch.value.length)
console.log(filterOrSearch.value)
searchOrFilter()
}
}
......@@ -287,9 +330,13 @@ function runTextSearch() {
@click:appendInner="searchOrFilter" @click:clear="clearFilterOrSearch"
@update:modelValue="() => clearSearch()">
<template #chip="{ props, item, index }">
<v-chip v-if="(index + 1) % 3 === 0" v-bind="props" :text="item.raw.title" closable
<v-chip v-bind="props" :text="item.raw.title" :closable="item.props.deletable"
@click:close="item.props.type === 'text' ? deleteTextFilter(index) : deleteOneFilter(index)"></v-chip>
<!-- <v-chip v-if="(index + 1) % 3 === 0" v-bind="props" :text="item.raw.title" closable
@click:close="deleteOneFilter(index)"></v-chip>
<v-chip v-else v-bind="props" :text="item.raw.title"></v-chip>
<v-chip v-else v-bind="props" :text="item.raw.title"></v-chip> -->
</template>
<template #item="{ props, item }">
<v-list-item v-bind="{ ...props, active: false, onClick: () => selectItem(item) }" :title="item.title"
......@@ -297,9 +344,10 @@ function runTextSearch() {
</v-list-item>
</template>
<!-- <template #no-data></template>
<template #prepend-item>
<v-list-item v-if="canAddTextSearch" title="Text search" @click="runTextSearch"> </v-list-item>
</template>
<v-list-item v-if="canAddTextSearch" :title="`Text search: ${search}`" @click="runTextSearch"> </v-list-item>
</template> -->
</v-autocomplete>
</v-toolbar>
<v-data-table-server v-if="!msError" v-model:page="reactiveParams.page"
......
......@@ -113,6 +113,13 @@ def update_refseq(
"sortFacetValuesBy": {"*": "count"},
}
index.update_faceting_settings(params)
print("typo toler")
index.update_typo_tolerance(
{
"enabled": False
# "minWordSizeForTypos": {"oneTypo": 50, "twoTypos": 100}
}
)
def update_structure(
......@@ -155,6 +162,7 @@ def update_structure(
"plddts",
]
)
index.update_typo_tolerance({"enabled": False})
def split_on_comma(str_val: str) -> List[str]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment