Browse Source

Merge pull request #8178 from nocodb/nc-fix/column-delete-bug

Nc fix/column delete bug
pull/8180/head
Pranav C 8 months ago committed by GitHub
parent
commit
e7214918b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      packages/nc-gui/components/cell/Url.vue
  2. 2
      packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue
  3. 4
      packages/nc-gui/components/virtual-cell/components/UnLinkedItems.vue
  4. 5
      packages/nc-gui/composables/useLTARStore.ts
  5. 7
      packages/nocodb/src/models/CalendarViewColumn.ts
  6. 73
      packages/nocodb/src/models/Column.ts
  7. 4
      packages/nocodb/src/models/FormViewColumn.ts
  8. 7
      packages/nocodb/src/models/GalleryViewColumn.ts
  9. 2
      packages/nocodb/src/models/GridViewColumn.ts
  10. 4
      packages/nocodb/src/models/KanbanViewColumn.ts
  11. 4
      packages/nocodb/src/models/MapViewColumn.ts
  12. 4
      packages/nocodb/src/services/views.service.ts

14
packages/nc-gui/components/cell/Url.vue

@ -47,6 +47,8 @@ const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!
const isForm = inject(IsFormInj)! const isForm = inject(IsFormInj)!
const trim = (val: string) => val?.trim?.()
// Used in the logic of when to display error since we are not storing the url if it's not valid // Used in the logic of when to display error since we are not storing the url if it's not valid
const localState = ref(value) const localState = ref(value)
@ -54,21 +56,21 @@ const vModel = computed({
get: () => value, get: () => value,
set: (val) => { set: (val) => {
localState.value = val localState.value = val
if (!parseProp(column.value.meta)?.validate || (val && isValidURL(val)) || !val || isForm.value) { if (!parseProp(column.value.meta)?.validate || (val && isValidURL(trim(val))) || !val || isForm.value) {
emit('update:modelValue', val) emit('update:modelValue', val)
} }
}, },
}) })
const isValid = computed(() => value && isValidURL(value)) const isValid = computed(() => value && isValidURL(trim(value)))
const url = computed(() => { const url = computed(() => {
if (!value || !isValidURL(value)) return '' if (!value || !isValidURL(trim(value))) return ''
/** add url scheme if missing */ /** add url scheme if missing */
if (/^https?:\/\//.test(value)) return value if (/^https?:\/\//.test(trim(value))) return trim(value)
return `https://${value}` return `https://${trim(value)}`
}) })
const { cellUrlOptions } = useCellUrlConfig(url) const { cellUrlOptions } = useCellUrlConfig(url)
@ -84,7 +86,7 @@ watch(
parseProp(column.value.meta)?.validate && parseProp(column.value.meta)?.validate &&
!editEnabled.value && !editEnabled.value &&
localState.value && localState.value &&
!isValidURL(localState.value) !isValidURL(trim(localState.value))
) { ) {
message.error(t('msg.error.invalidURL')) message.error(t('msg.error.invalidURL'))
localState.value = undefined localState.value = undefined

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

@ -81,7 +81,7 @@ const {
activeView, activeView,
parentId?.value, parentId?.value,
computed(() => autoSave.value), computed(() => autoSave.value),
() => reloadDataHook.trigger({ shouldShowLoading: showLoading.value }), () => reloadDataHook.trigger({ shouldShowLoading: showLoading.value, offset: 0 }),
modelValue.value || nestedFilters.value, modelValue.value || nestedFilters.value,
!modelValue.value, !modelValue.value,
webHook.value, webHook.value,

4
packages/nc-gui/components/virtual-cell/components/UnLinkedItems.vue

@ -51,7 +51,7 @@ const {
unlink, unlink,
row, row,
headerDisplayValue, headerDisplayValue,
resetChildrenExcludedOffsetCount resetChildrenExcludedOffsetCount,
} = useLTARStoreOrThrow() } = useLTARStoreOrThrow()
const { addLTARRef, isNew, removeLTARRef, state: rowState } = useSmartsheetRowStoreOrThrow() const { addLTARRef, isNew, removeLTARRef, state: rowState } = useSmartsheetRowStoreOrThrow()
@ -262,7 +262,7 @@ onUnmounted(() => {
}) })
const onFilterChange = () => { const onFilterChange = () => {
childrenExcludedListPagination.page = 1; childrenExcludedListPagination.page = 1
resetChildrenExcludedOffsetCount() resetChildrenExcludedOffsetCount()
} }
</script> </script>

5
packages/nc-gui/composables/useLTARStore.ts

