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

fix issue in removing a filter

parent 1d8d2ebc
No related branches found
No related tags found
No related merge requests found
Pipeline #129155 failed
...@@ -193,6 +193,7 @@ function updateAutocompleteFocused(isFocused: boolean) { ...@@ -193,6 +193,7 @@ function updateAutocompleteFocused(isFocused: boolean) {
function emitUpdateModelValue(filters: MaybeRef<FilterItem[] | undefined>) { function emitUpdateModelValue(filters: MaybeRef<FilterItem[] | undefined>) {
console.log("emitupdatemodelValue")
console.log(filters) console.log(filters)
emit('update:modelValue', toValue(filters)) emit('update:modelValue', toValue(filters))
...@@ -204,21 +205,23 @@ function clearFilters() { ...@@ -204,21 +205,23 @@ function clearFilters() {
function deleteOneFilter(index: number) { function deleteOneFilter(index: number) {
const toValFilterItems = toValue(props.modelValue) const toValFilterItems = toValue(props.modelValue)
console.log(toValFilterItems)
const cloneFilters = toValFilterItems?.slice(0)
// check if the next item is an outeroperator // check if the next item is an outeroperator
const nextFilterItem = toValFilterItems?.slice(index + 1, index + 2) const nextFilterItem = cloneFilters?.slice(index + 1, index + 2)
if (index + 1 === toValFilterItems?.length && toValFilterItems?.length >= 7) { if (index + 1 === cloneFilters?.length && cloneFilters?.length >= 7) {
// need to remove the previous outer operator // need to remove the previous outer operator
toValFilterItems?.splice(index - 3, 4) cloneFilters?.splice(index - 3, 4)
} }
else if (nextFilterItem?.length === 1 && nextFilterItem[0].type === 'outerOperator') { else if (nextFilterItem?.length === 1 && nextFilterItem[0].type === 'outerOperator') {
toValFilterItems?.splice(index - 2, 4) cloneFilters?.splice(index - 2, 4)
} }
else { else {
toValFilterItems?.splice(index - 2, 3) cloneFilters?.splice(index - 2, 3)
} }
emitUpdateModelValue(toValFilterItems) emitUpdateModelValue(cloneFilters)
} }
function isItemFilter(type: string | undefined) { function isItemFilter(type: string | undefined) {
......
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