Browse Source

fix(nc-gui): rollup followup items (#9017)

pull/9028/head
Ramesh Mane 4 months ago committed by GitHub
parent
commit
1918a4588a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      packages/nc-gui/components/virtual-cell/Rollup.vue
  2. 52
      packages/nocodb-sdk/src/lib/helperFunctions.ts

11
packages/nc-gui/components/virtual-cell/Rollup.vue

@ -1,4 +1,5 @@
<script setup lang="ts">
import { UITypes, getRenderAsTextFunForUiType } from 'nocodb-sdk'
import type { ColumnType, LinkToAnotherRecordType, RollupType } from 'nocodb-sdk'
const { metas } = useMetas()
@ -37,15 +38,15 @@ const childColumn = computed(() => {
}
return ''
})
const renderAsTextFun = computed(() => {
return getRenderAsTextFunForUiType(childColumn.value?.uidt || UITypes.SingleLineText)
})
</script>
<template>
<div class="nc-cell-field" @dblclick="activateShowEditNonEditableFieldWarning">
<div
v-if="
['count', 'avg', 'sum', 'min', 'max', 'countDistinct', 'sumDistinct', 'avgDistinct'].includes(colOptions.rollup_function)
"
>
<div v-if="renderAsTextFun.includes(colOptions.rollup_function)">
{{ value }}
</div>
<LazySmartsheetCell v-else v-model="value" :column="childColumn" :edit-enabled="false" :read-only="true" />

52
packages/nocodb-sdk/src/lib/helperFunctions.ts

@ -59,7 +59,16 @@ const stringifyRolesObj = (roles?: RolesObj | null): string => {
};
const getAvailableRollupForUiType = (type: string) => {
if ([UITypes.Year].includes(type as UITypes)) {
if (
[
UITypes.Year,
UITypes.Time,
UITypes.Date,
UITypes.DateTime,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
].includes(type as UITypes)
) {
return ['count', 'min', 'max', 'countDistinct'];
}
if (isNumericCol(type as UITypes)) {
@ -75,16 +84,7 @@ const getAvailableRollupForUiType = (type: string) => {
'avgDistinct',
];
}
if (
[
UITypes.Date,
UITypes.DateTime,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
].includes(type as UITypes)
) {
return ['count', 'min', 'max', 'countDistinct'];
}
if (
[
UITypes.SingleLineText,
@ -119,6 +119,35 @@ const getAvailableRollupForUiType = (type: string) => {
];
};
const getRenderAsTextFunForUiType = (type: UITypes) => {
if (
[
UITypes.Year,
UITypes.Time,
UITypes.Date,
UITypes.DateTime,
UITypes.CreatedTime,
UITypes.LastModifiedTime,
UITypes.Decimal,
UITypes.Currency,
UITypes.Duration,
].includes(type)
) {
return ['count', 'countDistinct'];
}
return [
'sum',
'count',
'avg',
'min',
'max',
'countDistinct',
'sumDistinct',
'avgDistinct',
];
};
const getFileName = ({ name, count, ext }) =>
`${name}${count ? `(${count})` : ''}${ext ? `${ext}` : ''}`;
@ -170,6 +199,7 @@ export {
extractRolesObj,
stringifyRolesObj,
getAvailableRollupForUiType,
getRenderAsTextFunForUiType,
populateUniqueFileName,
roundUpToPrecision,
};

Loading…
Cancel
Save