4
4
5
5
import React , { Component , PropTypes } from 'react' ;
6
6
import sCompare from 'react-addons-shallow-compare' ;
7
- import { isEmpty , get , merge } from 'lodash' ;
7
+ import { isEmpty , get , merge , isNil , isArray , cloneDeep , set , has } from 'lodash' ;
8
8
import FieldGroupUtils from '../../fieldGroup/FieldGroupUtils.js' ;
9
- import { fieldGroupConnector } from '../../ui/FieldGroupConnector.jsx' ;
10
- import { doFetchTable , getColumnIdx , getTblById } from '../../tables/TableUtil.js' ;
9
+ import { dispatchValueChange } from '../../fieldGroup/FieldGroupCntlr.js' ;
10
+ import { fetchTable } from '../../rpc/SearchServicesJson.js' ;
11
+ import { getColumnIdx , getTblById } from '../../tables/TableUtil.js' ;
11
12
import { BasicTableView } from '../../tables/ui/BasicTableView.jsx' ;
12
- import { ListBoxInputField } from '../../ui/ListBoxInputField.jsx' ;
13
- import { InputAreaFieldConnected } from '../../ui/InputAreaField.jsx' ;
14
13
import { createLinkCell , createInputCell } from '../../tables/ui/TableRenderer.js' ;
15
14
import * as TblCntlr from '../../tables/TablesCntlr.js' ;
16
15
import * as TblUtil from '../../tables/TableUtil.js' ;
17
16
import { SelectInfo } from '../../tables/SelectInfo.js' ;
18
17
import { FilterInfo , FILTER_TTIPS } from '../../tables/FilterInfo.js' ;
19
- import { isNil , isArray , cloneDeep , set } from 'lodash' ;
20
- import { dispatchValueChange } from '../../fieldGroup/FieldGroupCntlr.js' ;
18
+ import { ListBoxInputField } from '../../ui/ListBoxInputField.jsx' ;
19
+ import { InputAreaFieldConnected } from '../../ui/InputAreaField.jsx' ;
20
+ import { fieldGroupConnector } from '../../ui/FieldGroupConnector.jsx' ;
21
21
import { LSSTDDPID } from './LSSTCatalogSelectViewPanel.jsx' ;
22
22
const sqlConstraintsCol = { name : 'constraints' , idx : 1 , type : 'char' , width : 10 } ;
23
23
@@ -37,6 +37,7 @@ function getTblId(catName, dd_short) {
37
37
/**
38
38
* @summary reest table constraints state
39
39
* @param {string } gkey
40
+ * @param {string } fieldKey
40
41
*/
41
42
function resetConstraints ( gkey , fieldKey ) {
42
43
const value = { constraints : '' , selcols : '' , filters : { } , errorConstraints :'' } ;
@@ -86,6 +87,7 @@ export class CatalogConstraintsPanel extends React.Component {
86
87
87
88
render ( ) {
88
89
const { tableModel} = this . state ;
90
+ const { error} = tableModel || { } ;
89
91
const { catname, dd_short, fieldKey, showFormType= true , createDDRequest, groupKey} = this . props ;
90
92
91
93
var resetButton = ( ) => {
@@ -126,12 +128,12 @@ export class CatalogConstraintsPanel extends React.Component {
126
128
margin :'0px 10px 5px 5px' , padding :'0 0 0 10px' ,
127
129
border :'1px solid #a3aeb9' } } >
128
130
< div style = { { display :'flex' , flexDirection :'row' , padding :'5px 5px 0' } } >
129
- { showFormType && formTypeList ( ) }
130
- { resetButton ( ) }
131
+ { ! error && showFormType && formTypeList ( ) }
132
+ { ! error && resetButton ( ) }
131
133
</ div >
132
134
< div >
133
135
< TablePanelConnected { ...{ tableModel, fieldKey} } />
134
- { renderSqlArea ( ) }
136
+ { ! error && renderSqlArea ( ) }
135
137
</ div >
136
138
</ div >
137
139
</ div >
@@ -165,8 +167,7 @@ export class CatalogConstraintsPanel extends React.Component {
165
167
const request = createDDRequest ( ) ; //Fetch DD master table
166
168
const urlDef = get ( FieldGroupUtils . getGroupFields ( this . props . groupKey ) , 'cattable.coldef' , 'null' ) ;
167
169
168
-
169
- doFetchTable ( request ) . then ( ( tableModel ) => {
170
+ fetchTable ( request ) . then ( ( tableModel ) => {
170
171
const tableModelFetched = tableModel ;
171
172
tableModelFetched . tbl_id = tblid ;
172
173
addConstraintColumn ( tableModelFetched , this . props . groupKey ) ;
@@ -180,7 +181,11 @@ export class CatalogConstraintsPanel extends React.Component {
180
181
TblCntlr . dispatchTableReplace ( tableModel ) ;
181
182
this . setState ( { tableModel : tableModelFetched } ) ;
182
183
} ) . catch ( ( reason ) => {
183
- console . error ( reason ) ;
184
+ console . log ( reason . message ) ;
185
+ const errTable = TblUtil . createErrorTbl ( tblid , `Catalog Fetch Error: ${ reason . message } ` ) ;
186
+
187
+ TblCntlr . dispatchTableReplace ( errTable ) ;
188
+ this . setState ( { tableModel : errTable } ) ;
184
189
}
185
190
) ;
186
191
}
@@ -359,8 +364,9 @@ class ConstraintPanel extends Component {
359
364
const { tableModel, onTableChanged} = this . props ;
360
365
const tbl_ui_id = tableModel . tbl_id + '-ui' ;
361
366
const tbl = getTblById ( tableModel . tbl_id ) ;
362
- const { columns, data} = get ( tbl , 'tableData' ) ;
363
- const selectInfoCls = SelectInfo . newInstance ( tbl . selectInfo , 0 ) ;
367
+ const { columns, data} = get ( tbl , 'tableData' , { } ) ;
368
+ const selectInfoCls = has ( tbl , 'selectInfo' ) && SelectInfo . newInstance ( tbl . selectInfo , 0 ) ;
369
+ const totalCol = columns ? ( columns . length - 1 ) : 0 ;
364
370
365
371
//const {tableconstraints} = FieldGroupUtils.getGroupFields(groupKey);
366
372
//console.log('constraint: ' + tableconstraints.value.constraints + ' errorConstraints: ' + tableconstraints.value.errorConstraints);
@@ -383,6 +389,7 @@ class ConstraintPanel extends Component {
383
389
currentPage = { 1 }
384
390
hlRowIdx = { 0 }
385
391
key = { tableModel . tbl_id }
392
+ error = { tableModel . error }
386
393
callbacks = {
387
394
{
388
395
onRowSelect : updateRowSelected ( tableModel . tbl_id , onTableChanged ) ,
@@ -395,7 +402,7 @@ class ConstraintPanel extends Component {
395
402
{ cellRenderer :
396
403
createLinkCell (
397
404
{
398
- hrefColIdx : tableModel . tableData . columns . length - 1
405
+ hrefColIdx : totalCol
399
406
}
400
407
)
401
408
} ,
0 commit comments