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 11 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 // 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 // in these 2 scenario it will return json array or `___` separated value
const parseKey = (group) => { 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 // 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) { if ((key && group.column?.uidt === UITypes.Lookup) || group.column?.uidt === UITypes.LinkToAnotherRecord) {
try { try {
const parsedKey = JSON.parse(key) key = JSON.parse(key)
return parsedKey
} catch { } catch {
// if parsing try to split it by `___` (for sqlite) // if parsing try to split it by `___` (for sqlite)
return key.split('___') return key.split('___')

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

@ -1,4 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { UITypes, isLinksOrLTAR } from 'nocodb-sdk'
import { RollupColumn } from '../../../../nocodb/src/models'
import Table from './Table.vue' import Table from './Table.vue'
import { IsGroupByInj, computed, ref } from '#imports' import { IsGroupByInj, computed, ref } from '#imports'
import type { Group, Row } from '#imports' import type { Group, Row } from '#imports'
@ -43,7 +45,14 @@ function addEmptyRow(group: Group, addAfter?: number) {
addAfter = addAfter ?? group.rows.length addAfter = addAfter ?? group.rows.length
const setGroup = group.nestedIn.reduce((acc, curr) => { 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 return acc
}, {} as Record<string, any>) }, {} as Record<string, any>)

Loading…
Cancel
Save