Browse Source

filter(gui-v2): correction in filter delete

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3005/head
Pranav C 2 years ago
parent
commit
ac046a24a9
  1. 1
      packages/nc-gui-v2/components.d.ts
  2. 2
      packages/nc-gui-v2/components/smartsheet-toolbar/ColumnFilter.vue
  3. 27
      packages/nc-gui-v2/composables/useViewFilters.ts

1
packages/nc-gui-v2/components.d.ts vendored

@ -7,7 +7,6 @@ export {}
declare module '@vue/runtime-core' { declare module '@vue/runtime-core' {
export interface GlobalComponents { export interface GlobalComponents {
'(fix(gui-v2)': block user from editing pk and ai values)
AAlert: typeof import('ant-design-vue/es')['Alert'] AAlert: typeof import('ant-design-vue/es')['Alert']
AAutoComplete: typeof import('ant-design-vue/es')['AutoComplete'] AAutoComplete: typeof import('ant-design-vue/es')['AutoComplete']
AButton: typeof import('ant-design-vue/es')['Button'] AButton: typeof import('ant-design-vue/es')['Button']

2
packages/nc-gui-v2/components/smartsheet-toolbar/ColumnFilter.vue

@ -124,7 +124,7 @@ defineExpose({
v-if="!filter.readOnly" v-if="!filter.readOnly"
:key="i" :key="i"
small small
class="nc-filter-item-remove-btn text-grey" class="nc-filter-item-remove-btn cursor-pointer text-grey"
@click.stop="deleteFilter(filter, i)" @click.stop="deleteFilter(filter, i)"
/> />
<span v-else :key="`${i}dummy`" /> <span v-else :key="`${i}dummy`" />

27
packages/nc-gui-v2/composables/useViewFilters.ts

@ -43,19 +43,24 @@ export function useViewFilters(
} }
const deleteFilter = async (filter: FilterType & { status: string }, i: number) => { const deleteFilter = async (filter: FilterType & { status: string }, i: number) => {
// if shared or sync permission not allowed simply remove it from array
if (shared || !isUIAllowed('filterSync')) { if (shared || !isUIAllowed('filterSync')) {
const _filters = unref(filters.value) filters.value.splice(i, 1)
_filters.splice(i, 1) reloadData?.()
filters.value = _filters } else {
} else if (filter.id) { if (filter.id) {
if (!autoApply?.value) { // if auto-apply disabled mark it as disabled
filter.status = 'delete' if (!autoApply?.value) {
filter.status = 'delete'
// if auto-apply enabled invoke delete api and remove from array
} else {
await $api.dbTableFilter.delete(filter.id)
reloadData?.()
filters.value.splice(i, 1)
}
// if not synced yet remove it from array
} else { } else {
await $api.dbTableFilter.delete(filter.id) filters.value.splice(i, 1)
const _filters = unref(filters.value)
_filters.splice(i, 1)
filters.value = _filters
reloadData?.()
} }
} }
} }

Loading…
Cancel
Save