@ -1481,8 +1481,8 @@ export default class NcMetaMgr {
result = await this . xcVisibilityMetaSetAll ( args ) ;
break ;
case 'table List' :
result = await this . xcTableList ( req , args ) ;
case 'xcTableAndView List' :
result = await this . xcTableAndView List ( req , args ) ;
break ;
case 'columnList' :
@ -4819,13 +4819,13 @@ export default class NcMetaMgr {
xcCondition : {
_or : [
{
type : 'table'
type : { eq : 'table' }
} ,
{
type : 'view'
type : { eq : 'view' }
} ,
{
type : 'vtable'
type : { eq : 'vtable' }
}
]
}
@ -4839,7 +4839,8 @@ export default class NcMetaMgr {
order : table.order ,
disabled : { . . . defaultDisabled } ,
type : table . type ,
show_as : table.show_as
show_as : table.show_as ,
ptn : table.parent_model_title
} ;
return obj ;
} , { } ) ;
@ -4852,13 +4853,13 @@ export default class NcMetaMgr {
xcCondition : {
_or : [
{
type : 'table'
type : { eq : 'table' }
} ,
{
type : 'view'
type : { eq : 'view' }
} ,
{
type : 'vtable'
type : { eq : 'vtable' }
}
]
}
@ -4876,6 +4877,70 @@ export default class NcMetaMgr {
) ;
}
break ;
case 'table_view' :
{
const models = await this . xcMeta . metaList (
this . getProjectId ( args ) ,
this . getDbAlias ( args ) ,
'nc_models' ,
{
condition : {
. . . ( args ? . args ? . includeM2M ? { } : { mm : null } )
} ,
xcCondition : {
_or : [
{
type : { eq : 'table' }
} ,
{
type : { eq : 'view' }
}
]
} ,
orderBy : {
order : 'asc'
}
}
) ;
const result = models . reduce ( ( obj , table ) = > {
obj [ table . title ] = {
tn : table.title ,
_tn : table.alias || table . title ,
order : table.order ,
disabled : { . . . defaultDisabled } ,
type : table . type ,
show_as : table.show_as ,
ptn : table.parent_model_title
} ;
return obj ;
} , { } ) ;
const disabledList = await this . xcMeta . metaList (
args . project_id ,
this . getDbAlias ( args ) ,
'nc_disabled_models_for_role' ,
{
xcCondition : {
_or : [
{
type : { eq : 'table' }
} ,
{
type : { eq : 'view' }
}
]
}
}
) ;
for ( const d of disabledList ) {
result [ d . title ] . disabled [ d . role ] = ! ! d . disabled ;
}
return Object . values ( result ) ;
}
break ;
}
} catch ( e ) {
throw e ;
@ -5230,6 +5295,23 @@ export default class NcMetaMgr {
} ;
}
protected async xcTableAndViewList ( req , args ) : Promise < any > {
const roles = req . session ? . passport ? . user ? . roles ;
let tables = await this . xcVisibilityMetaGet ( {
. . . args ,
args : { type : 'table_view' , . . . args . args }
} ) ;
tables = tables . filter ( ( table : any ) = > {
return Object . keys ( roles ) . some (
role = > roles [ role ] && ! table . disabled [ role ]
) ;
} ) ;
return { data : { list : tables } } ;
}
protected async xcVirtualTableList ( args , req ) : Promise < any > {
const roles = ( await this . xcMeta . metaList ( '' , '' , 'nc_roles' ) )
. map ( r = > r . title )