π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix: shared view fixes
DarkPhoenix27040acc0ea3215e
diff --git a/packages/nc-gui/components/smartsheet/Kanban.vue b/packages/nc-gui/components/smartsheet/Kanban.vueindex d14b4b45b5..9e1f844f25 100644--- a/packages/nc-gui/components/smartsheet/Kanban.vue+++ b/packages/nc-gui/components/smartsheet/Kanban.vue@@ -58,9 +58,11 @@ const {addEmptyRow,groupingFieldColOptions,groupingField,+ stackMetaObj,groupingFieldColumn,countByStack,deleteStack,+ updateKanbanMeta,shouldScrollToRight,deleteRow,moveHistory,@@ -234,22 +236,52 @@ async function onMoveStack(event: any, undo = false) {if (event.moved) {const { oldIndex, newIndex } = event.moved- await updateStackProperty(oldIndex, { order: newIndex })- await updateStackProperty(newIndex, { order: oldIndex })+ // Create a copy of the current stack metadata+ const stackMeta = [...groupingFieldColOptions.value]++ // Update both stacks in the local copy+ stackMeta[oldIndex] = { ...stackMeta[oldIndex], order: newIndex }+ stackMeta[newIndex] = { ...stackMeta[newIndex], order: oldIndex }++ // Prepare the updated stack metadata object+ const updatedStackMetaObj = {+ ...stackMetaObj.value,+ [kanbanMetaData.value.fk_grp_col_id!]: stackMeta,+ }++ await updateKanbanMeta({+ meta: updatedStackMetaObj,+ })if (!undo) {addUndo({undo: {fn: async (e: any) => {- await updateStackProperty(e.moved.newIndex, { order: e.moved.oldIndex })- await updateStackProperty(e.moved.oldIndex, { order: e.moved.newIndex })+ const undoStackMeta = [...groupingFieldColOptions.value]+ undoStackMeta[e.moved.newIndex] = { ...undoStackMeta[e.moved.newIndex], order: e.moved.oldIndex }+ undoStackMeta[e.moved.oldIndex] = { ...undoStackMeta[e.moved.oldIndex], order: e.moved.newIndex }++ const undoStackMetaObj = {+ ...stackMetaObj.value,+ [kanbanMetaData.value.fk_grp_col_id!]: undoStackMeta,+ }++ await updateKanbanMeta({ meta: undoStackMetaObj })},args: [{ moved: { oldIndex, newIndex } }],},redo: {fn: async (e: any) => {- await updateStackProperty(e.moved.oldIndex, { order: e.moved.newIndex })- await updateStackProperty(e.moved.newIndex, { order: e.moved.oldIndex })+ const redoStackMeta = [...groupingFieldColOptions.value]+ redoStackMeta[e.moved.oldIndex] = { ...redoStackMeta[e.moved.oldIndex], order: e.moved.newIndex }+ redoStackMeta[e.moved.newIndex] = { ...redoStackMeta[e.moved.newIndex], order: e.moved.oldIndex }++ const redoStackMetaObj = {+ ...stackMetaObj.value,+ [kanbanMetaData.value.fk_grp_col_id!]: redoStackMeta,+ }++ await updateKanbanMeta({ meta: redoStackMetaObj })},args: [{ moved: { oldIndex, newIndex } }],},@@ -377,40 +409,27 @@ watch(contextMenu, () => {}})-watch(- view,- async (nextView) => {- if (nextView?.type === ViewTypes.KANBAN) {- isViewDataLoading.value = true-- try {- isViewDataLoading.value = false-- // load kanban data- await loadKanbanData()-- // horizontally scroll to the end of the kanban container- // when a new option is added within kanban view- nextTick(() => {- if (shouldScrollToRight.value && kanbanContainerRef.value) {- kanbanContainerRef.value.scrollTo({- left: kanbanContainerRef.value.scrollWidth,- behavior: 'smooth',- })- // reset shouldScrollToRight- shouldScrollToRight.value = false- }+onMounted(async () => {+ try {+ isViewDataLoading.value = true+ await loadKanbanData()++ nextTick(() => {+ if (shouldScrollToRight.value && kanbanContainerRef.value) {+ kanbanContainerRef.value.scrollTo({+ left: kanbanContainerRef.value.scrollWidth,+ behavior: 'smooth',})- } catch (error) {- console.error(error)- isViewDataLoading.value = false+ // reset shouldScrollToRight+ shouldScrollToRight.value = false}- }- },- {- immediate: true,- },-)+ })+ isViewDataLoading.value = false+ } catch (error) {+ console.error(error)+ isViewDataLoading.value = false+ }+})const getRowId = (row: RowType) => {const pk = extractPkFromRow(row.row, meta.value!.columns!)diff --git a/packages/nc-gui/composables/useKanbanViewStore.ts b/packages/nc-gui/composables/useKanbanViewStore.tsindex e95351395d..388a4a74ae 100644--- a/packages/nc-gui/composables/useKanbanViewStore.ts+++ b/packages/nc-gui/composables/useKanbanViewStore.ts@@ -346,14 +346,10 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState(}async function updateKanbanMeta(updateObj: Partial<KanbanType>) {- if (- !viewMeta?.value?.id ||- !isUIAllowed('viewCreateOrEdit', {- skipSourceCheck: true,- })- )- return- await updateViewMeta(viewMeta.value.id, ViewTypes.KANBAN, updateObj)+ if (!viewMeta?.value?.id) return+ await updateViewMeta(viewMeta.value.id, ViewTypes.KANBAN, updateObj, {+ skipNetworkCall: isPublic.value || !isUIAllowed('viewCreateOrEdit', { skipSourceCheck: true }),+ })}const updateStackProperty = async (stackIdx: number, updates: Partial<GroupingFieldColOptionsType>) => {@@ -974,6 +970,7 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState(removeRowFromUncategorizedStack,shouldScrollToRight,deleteRow,+ stackMetaObj,moveHistory,addNewStackId,updateStackProperty,diff --git a/packages/nc-gui/store/views.ts b/packages/nc-gui/store/views.tsindex 9d94d1d6d5..ab5ea63ec7 100644--- a/packages/nc-gui/store/views.ts+++ b/packages/nc-gui/store/views.ts@@ -499,31 +499,46 @@ export const useViewsStore = defineStore('viewsStore', () => {}}- const updateViewMeta = async (viewId: string, viewType: ViewTypes, updates: Record<string, any>): Promise<ViewType | null> => {+ const updateViewMeta = async (+ viewId: string,+ viewType: ViewTypes,+ updates: Record<string, any>,+ { skipNetworkCall = false },+ ): Promise<ViewType | null> => {try {- let updatedView: ViewType-- switch (viewType) {- case ViewTypes.GRID:- updatedView = await $api.dbView.gridUpdate(viewId, updates)- break- case ViewTypes.GALLERY:- updatedView = await $api.dbView.galleryUpdate(viewId, updates)- break- case ViewTypes.KANBAN:- updatedView = await $api.dbView.kanbanUpdate(viewId, updates)- break- case ViewTypes.MAP:- updatedView = await $api.dbView.mapUpdate(viewId, updates)- break- case ViewTypes.CALENDAR:- updatedView = await $api.dbView.calendarUpdate(viewId, updates)- break- case ViewTypes.FORM:- updatedView = await $api.dbView.formUpdate(viewId, updates)- break- default:- throw new Error(`Unsupported view type for meta update: ${viewType}`)+ let updatedView++ if (!skipNetworkCall) {+ switch (viewType) {+ case ViewTypes.GRID:+ updatedView = await $api.dbView.gridUpdate(viewId, updates)+ break+ case ViewTypes.GALLERY:+ updatedView = await $api.dbView.galleryUpdate(viewId, updates)+ break+ case ViewTypes.KANBAN:+ updatedView = await $api.dbView.kanbanUpdate(viewId, updates)+ break+ case ViewTypes.MAP:+ updatedView = await $api.dbView.mapUpdate(viewId, updates)+ break+ case ViewTypes.CALENDAR:+ updatedView = await $api.dbView.calendarUpdate(viewId, updates)+ break+ case ViewTypes.FORM:+ updatedView = await $api.dbView.formUpdate(viewId, updates)+ break+ default:+ throw new Error(`Unsupported view type for meta update: ${viewType}`)+ }+ } else {+ updatedView = {+ ...activeView.value,+ view: {+ ...(activeView.value || {}).view,+ ...updates,+ },+ }}// Find the table and update the view in the store@@ -538,6 +553,16 @@ export const useViewsStore = defineStore('viewsStore', () => {}}+ if (isPublic.value) {+ sharedView.value = {+ ...sharedView.value,+ view: {+ ...(sharedView.value?.view || {}),+ ...updates,+ },+ }+ }+refreshCommandPalette()return updatedView