@ -56,13 +56,16 @@ const refTables = computed(() => {
const _refTables = meta . value . columns
const _refTables = meta . value . columns
. filter (
. filter (
( c ) =>
( c : ColumnType ) =>
isLinksOrLTAR ( c ) &&
isLinksOrLTAR ( c ) &&
! [ RelationTypes . BELONGS _TO , RelationTypes . ONE _TO _ONE ] . includes ( ( c . colOptions as LinkToAnotherRecordType ) . type ) &&
( c . colOptions as LinkToAnotherRecordType ) . type &&
! [ RelationTypes . BELONGS _TO , RelationTypes . ONE _TO _ONE ] . includes (
( c . colOptions as LinkToAnotherRecordType ) . type as RelationTypes ,
) &&
! c . system &&
! c . system &&
c . source _id === meta . value ? . source _id ,
c . source _id === meta . value ? . source _id ,
)
)
. map ( ( c ) => ( {
. map ( ( c : ColumnType ) => ( {
col : c . colOptions ,
col : c . colOptions ,
column : c ,
column : c ,
... tables . value . find ( ( t ) => t . id === ( c . colOptions as any ) ? . fk _related _model _id ) ,
... tables . value . find ( ( t ) => t . id === ( c . colOptions as any ) ? . fk _related _model _id ) ,
@ -118,16 +121,29 @@ const allFunctions = [
{ text : t ( 'general.avgDistinct' ) , value : 'avgDistinct' } ,
{ text : t ( 'general.avgDistinct' ) , value : 'avgDistinct' } ,
]
]
const availableRollupPerColumn = computed ( ( ) => {
const fnMap : Record < string , { text : string ; value : string } [ ] > = { }
columns . value ? . forEach ( ( column ) => {
if ( ! column ? . id ) return
fnMap [ column . id ] = allFunctions . filter ( ( func ) => getAvailableRollupForUiType ( column . uidt as UITypes ) . includes ( func . value ) )
} )
return fnMap
} )
const filteredColumns = computed ( ( ) => {
return columns . value ? . filter ( ( column ) => {
return column . id && availableRollupPerColumn . value [ column . id as string ] ? . length
} )
} )
watch (
watch (
( ) => vModel . value . fk _rollup _column _id ,
( ) => vModel . value . fk _rollup _column _id ,
( ) => {
( ) => {
const childFieldColumn = columns . value ? . find ( ( column : ColumnType ) => column . id === vModel . value . fk _rollup _column _id )
const childFieldColumn = columns . value ? . find ( ( column : ColumnType ) => column . id === vModel . value . fk _rollup _column _id )
aggFunctionsList . value = allFunctions . filter ( ( func ) =>
aggFunctionsList . value = availableRollupPerColumn . value [ childFieldColumn ? . id as string ] || [ ]
getAvailableRollupForUiType ( childFieldColumn ? . uidt as UITypes ) . includes ( func . value ) ,
)
if ( ! aggFunctionsList . value . includes ( vModel . value . rollup _function ) ) {
if ( aggFunctionsList . value . length && ! aggFunctionsList . value . find ( ( func ) => func . value === vModel . value . rollup _function ) ) {
/ / w h e n t h e p r e v i o u s r o l l u p f u n c t i o n w a s n u m e r i c t y p e a n d t h e c u r r e n t c h i l d f i e l d i s n o n - n u m e r i c
/ / w h e n t h e p r e v i o u s r o l l u p f u n c t i o n w a s n u m e r i c t y p e a n d t h e c u r r e n t c h i l d f i e l d i s n o n - n u m e r i c
/ / r e s e t r o l l u p f u n c t i o n w i t h a n o n - n u m e r i c t y p e
/ / r e s e t r o l l u p f u n c t i o n w i t h a n o n - n u m e r i c t y p e
vModel . value . rollup _function = aggFunctionsList . value [ 0 ] . value
vModel . value . rollup _function = aggFunctionsList . value [ 0 ] . value
@ -176,7 +192,7 @@ watch(
dropdown - class - name = "nc-dropdown-relation-column !rounded-xl"
dropdown - class - name = "nc-dropdown-relation-column !rounded-xl"
@ change = "onDataTypeChange"
@ change = "onDataTypeChange"
>
>
< a -select -option v-for ="(column, index) of c olumns" :key="index" :value="column.id" >
< a -select -option v-for ="(column, index) of filteredC olumns" :key="index" :value="column.id" >
< div class = "flex gap-2 truncate items-center" >
< div class = "flex gap-2 truncate items-center" >
< div class = "flex items-center flex-1 truncate font-semibold" >
< div class = "flex items-center flex-1 truncate font-semibold" >
< component :is ="cellIcon(column)" :column-meta ="column" / >
< component :is ="cellIcon(column)" :column-meta ="column" / >