@ -1,13 +1,18 @@
import { Injectable } from '@nestjs/common' ;
import { Injectable } from '@nestjs/common' ;
import {
import {
isCreatedOrLastModifiedByCol ,
isCreatedOrLastModifiedByCol ,
isLinksOrLTAR ,
RelationTypes ,
RelationTypes ,
UITypes ,
UITypes ,
ViewTypes ,
} from 'nocodb-sdk' ;
} from 'nocodb-sdk' ;
import { isLinksOrLTAR } from 'nocodb-sdk' ;
import type {
import type { LinkToAnotherRecordColumn , LookupColumn } from '~/models' ;
CalendarView ,
import { NcError } from '~/helpers/catchError' ;
LinkToAnotherRecordColumn ,
LookupColumn ,
} from '~/models' ;
import { Base , BaseUser , Column , Model , Source , View } from '~/models' ;
import { Base , BaseUser , Column , Model , Source , View } from '~/models' ;
import { NcError } from '~/helpers/catchError' ;
@Injectable ( )
@Injectable ( )
export class PublicMetasService {
export class PublicMetasService {
@ -36,12 +41,28 @@ export class PublicMetasService {
view . client = source . type ;
view . client = source . type ;
// todo: return only required props
// todo: return only required props
delete view [ 'password' ] ;
view . password = undefined ;
// Required for Calendar Views
const rangeColumns = [ ] ;
if ( view . type === ViewTypes . CALENDAR ) {
for ( const c of ( view . view as CalendarView ) . calendar_range ) {
if ( c . fk_from_column_id ) {
rangeColumns . push ( c . fk_from_column_id ) ;
} else if ( ( c as any ) . fk_to_column_id ) {
rangeColumns . push ( ( c as any ) . fk_to_column_id ) ;
}
}
}
view . model . columns = view . columns
view . model . columns = view . columns
. filter ( ( c ) = > {
. filter ( ( c ) = > {
const column = view . model . columnsById [ c . fk_column_id ] ;
const column = view . model . columnsById [ c . fk_column_id ] ;
if ( rangeColumns . includes ( c . fk_column_id ) ) {
return true ;
}
// Check if column exists to prevent processing non-existent columns
// Check if column exists to prevent processing non-existent columns
if ( ! column ) return false ;
if ( ! column ) return false ;