From 6624bf5091817a5b202f3d6e9ea1423e319f41be Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 5 Jun 2024 17:28:02 +0530 Subject: [PATCH] Nc feat/links view filter (#8646) * feat(nocodb): add support for limiting selection to specific views * test: fix failing tests * fix: failing playwright tests * feat: allow updating static view filter from both sides * fix: remove console logs * refactor: rename migration name * fix: corrections in ui and update api * fix: apply same behaviour for LTAR column(bt) * refactor: rename view id column in relation to avoid confusion * fix: option to disable view filter(switch) * refactor: some minor ui spacing corrections * fix: avoid setting target view id for bt relation when creating hm relation * feat: links - record selection based on custom filters * fix: corrections * feat: add edit support for conditions * feat: option to switch between dynamic and static value * fix: backend corrections * feat: apis for links filter * feat: filter api integration with ui * feat: filter with save and update * feat: dynamic filter * feat: shared form filter * feat: expanded form * fix: missing imports and corrections * fix: pass correct column list * fix: nested filter bug * fix: corrections in actions and swagger * fix: missing add button menu * fix: expanded form bug * test: playwright test - WIP * test: playwright - link with filters/view * chore: lint * refactor: ui corrections * fix: remove unnecessary filtering from hm/mm list and count * fix: filter ui correction * fix: lable correction * fix: skip view filter for rollup * fix: ui corrections * fix: extract correct column id * fix: duplicate LTAR - missing target view * feat: add duplicate support for link with filters/view * fix: height issue and nested filter creation bug * fix: pass metadata to nested filter component * fix: filter on column creation * fix: filter getting cloned under group * fix: exclude deleted filters when deciding locked state * fix: update state when switching to dynamic filter * fix: unlink view on delete and handle undefined values as null * fix: filter based on unsaved data * fix: handle overflow * fix: multi-field editor - filter UI correction * fix: duplicate link column with dynamic field ref * fix: remove virtual column support * fix: add support to link filter in normal list method * fix: apply filter on count query * fix: pass correct column list * feat: add link filter support in multifield column creation * feat: add link filter support in multifield column creation * Merge branch 'develop' into feat/links-view-filter * fix: dynamic value column export * fix: review comments * test: kludge for groupby tests * fix: extract updated status correctly * test: try waitFor for links * test: kludge * refactor: exclude attachment & rating from dynamic filter and treat float and integer as number * test: label correction * refactor: replace try...catch and use if condition * fix: apply conditions only if enabled * fix: MFE bugs * refactor: show radio button active border only when focused * fix: proper state handling * fix: view delete - unlink from link column * fix: duplicate Link with filter view id * refactor: column filter section padding * fix: exclude system columns * fix: dynamic column filter logic correction * refactor: cleanup * test: kludge with delay for groupby test * refactor: add missing placeholder method * docs: limit link record selection * refactor: add missing placeholder method * chore: lint --------- Co-authored-by: DarkPhoenix2704 Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .../smartsheet/column/EditOrAdd.vue | 24 +- .../smartsheet/column/LinkOptions.vue | 5 + .../column/LinkedToAnotherRecordOptions.vue | 153 +++- .../smartsheet/column/SelectOptions.vue | 12 +- .../column/UITypesOptionsWithSearch.vue | 7 +- .../components/smartsheet/details/Api.vue | 2 +- .../components/smartsheet/details/Fields.vue | 62 +- .../smartsheet/expanded-form/Comments.vue | 1 - .../expanded-form/RichTextOptions.vue | 1 - .../smartsheet/expanded-form/index.vue | 2 +- .../components/smartsheet/header/Menu.vue | 2 +- .../smartsheet/toolbar/ColumnFilter.vue | 328 +++++++-- .../smartsheet/toolbar/ColumnFilterMenu.vue | 6 +- .../toolbar/FieldListAutoCompleteDropdown.vue | 7 +- .../smartsheet/toolbar/GroupByMenu.vue | 1 + .../smartsheet/toolbar/SortListMenu.vue | 1 + .../virtual-cell/components/UnLinkedItems.vue | 3 +- .../composables/useColumnCreateStore.ts | 18 +- packages/nc-gui/composables/useLTARStore.ts | 27 + .../composables/useSharedFormViewStore.ts | 1 - packages/nc-gui/composables/useViewFilters.ts | 107 ++- packages/nc-gui/lang/en.json | 3 + .../040.links-based/010.links.md | 83 ++- .../img/v2/fields/types/limit-by-filter.png | Bin 0 -> 253969 bytes .../img/v2/fields/types/limit-by-view.png | Bin 0 -> 256607 bytes .../fields/types/link-filter-settings-2.png | Bin 0 -> 272935 bytes .../v2/fields/types/link-filter-settings.png | Bin 0 -> 246899 bytes .../static/img/v2/fields/types/links.png | Bin 177504 -> 182991 bytes .../src/controllers/filters.controller.ts | 2 +- .../controllers/public-datas.controller.ts | 11 + packages/nocodb/src/db/BaseModelSqlv2.ts | 659 ++++++++++++------ packages/nocodb/src/db/genRollupSelectv2.ts | 152 ++-- packages/nocodb/src/helpers/columnHelpers.ts | 12 +- .../meta/migrations/XcMigrationSourcev2.ts | 4 + .../meta/migrations/v2/nc_048_view_links.ts | 26 + packages/nocodb/src/models/Column.ts | 26 +- packages/nocodb/src/models/Filter.ts | 51 +- .../src/models/LinkToAnotherRecordColumn.ts | 19 + packages/nocodb/src/models/View.ts | 20 + .../jobs/export-import/duplicate.processor.ts | 2 +- .../jobs/jobs/export-import/export.service.ts | 59 +- .../jobs/jobs/export-import/import.service.ts | 61 +- packages/nocodb/src/schema/swagger-v2.json | 3 + packages/nocodb/src/schema/swagger.json | 29 + .../src/services/app-hooks/interfaces.ts | 1 + .../nocodb/src/services/columns.service.ts | 100 ++- packages/nocodb/src/services/datas.service.ts | 16 +- .../nocodb/src/services/filters.service.ts | 10 + .../src/services/public-datas.service.ts | 28 +- .../pages/Dashboard/Details/FieldsPage.ts | 2 +- .../pages/Dashboard/ExpandedForm/index.ts | 18 +- .../Dashboard/Grid/Column/LTAR/LinkRecord.ts | 5 + .../Dashboard/Grid/Column/LTARFilterOption.ts | 13 + .../Dashboard/Grid/Column/LTAROptionColumn.ts | 61 ++ .../pages/Dashboard/Grid/Column/index.ts | 19 + .../playwright/pages/Dashboard/Grid/Group.ts | 4 + .../pages/Dashboard/common/Toolbar/Filter.ts | 22 +- .../db/general/toolbarOperations.spec.ts | 1 + .../tests/db/views/viewGridShare.spec.ts | 9 + 59 files changed, 1797 insertions(+), 504 deletions(-) create mode 100644 packages/noco-docs/static/img/v2/fields/types/limit-by-filter.png create mode 100644 packages/noco-docs/static/img/v2/fields/types/limit-by-view.png create mode 100644 packages/noco-docs/static/img/v2/fields/types/link-filter-settings-2.png create mode 100644 packages/noco-docs/static/img/v2/fields/types/link-filter-settings.png create mode 100644 packages/nocodb/src/meta/migrations/v2/nc_048_view_links.ts create mode 100644 tests/playwright/pages/Dashboard/Grid/Column/LTARFilterOption.ts create mode 100644 tests/playwright/pages/Dashboard/Grid/Column/LTAROptionColumn.ts diff --git a/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue b/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue index c272eb8cbb..c4e462a0b1 100644 --- a/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue +++ b/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue @@ -192,15 +192,20 @@ onMounted(() => { ...formState.value, ...others, } + if (colOptions) { + const meta = formState.value.meta || {} onUidtOrIdTypeChange() formState.value = { ...formState.value, colOptions: { ...colOptions, }, + meta, } } + } else { + formState.value.filters = undefined } // for cases like formula @@ -269,21 +274,16 @@ const submitBtnLabel = computed(() => { loadingLabel: `${isEdit.value && !props.columnLabel ? t('general.updating') : t('general.saving')} ${columnLabel.value}`, } }) - -const filterOption = (input: string, option: { value: UITypes }) => { - return ( - option.value.toLowerCase().includes(input.toLowerCase()) || - (UITypesName[option.value] && UITypesName[option.value].toLowerCase().includes(input.toLowerCase())) - ) -} @@ -459,29 +575,35 @@ watchEffect(() => {