11/* eslint-disable no-underscore-dangle */
2- import { BaseProperty , PropertyType } from 'admin-bro'
3- import { ModelAttributeColumnOptions } from 'sequelize/types'
2+ import { BaseProperty , PropertyType } from 'admin-bro' ;
3+ import { ModelAttributeColumnOptions } from 'sequelize/types' ;
44
55const TYPES_MAPPING = [
66 [ 'STRING' , 'string' ] ,
@@ -25,99 +25,98 @@ const TYPES_MAPPING = [
2525 [ 'RANGE' , 'string' ] ,
2626 [ 'GEOMETRY' , 'string' ] ,
2727 [ 'BOOLEAN' , 'boolean' ] ,
28- ]
28+ ] ;
2929
3030class Property extends BaseProperty {
3131 private sequelizePath : ModelAttributeColumnOptions
3232
3333 private fieldName : string
3434
3535 constructor ( sequelizePath : ModelAttributeColumnOptions ) {
36- const { fieldName } = sequelizePath as any
37- super ( { path : fieldName } )
38- this . fieldName = fieldName
39- this . sequelizePath = sequelizePath
36+ const { fieldName } = sequelizePath as any ;
37+ super ( { path : fieldName } ) ;
38+ this . fieldName = fieldName ;
39+ this . sequelizePath = sequelizePath ;
4040 }
4141
4242 name ( ) : string {
43- return this . fieldName
43+ return this . fieldName ;
4444 }
4545
4646 isEditable ( ) : boolean {
4747 if ( ( this . sequelizePath as any ) . _autoGenerated ) {
48- return false
48+ return false ;
4949 }
5050 if ( this . sequelizePath . autoIncrement ) {
51- return false
51+ return false ;
5252 }
5353 if ( this . isId ( ) ) {
54- return false
54+ return false ;
5555 }
56- return true
56+ return true ;
5757 }
5858
5959 isVisible ( ) : boolean {
6060 // fields containing password are hidden by default
61- return ! this . name ( ) . match ( 'password' )
61+ return ! this . name ( ) . match ( 'password' ) ;
6262 }
6363
6464 isId ( ) : boolean {
65- return ! ! this . sequelizePath . primaryKey
65+ return ! ! this . sequelizePath . primaryKey ;
6666 }
6767
6868 reference ( ) : string | null {
6969 if ( this . isArray ( ) ) {
70- return null
70+ return null ;
7171 }
7272
7373 if ( this . sequelizePath . references === 'string' ) {
74- return this . sequelizePath . references as string
74+ return this . sequelizePath . references as string ;
7575 } if ( this . sequelizePath . references && typeof this . sequelizePath . references !== 'string' ) {
76- return this . sequelizePath . references ?. model as string
76+ return this . sequelizePath . references ?. model as string ;
7777 }
78- return null
78+ return null ;
7979 }
8080
8181 availableValues ( ) : Array < string > | null {
8282 return this . sequelizePath . values && this . sequelizePath . values . length
8383 ? this . sequelizePath . values as Array < string >
84- : null
84+ : null ;
8585 }
8686
8787 isArray ( ) : boolean {
88- return this . sequelizePath . type . constructor . name === 'ARRAY'
88+ return this . sequelizePath . type . constructor . name === 'ARRAY' ;
8989 }
9090
9191 /**
9292 * @returns {PropertyType }
9393 */
9494 type ( ) : PropertyType {
95- let sequelizeType = this . sequelizePath . type
95+ let sequelizeType = this . sequelizePath . type ;
9696
9797 if ( this . isArray ( ) ) {
98- sequelizeType = ( sequelizeType as any ) . type
98+ sequelizeType = ( sequelizeType as any ) . type ;
9999 }
100100
101101 const key = TYPES_MAPPING . find ( ( element ) => (
102102 sequelizeType . constructor . name === element [ 0 ]
103- ) )
103+ ) ) ;
104104
105105 if ( this . reference ( ) ) {
106- return 'reference' as PropertyType
106+ return 'reference' as PropertyType ;
107107 }
108108
109- const type = key && key [ 1 ]
110- return ( type || 'string' ) as PropertyType
109+ const type = key && key [ 1 ] ;
110+ return ( type || 'string' ) as PropertyType ;
111111 }
112112
113113 isSortable ( ) : boolean {
114- return this . type ( ) !== 'mixed' && ! this . isArray ( )
114+ return this . type ( ) !== 'mixed' && ! this . isArray ( ) ;
115115 }
116116
117117 isRequired ( ) : boolean {
118- return ! ( typeof this . sequelizePath . allowNull === 'undefined'
119- || this . sequelizePath . allowNull === true )
118+ return ! ( typeof this . sequelizePath . allowNull === 'undefined' || this . sequelizePath . allowNull ) ;
120119 }
121120}
122121
123- export default Property
122+ export default Property ;
0 commit comments