|
|
@ -12,6 +12,7 @@ interface Props { |
|
|
|
webHook?: boolean |
|
|
|
webHook?: boolean |
|
|
|
draftFilter?: Partial<FilterType> |
|
|
|
draftFilter?: Partial<FilterType> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<Props>(), { |
|
|
|
const props = withDefaults(defineProps<Props>(), { |
|
|
|
nestedLevel: 0, |
|
|
|
nestedLevel: 0, |
|
|
|
autoSave: true, |
|
|
|
autoSave: true, |
|
|
@ -21,13 +22,14 @@ const props = withDefaults(defineProps<Props>(), { |
|
|
|
webHook: false, |
|
|
|
webHook: false, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['update:filtersLength', 'update:draftFilter']) |
|
|
|
const emit = defineEmits(['update:filtersLength', 'update:draftFilter', 'update:modelValue']) |
|
|
|
|
|
|
|
|
|
|
|
const excludedFilterColUidt = [UITypes.QrCode, UITypes.Barcode] |
|
|
|
const excludedFilterColUidt = [UITypes.QrCode, UITypes.Barcode] |
|
|
|
|
|
|
|
|
|
|
|
const draftFilter = useVModel(props, 'draftFilter', emit) |
|
|
|
const draftFilter = useVModel(props, 'draftFilter', emit) |
|
|
|
|
|
|
|
const modelValue = useVModel(props, 'modelValue', emit) |
|
|
|
|
|
|
|
|
|
|
|
const { nestedLevel, parentId, autoSave, hookId, modelValue, showLoading, webHook } = toRefs(props) |
|
|
|
const { nestedLevel, parentId, autoSave, hookId, showLoading, webHook } = toRefs(props) |
|
|
|
|
|
|
|
|
|
|
|
const nested = computed(() => nestedLevel.value > 0) |
|
|
|
const nested = computed(() => nestedLevel.value > 0) |
|
|
|
|
|
|
|
|
|
|
@ -66,7 +68,7 @@ const { |
|
|
|
types, |
|
|
|
types, |
|
|
|
} = useViewFilters( |
|
|
|
} = useViewFilters( |
|
|
|
activeView, |
|
|
|
activeView, |
|
|
|
parentId?.value, |
|
|
|
parentId, |
|
|
|
computed(() => autoSave.value), |
|
|
|
computed(() => autoSave.value), |
|
|
|
() => reloadDataHook.trigger({ shouldShowLoading: showLoading.value, offset: 0 }), |
|
|
|
() => reloadDataHook.trigger({ shouldShowLoading: showLoading.value, offset: 0 }), |
|
|
|
modelValue.value || nestedFilters.value, |
|
|
|
modelValue.value || nestedFilters.value, |
|
|
@ -250,7 +252,7 @@ const updateFilterValue = (value: string, filter: Filter, index: number) => { |
|
|
|
|
|
|
|
|
|
|
|
defineExpose({ |
|
|
|
defineExpose({ |
|
|
|
applyChanges, |
|
|
|
applyChanges, |
|
|
|
parentId: parentId?.value, |
|
|
|
parentId, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const scrollToBottom = () => { |
|
|
|
const scrollToBottom = () => { |
|
|
@ -355,22 +357,35 @@ 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) |
|
|
|
}), |
|
|
|
}), |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
await filterUpdateCondition(filter, index) |
|
|
|
await saveOrUpdate(filter, index) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// watch for changes in filters and update the modelValue |
|
|
|
|
|
|
|
watch( |
|
|
|
|
|
|
|
filters, |
|
|
|
|
|
|
|
() => { |
|
|
|
|
|
|
|
if (modelValue.value !== filters.value) modelValue.value = filters.value |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
immediate: true, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
@ -403,9 +418,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"> |
|
|
@ -434,7 +449,7 @@ const onLogicalOpUpdate = async (filter: Filter, index: number) => { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="flex border-1 rounded-lg p-2 w-full" :class="nestedLevel % 2 !== 0 ? 'bg-white' : 'bg-gray-100'"> |
|
|
|
<div class="flex border-1 rounded-lg p-2 w-full" :class="nestedLevel % 2 !== 0 ? 'bg-white' : 'bg-gray-100'"> |
|
|
|
<LazySmartsheetToolbarColumnFilter |
|
|
|
<LazySmartsheetToolbarColumnFilter |
|
|
|
v-if="filter.id || filter.children" |
|
|
|
v-if="filter.id || filter.children || !autoSave" |
|
|
|
:key="filter.id ?? i" |
|
|
|
:key="filter.id ?? i" |
|
|
|
ref="localNestedFilters" |
|
|
|
ref="localNestedFilters" |
|
|
|
v-model="filter.children" |
|
|
|
v-model="filter.children" |
|
|
@ -456,7 +471,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 |
|
|
|