Browse Source

fix(api): avoid unnecessary filter reload

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3977/head
Pranav C 2 years ago
parent
commit
5daac02ced
  1. 7
      packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue
  2. 2
      packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
  3. 4
      packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue
  4. 2
      packages/nc-gui/composables/useViewColumns.ts
  5. 2
      packages/nc-gui/composables/useViewFilters.ts

7
packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue

@ -42,9 +42,11 @@ const filtersLength = ref(0)
watch(
() => activeView?.value,
async () => {
async (view) => {
if (view?.id) {
await loadFilters()
filtersLength.value = filters.value.length || 0
}
},
{ immediate: true },
)
@ -83,7 +85,8 @@ const filterAutoSaveLoc = computed({
@update:filters-length="filtersLength = $event"
>
<div v-if="!isPublic" class="flex items-end mt-2 min-h-[30px]" @click.stop>
<a-checkbox id="col-filter-checkbox" v-model:checked="filterAutoSaveLoc" class="col-filter-checkbox" hide-details dense>
<a-checkbox id="col-filter-checkbox" v-model:checked="filterAutoSaveLoc" class="col-filter-checkbox"
hide-details dense>
<span class="text-grey text-xs">
{{ $t('msg.info.filterAutoApply') }}
<!-- Auto apply -->

2
packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue

@ -51,7 +51,7 @@ const {
watch(
() => activeView.value?.id,
async (newVal, oldVal) => {
if (newVal !== oldVal && meta.value) {
if (newVal && newVal !== oldVal && meta.value) {
await loadViewColumns()
}
},

4
packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue

@ -32,8 +32,8 @@ const columnByID = computed(() =>
watch(
() => view.value?.id,
() => {
loadSorts()
(viewId) => {
if(viewId)loadSorts()
},
{ immediate: true },
)

2
packages/nc-gui/composables/useViewColumns.ts

@ -207,7 +207,7 @@ export function useViewColumns(
// reload view columns when table meta changes
watch(meta, async (newVal, oldVal) => {
if (newVal !== oldVal && meta.value) {
if (newVal !== oldVal && newVal) {
await loadViewColumns()
}
})

2
packages/nc-gui/composables/useViewFilters.ts

@ -218,7 +218,7 @@ export function useViewFilters(
return metas?.value?.[view?.value?.fk_model_id as string]?.columns?.length || 0
},
async (nextColsLength, oldColsLength) => {
if (nextColsLength < oldColsLength) await loadFilters()
if (nextColsLength && nextColsLength < oldColsLength) await loadFilters()
},
)

Loading…
Cancel
Save