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. 6
      packages/nc-gui/components/virtual-cell/components/UnLinkedItems.vue
  4. 7
      packages/nc-gui/composables/useLTARStore.ts
  5. 7
      packages/nocodb/src/models/CalendarViewColumn.ts
  6. 85
      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 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
const localState = ref(value)
@ -54,21 +56,21 @@ const vModel = computed({
get: () => value,
set: (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)
}
},
})
const isValid = computed(() => value && isValidURL(value))
const isValid = computed(() => value && isValidURL(trim(value)))
const url = computed(() => {
if (!value || !isValidURL(value)) return ''
if (!value || !isValidURL(trim(value))) return ''
/** 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)
@ -84,7 +86,7 @@ watch(
parseProp(column.value.meta)?.validate &&
!editEnabled.value &&
localState.value &&
!isValidURL(localState.value)
!isValidURL(trim(localState.value))
) {
message.error(t('msg.error.invalidURL'))
localState.value = undefined

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

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

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

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

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

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

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

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

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

@ -823,64 +823,33 @@ export default class Column<T = any> implements ColumnType {
);
}
// Grid View Columns
await ncMeta.metaDelete(null, null, MetaTable.GRID_VIEW_COLUMNS, {
fk_column_id: col.id,
});
const gridViewColumnId = await NocoCache.get(
`${CacheScope.GRID_VIEW_COLUMN}:${col.id}`,
CacheGetType.TYPE_STRING,
);
if (gridViewColumnId) {
await NocoCache.deepDel(
`${CacheScope.GRID_VIEW_COLUMN}:${gridViewColumnId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
}
// 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
await ncMeta.metaDelete(null, null, MetaTable.KANBAN_VIEW_COLUMNS, {
fk_column_id: col.id,
});
const kanbanViewColumnId = await NocoCache.get(
`${CacheScope.KANBAN_VIEW_COLUMN}:${col.id}`,
CacheGetType.TYPE_STRING,
);
if (kanbanViewColumnId) {
await NocoCache.deepDel(
`${CacheScope.KANBAN_VIEW_COLUMN}:${kanbanViewColumnId}`,
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,
);
// Delete from all view columns
const viewColumnTables = [
MetaTable.GRID_VIEW_COLUMNS,
MetaTable.FORM_VIEW_COLUMNS,
MetaTable.KANBAN_VIEW_COLUMNS,
MetaTable.GALLERY_VIEW_COLUMNS,
];
const viewColumnCacheScope = [
CacheScope.GRID_VIEW_COLUMN,
CacheScope.FORM_VIEW_COLUMN,
CacheScope.KANBAN_VIEW_COLUMN,
CacheScope.GALLERY_VIEW_COLUMN,
];
for (let i = 0; i < viewColumnTables.length; i++) {
const table = viewColumnTables[i];
const cacheScope = viewColumnCacheScope[i];
const viewColumns = await ncMeta.metaList2(null, null, table, {
condition: { fk_column_id: id },
});
await ncMeta.metaDelete(null, null, table, { fk_column_id: id });
for (const viewColumn of viewColumns) {
await NocoCache.deepDel(
`${cacheScope}:${viewColumn.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
}
}
// 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;
}
const { id, fk_column_id } = await ncMeta.metaInsert2(
const { id } = await ncMeta.metaInsert2(
null,
null,
MetaTable.FORM_VIEW_COLUMNS,
insertObj,
);
await NocoCache.set(`${CacheScope.FORM_VIEW_COLUMN}:${fk_column_id}`, id);
return this.get(id, ncMeta).then(async (viewColumn) => {
await NocoCache.appendToList(
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;
}
const { id, fk_column_id } = await ncMeta.metaInsert2(
const { id } = await ncMeta.metaInsert2(
null,
null,
MetaTable.GALLERY_VIEW_COLUMNS,
insertObj,
);
await NocoCache.set(
`${CacheScope.GALLERY_VIEW_COLUMN}:${fk_column_id}`,
id,
);
// on new view column, delete any optimised single query cache
{
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,
);
await NocoCache.set(`${CacheScope.GRID_VIEW_COLUMN}:${fk_column_id}`, id);
await View.fixPVColumnForView(column.fk_view_id, ncMeta);
// 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;
}
const { id, fk_column_id } = await ncMeta.metaInsert2(
const { id } = await ncMeta.metaInsert2(
null,
null,
MetaTable.KANBAN_VIEW_COLUMNS,
insertObj,
);
await NocoCache.set(`${CacheScope.KANBAN_VIEW_COLUMN}:${fk_column_id}`, id);
return this.get(id, ncMeta).then(async (kanbanViewColumn) => {
await NocoCache.appendToList(
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;
}
const { id, fk_column_id } = await ncMeta.metaInsert2(
const { id } = await ncMeta.metaInsert2(
null,
null,
MetaTable.MAP_VIEW_COLUMNS,
insertObj,
);
await NocoCache.set(`${CacheScope.MAP_VIEW_COLUMN}:${fk_column_id}`, id);
return this.get(id, ncMeta).then(async (viewCol) => {
await NocoCache.appendToList(
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);
if (!model) {
NcError.tableNotFound(param.tableId);
}
const viewList = await xcVisibilityMetaGet({
baseId: model.base_id,
models: [model],

Loading…
Cancel
Save