Browse Source

fix(gui): only overwrite Rollup and Formula cell on row update

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4221/head
Pranav C 2 years ago
parent
commit
2f259a08b8
  1. 16
      packages/nc-gui/composables/useViewData.ts

16
packages/nc-gui/composables/useViewData.ts

@ -1,4 +1,4 @@
import { ViewTypes, isVirtualCol } from 'nocodb-sdk'
import { ViewTypes, isVirtualCol, UITypes } from 'nocodb-sdk'
import type { Api, ColumnType, FormType, GalleryType, PaginatedType, TableType, ViewType } from 'nocodb-sdk'
import type { ComputedRef, Ref } from 'vue'
import {
@ -203,7 +203,10 @@ export function useViewData(
async function insertRow(
currentRow: Row,
ltarState: Record<string, any> = {},
{ metaValue = meta.value, viewMetaValue = viewMeta.value }: { metaValue?: TableType; viewMetaValue?: ViewType } = {},
{
metaValue = meta.value,
viewMetaValue = viewMeta.value,
}: { metaValue?: TableType; viewMetaValue?: ViewType } = {},
) {
const row = currentRow.row
if (currentRow.rowMeta) currentRow.rowMeta.saving = true
@ -243,7 +246,10 @@ export function useViewData(
async function updateRowProperty(
toUpdate: Row,
property: string,
{ metaValue = meta.value, viewMetaValue = viewMeta.value }: { metaValue?: TableType; viewMetaValue?: ViewType } = {},
{
metaValue = meta.value,
viewMetaValue = viewMeta.value,
}: { metaValue?: TableType; viewMetaValue?: ViewType } = {},
) {
if (toUpdate.rowMeta) toUpdate.rowMeta.saving = true
try {
@ -278,7 +284,7 @@ export function useViewData(
Object.assign(
toUpdate.row,
metaValue!.columns!.reduce<Record<string, any>>((acc: Record<string, any>, col: ColumnType) => {
if (isVirtualCol(col)) acc[col.title!] = updatedRowData[col.title!]
if (col.uidt === UITypes.Formula || col.uidt === UITypes.Rollup) acc[col.title!] = updatedRowData[col.title!]
return acc
}, {} as Record<string, any>),
)
@ -317,7 +323,7 @@ export function useViewData(
async function deleteRowById(id: string) {
if (!id) {
throw new Error("Delete not allowed for table which doesn't have primary Key")
throw new Error('Delete not allowed for table which doesn\'t have primary Key')
}
const res: any = await $api.dbViewRow.delete(

Loading…
Cancel
Save