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