@ -24,24 +24,13 @@ export class Connection extends BI.Widget {
title : HTapeLayout ;
watch = {
connectionSelected : ( name : string ) = > {
if ( name ) {
const canEdit = connectionCanEdit ( this . model . connectionSelectedOne ) ;
const type = this . getSelectConnectionType ( ) ;
this . connectionTitleWidget . setText ( ` ${ name } ( ${ getTextByDatabaseType ( type ) } ) ` ) ;
this . connectionEditWidget . setVisible ( canEdit ) ;
const hasRegistered = this . hasRegistered ( ) ;
this . title . setVisible ( hasRegistered ) ;
if ( ! hasRegistered ) {
this . listView . populate ( BI . createItems ( this . renderNoRegistered ( ) ) ) ;
} else {
this . listView . populate ( BI . createItems ( this . renderItems ( ) ) ) ;
}
} else {
this . listView . populate ( BI . createItems ( this . renderEmpty ( ) ) ) ;
this . connectionTitleWidget . setText ( '' ) ;
this . connectionEditWidget . setVisible ( false ) ;
}
connectionSelected : {
immediate : true ,
handler : ( name : string ) = > {
BI . nextTick ( ( ) = > {
name ? this . renderConnectionListView ( name ) : this . renderEmptyListView ( ) ;
} ) ;
} ,
} ,
} ;
@ -50,8 +39,6 @@ export class Connection extends BI.Widget {
}
render() {
this . store . setConnectionSelected ( '' ) ;
return {
type : BI . HTapeLayout . xtype ,
hgap : 10 ,
@ -214,12 +201,6 @@ export class Connection extends BI.Widget {
} ] ;
}
private renderEmpty() {
return [ {
type : BI . Layout . xtype ,
} ] ;
}
private hasRegistered() {
const allDatabaseTypes = getAllDatabaseTypes ( ) ;
switch ( this . model . connectionSelectedOne . connectionType ) {
@ -246,4 +227,32 @@ export class Connection extends BI.Widget {
this . store . setPageIndex ( PAGE_INDEX . MAINTAIN ) ;
this . store . setDatebaseTypeSelected ( '' ) ;
}
private renderConnectionListView ( name : string ) {
const canEdit = connectionCanEdit ( this . model . connectionSelectedOne ) ,
type = this . getSelectConnectionType ( ) ,
hasRegistered = this . hasRegistered ( ) ;
this . connectionTitleWidget . setText ( ` ${ name } ( ${ getTextByDatabaseType ( type ) } ) ` ) ;
this . connectionEditWidget . setVisible ( canEdit ) ;
this . title . setVisible ( hasRegistered ) ;
hasRegistered
? this . listView . populate ( BI . createItems ( this . renderItems ( ) ) )
: this . listView . populate ( BI . createItems ( this . renderNoRegistered ( ) ) ) ;
}
private renderEmptyListView() {
this . listView . populate (
BI . createItems ( [
{
type : BI . Layout . xtype ,
}
] )
) ;
this . connectionTitleWidget . setText ( '' ) ;
this . connectionEditWidget . setVisible ( false ) ;
}
}