Browse Source

Merge pull request #7208 from nocodb/fix/7204-group-by-add-new-row

fix: Avoid setting default value(LTAR/Links) when adding new row in grouped by table
pull/7222/head
mertmit 9 months ago committed by GitHub
parent
commit
417fd432e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      packages/nc-gui/components/smartsheet/grid/GroupBy.vue
  2. 11
      packages/nc-gui/components/smartsheet/grid/GroupByTable.vue

5
packages/nc-gui/components/smartsheet/grid/GroupBy.vue

@ -140,13 +140,12 @@ const onScroll = (e: Event) => {
// a method to parse group key if grouped column type is LTAR or Lookup
// in these 2 scenario it will return json array or `___` separated value
const parseKey = (group) => {
const key = group.key.toString()
let key = group.key.toString()
// parse json array key if it's a lookup or link to another record
if ((key && group.column?.uidt === UITypes.Lookup) || group.column?.uidt === UITypes.LinkToAnotherRecord) {
try {
const parsedKey = JSON.parse(key)
return parsedKey
key = JSON.parse(key)
} catch {
// if parsing try to split it by `___` (for sqlite)
return key.split('___')

11
packages/nc-gui/components/smartsheet/grid/GroupByTable.vue

@ -1,4 +1,6 @@
<script lang="ts" setup>
import { UITypes, isLinksOrLTAR } from 'nocodb-sdk'
import { RollupColumn } from '../../../../nocodb/src/models'
import Table from './Table.vue'
import { IsGroupByInj, computed, ref } from '#imports'
import type { Group, Row } from '#imports'
@ -43,7 +45,14 @@ function addEmptyRow(group: Group, addAfter?: number) {
addAfter = addAfter ?? group.rows.length
const setGroup = group.nestedIn.reduce((acc, curr) => {
if (curr.key !== '__nc_null__') acc[curr.title] = curr.key
if (
curr.key !== '__nc_null__' &&
// avoid setting default value for rollup, formula, barcode, qrcode, links, ltar
!isLinksOrLTAR(curr.column_uidt) &&
![UITypes.Rollup, UITypes.Lookup, UITypes.Formula, UITypes.Barcode, UITypes.QrCode].includes(curr.column_uidt)
) {
acc[curr.title] = curr.key
}
return acc
}, {} as Record<string, any>)

Loading…
Cancel
Save