@ -191,7 +191,8 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
const loadChildrenExcludedList = async (activeState?: any) => { const loadChildrenExcludedList = async (activeState?: any) => {
if (activeState) newRowState.state = activeState if (activeState) newRowState.state = activeState
try { try {
let offset = childrenExcludedListPagination.size * (childrenExcludedListPagination.page - 1) - childrenExcludedOffsetCount.value let offset =
childrenExcludedListPagination.size * (childrenExcludedListPagination.page - 1) - childrenExcludedOffsetCount.value
if (offset < 0) { if (offset < 0) {
offset = 0 offset = 0
@ -551,7 +552,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
}) })
const resetChildrenExcludedOffsetCount = () => { const resetChildrenExcludedOffsetCount = () => {
childrenExcludedOffsetCount.value = 0; childrenExcludedOffsetCount.value = 0
} }
const resetChildrenListOffsetCount = () => { const resetChildrenListOffsetCount = () => {

7
packages/nocodb/src/models/CalendarViewColumn.ts

@ -79,18 +79,13 @@ export default class CalendarViewColumn {
insertObj.source_id = viewRef.source_id; insertObj.source_id = viewRef.source_id;
} }
const { id, fk_column_id } = await ncMeta.metaInsert2( const { id } = await ncMeta.metaInsert2(
null, null,
null, null,
MetaTable.CALENDAR_VIEW_COLUMNS, MetaTable.CALENDAR_VIEW_COLUMNS,
insertObj, insertObj,
); );
await NocoCache.set(
`${CacheScope.CALENDAR_VIEW_COLUMN}:${fk_column_id}`,
id,
);
{ {
const view = await View.get(column.fk_view_id, ncMeta); const view = await View.get(column.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta); await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);

73
packages/nocodb/src/models/Column.ts

@ -823,64 +823,33 @@ export default class Column<T = any> implements ColumnType {
); );
} }
// Grid View Columns // Delete from all view columns
await ncMeta.metaDelete(null, null, MetaTable.GRID_VIEW_COLUMNS, { const viewColumnTables = [
fk_column_id: col.id, MetaTable.GRID_VIEW_COLUMNS,
}); MetaTable.FORM_VIEW_COLUMNS,
const gridViewColumnId = await NocoCache.get( MetaTable.KANBAN_VIEW_COLUMNS,
`${CacheScope.GRID_VIEW_COLUMN}:${col.id}`, MetaTable.GALLERY_VIEW_COLUMNS,
CacheGetType.TYPE_STRING, ];
); const viewColumnCacheScope = [
if (gridViewColumnId) { CacheScope.GRID_VIEW_COLUMN,
await NocoCache.deepDel( CacheScope.FORM_VIEW_COLUMN,
`${CacheScope.GRID_VIEW_COLUMN}:${gridViewColumnId}`, CacheScope.KANBAN_VIEW_COLUMN,
CacheDelDirection.CHILD_TO_PARENT, CacheScope.GALLERY_VIEW_COLUMN,
); ];
}
// Form View Columns
await ncMeta.metaDelete(null, null, MetaTable.FORM_VIEW_COLUMNS, {
fk_column_id: col.id,
});
const formViewColumnId = await NocoCache.get(
`${CacheScope.FORM_VIEW_COLUMN}:${col.id}`,
CacheGetType.TYPE_STRING,
);
if (formViewColumnId) {
await NocoCache.deepDel(
`${CacheScope.FORM_VIEW_COLUMN}:${formViewColumnId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
}
// Kanban View Columns for (let i = 0; i < viewColumnTables.length; i++) {
await ncMeta.metaDelete(null, null, MetaTable.KANBAN_VIEW_COLUMNS, { const table = viewColumnTables[i];
fk_column_id: col.id, const cacheScope = viewColumnCacheScope[i];
const viewColumns = await ncMeta.metaList2(null, null, table, {
condition: { fk_column_id: id },
}); });
const kanbanViewColumnId = await NocoCache.get( await ncMeta.metaDelete(null, null, table, { fk_column_id: id });
`${CacheScope.KANBAN_VIEW_COLUMN}:${col.id}`, for (const viewColumn of viewColumns) {
CacheGetType.TYPE_STRING,
);
if (kanbanViewColumnId) {
await NocoCache.deepDel( await NocoCache.deepDel(
`${CacheScope.KANBAN_VIEW_COLUMN}:${kanbanViewColumnId}`, `${cacheScope}:${viewColumn.id}`,
CacheDelDirection.CHILD_TO_PARENT, CacheDelDirection.CHILD_TO_PARENT,
); );
} }
// Gallery View Column
await ncMeta.metaDelete(null, null, MetaTable.GALLERY_VIEW_COLUMNS, {
fk_column_id: col.id,
});
const galleryViewColumnId = await NocoCache.get(
`${CacheScope.GALLERY_VIEW_COLUMN}:${col.id}`,
CacheGetType.TYPE_STRING,
);
if (galleryViewColumnId) {
await NocoCache.deepDel(
`${CacheScope.GALLERY_VIEW_COLUMN}:${galleryViewColumnId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
} }
// Get LTAR columns in which current column is referenced as foreign key // Get LTAR columns in which current column is referenced as foreign key

4
packages/nocodb/src/models/FormViewColumn.ts

@ -92,15 +92,13 @@ export default class FormViewColumn implements FormColumnType {
insertObj.source_id = viewRef.source_id; insertObj.source_id = viewRef.source_id;
} }
const { id, fk_column_id } = await ncMeta.metaInsert2( const { id } = await ncMeta.metaInsert2(
null, null,
null, null,
MetaTable.FORM_VIEW_COLUMNS, MetaTable.FORM_VIEW_COLUMNS,
insertObj, insertObj,
); );
await NocoCache.set(`${CacheScope.FORM_VIEW_COLUMN}:${fk_column_id}`, id);
return this.get(id, ncMeta).then(async (viewColumn) => { return this.get(id, ncMeta).then(async (viewColumn) => {
await NocoCache.appendToList( await NocoCache.appendToList(
CacheScope.FORM_VIEW_COLUMN, CacheScope.FORM_VIEW_COLUMN,

7
packages/nocodb/src/models/GalleryViewColumn.ts

@ -66,18 +66,13 @@ export default class GalleryViewColumn {
insertObj.source_id = viewRef.source_id; insertObj.source_id = viewRef.source_id;
} }
const { id, fk_column_id } = await ncMeta.metaInsert2( const { id } = await ncMeta.metaInsert2(
null, null,
null, null,
MetaTable.GALLERY_VIEW_COLUMNS, MetaTable.GALLERY_VIEW_COLUMNS,
insertObj, insertObj,
); );
await NocoCache.set(
`${CacheScope.GALLERY_VIEW_COLUMN}:${fk_column_id}`,
id,
);
// on new view column, delete any optimised single query cache // on new view column, delete any optimised single query cache
{ {
const view = await View.get(column.fk_view_id, ncMeta); const view = await View.get(column.fk_view_id, ncMeta);

2
packages/nocodb/src/models/GridViewColumn.ts

@ -107,8 +107,6 @@ export default class GridViewColumn implements GridColumnType {
insertObj, insertObj,
); );
await NocoCache.set(`${CacheScope.GRID_VIEW_COLUMN}:${fk_column_id}`, id);
await View.fixPVColumnForView(column.fk_view_id, ncMeta); await View.fixPVColumnForView(column.fk_view_id, ncMeta);
// on new view column, delete any optimised single query cache // on new view column, delete any optimised single query cache

4
packages/nocodb/src/models/KanbanViewColumn.ts

@ -63,15 +63,13 @@ export default class KanbanViewColumn implements KanbanColumnType {
insertObj.source_id = viewRef.source_id; insertObj.source_id = viewRef.source_id;
} }
const { id, fk_column_id } = await ncMeta.metaInsert2( const { id } = await ncMeta.metaInsert2(
null, null,
null, null,
MetaTable.KANBAN_VIEW_COLUMNS, MetaTable.KANBAN_VIEW_COLUMNS,
insertObj, insertObj,
); );
await NocoCache.set(`${CacheScope.KANBAN_VIEW_COLUMN}:${fk_column_id}`, id);
return this.get(id, ncMeta).then(async (kanbanViewColumn) => { return this.get(id, ncMeta).then(async (kanbanViewColumn) => {
await NocoCache.appendToList( await NocoCache.appendToList(
CacheScope.KANBAN_VIEW_COLUMN, CacheScope.KANBAN_VIEW_COLUMN,

4
packages/nocodb/src/models/MapViewColumn.ts

@ -57,15 +57,13 @@ export default class MapViewColumn {
insertObj.source_id = viewRef.source_id; insertObj.source_id = viewRef.source_id;
} }
const { id, fk_column_id } = await ncMeta.metaInsert2( const { id } = await ncMeta.metaInsert2(
null, null,
null, null,
MetaTable.MAP_VIEW_COLUMNS, MetaTable.MAP_VIEW_COLUMNS,
insertObj, insertObj,
); );
await NocoCache.set(`${CacheScope.MAP_VIEW_COLUMN}:${fk_column_id}`, id);
return this.get(id, ncMeta).then(async (viewCol) => { return this.get(id, ncMeta).then(async (viewCol) => {
await NocoCache.appendToList( await NocoCache.appendToList(
CacheScope.MAP_VIEW_COLUMN, CacheScope.MAP_VIEW_COLUMN,

4
packages/nocodb/src/services/views.service.ts

@ -76,6 +76,10 @@ export class ViewsService {
}) { }) {
const model = await Model.get(param.tableId); const model = await Model.get(param.tableId);
if (!model) {
NcError.tableNotFound(param.tableId);
}
const viewList = await xcVisibilityMetaGet({ const viewList = await xcVisibilityMetaGet({
baseId: model.base_id, baseId: model.base_id,
models: [model], models: [model],

Loading…
Cancel
Save