|
|
@ -355,15 +355,17 @@ watch( |
|
|
|
}, |
|
|
|
}, |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const visibleFilters = computed(() => filters.value.filter((filter) => filter.status !== 'delete')) |
|
|
|
|
|
|
|
|
|
|
|
const isLogicalOpChangeAllowed = computed(() => { |
|
|
|
const isLogicalOpChangeAllowed = computed(() => { |
|
|
|
return new Set(filters.value.slice(1).map((filter) => filter.logical_op)).size > 1 |
|
|
|
return new Set(visibleFilters.value.slice(1).map((filter) => filter.logical_op)).size > 1 |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// when logical operation is updated, update all the siblings with the same logical operation only if it's in locked state |
|
|
|
// when logical operation is updated, update all the siblings with the same logical operation only if it's in locked state |
|
|
|
const onLogicalOpUpdate = async (filter: Filter, index: number) => { |
|
|
|
const onLogicalOpUpdate = async (filter: Filter, index: number) => { |
|
|
|
if (index === 1 && filters.value.slice(2).every((siblingFilter) => siblingFilter.logical_op !== filter.logical_op)) { |
|
|
|
if (index === 1 && visibleFilters.value.slice(2).every((siblingFilter) => siblingFilter.logical_op !== filter.logical_op)) { |
|
|
|
await Promise.all( |
|
|
|
await Promise.all( |
|
|
|
filters.value.slice(2).map(async (siblingFilter, i) => { |
|
|
|
visibleFilters.value.slice(2).map(async (siblingFilter, i) => { |
|
|
|
siblingFilter.logical_op = filter.logical_op |
|
|
|
siblingFilter.logical_op = filter.logical_op |
|
|
|
await saveOrUpdate(siblingFilter, i + 2, false, false, true) |
|
|
|
await saveOrUpdate(siblingFilter, i + 2, false, false, true) |
|
|
|
}), |
|
|
|
}), |
|
|
@ -403,9 +405,9 @@ const onLogicalOpUpdate = async (filter: Filter, index: number) => { |
|
|
|
class="min-w-20 capitalize" |
|
|
|
class="min-w-20 capitalize" |
|
|
|
placeholder="Group op" |
|
|
|
placeholder="Group op" |
|
|
|
dropdown-class-name="nc-dropdown-filter-logical-op-group" |
|
|
|
dropdown-class-name="nc-dropdown-filter-logical-op-group" |
|
|
|
:disabled="i > 1 && !isLogicalOpChangeAllowed" |
|
|
|
:disabled="visibleFilters.indexOf(filter) > 1 && !isLogicalOpChangeAllowed" |
|
|
|
@click.stop |
|
|
|
@click.stop |
|
|
|
@change="saveOrUpdate(filter, i)" |
|
|
|
@change="onLogicalOpUpdate(filter, i)" |
|
|
|
> |
|
|
|
> |
|
|
|
<a-select-option v-for="op in logicalOps" :key="op.value" :value="op.value"> |
|
|
|
<a-select-option v-for="op in logicalOps" :key="op.value" :value="op.value"> |
|
|
|
<div class="flex items-center w-full justify-between w-full gap-2"> |
|
|
|
<div class="flex items-center w-full justify-between w-full gap-2"> |
|
|
@ -456,7 +458,7 @@ const onLogicalOpUpdate = async (filter: Filter, index: number) => { |
|
|
|
:dropdown-match-select-width="false" |
|
|
|
:dropdown-match-select-width="false" |
|
|
|
class="h-full !min-w-20 !max-w-20 capitalize" |
|
|
|
class="h-full !min-w-20 !max-w-20 capitalize" |
|
|
|
hide-details |
|
|
|
hide-details |
|
|
|
:disabled="filter.readOnly || (i > 1 && !isLogicalOpChangeAllowed)" |
|
|
|
:disabled="filter.readOnly || (visibleFilters.indexOf(filter) > 1 && !isLogicalOpChangeAllowed)" |
|
|
|
dropdown-class-name="nc-dropdown-filter-logical-op" |
|
|
|
dropdown-class-name="nc-dropdown-filter-logical-op" |
|
|
|
@change="onLogicalOpUpdate(filter, i)" |
|
|
|
@change="onLogicalOpUpdate(filter, i)" |
|
|
|
@click.stop |
|
|
|
@click.stop |
|
|
|