@@ -9,7 +9,7 @@ import FieldGroupCntlr from '../../fieldGroup/FieldGroupCntlr.js';
9
9
import { keyMap , computeLabelWidth , rgbFieldGroup , isTargetNeeded ,
10
10
IRAS , TWOMASS , WISE , MSX , DSS , SDSS , FITS , URL , NONE } from './ImageSelectPanel.jsx' ;
11
11
import { sizeFromDeg } from '../../ui/SizeInputField.jsx' ;
12
- import { get } from 'lodash' ;
12
+ import { get , isUndefined } from 'lodash' ;
13
13
14
14
// get unit (string), min (float) and max (float) from the data file
15
15
var getRangeItem = ( crtCatalogId , rangeItem ) => {
@@ -34,6 +34,18 @@ var getSize = (crtCatalogId) => {
34
34
}
35
35
} ;
36
36
37
+
38
+
39
+ function getTypeData ( keyMapId , key , id , value ) {
40
+ return {
41
+ fieldKey : keyMap [ keyMapId ] ,
42
+ label : get ( panelCatalogs [ id ] , [ key , 'Title' ] , 'Unused' ) ,
43
+ value : isUndefined ( value ) ? get ( panelCatalogs [ id ] , [ key , 'Default' ] , '' ) : value ,
44
+ labelWidth : computeLabelWidth ( get ( panelCatalogs [ id ] , [ key , 'Title' ] , 'Unused' ) )
45
+ } ;
46
+ }
47
+
48
+
37
49
// tab fields initialization
38
50
function initTabFields ( crtCatalogId ) {
39
51
return (
@@ -42,60 +54,15 @@ function initTabFields(crtCatalogId) {
42
54
fieldKey : keyMap [ 'catalogtab' ] ,
43
55
value : panelCatalogs [ crtCatalogId ] . CatalogId . toString ( )
44
56
} ,
45
- [ keyMap [ 'irastypes' ] ] : {
46
- fieldKey : keyMap [ 'irastypes' ] ,
47
- label : panelCatalogs [ IRAS ] . types . Title ,
48
- value : panelCatalogs [ IRAS ] . types . Default ,
49
- labelWidth : computeLabelWidth ( panelCatalogs [ IRAS ] . types . Title )
50
- } ,
51
- [ keyMap [ 'twomasstypes' ] ] : {
52
- fieldKey : keyMap [ 'twomasstypes' ] ,
53
- label : panelCatalogs [ TWOMASS ] . types . Title ,
54
- value : panelCatalogs [ TWOMASS ] . types . Default ,
55
- labelWidth : computeLabelWidth ( panelCatalogs [ TWOMASS ] . types . Title )
56
- } ,
57
- [ keyMap [ 'wisetypes' ] ] : {
58
- fieldKey : keyMap [ 'wisetypes' ] ,
59
- label : panelCatalogs [ WISE ] . types . Title ,
60
- value : panelCatalogs [ WISE ] . types . Default ,
61
- labelWidth : computeLabelWidth ( panelCatalogs [ WISE ] . types . Title )
62
- } ,
63
- [ keyMap [ 'wisebands' ] ] : {
64
- fieldKey : keyMap [ 'wisebands' ] ,
65
- label : panelCatalogs [ WISE ] . bands . Title ,
66
- value : panelCatalogs [ WISE ] . bands . Default ,
67
- labelWidth : computeLabelWidth ( panelCatalogs [ WISE ] . bands . Title )
68
- } ,
69
- [ keyMap [ 'msxtypes' ] ] : {
70
- fieldKey : keyMap [ 'msxtypes' ] ,
71
- label : panelCatalogs [ MSX ] . types . Title ,
72
- value : panelCatalogs [ MSX ] . types . Default ,
73
- labelWidth : computeLabelWidth ( panelCatalogs [ MSX ] . types . Title )
74
- } ,
75
- [ keyMap [ 'dsstypes' ] ] : {
76
- fieldKey : keyMap [ 'dsstypes' ] ,
77
- label : panelCatalogs [ DSS ] . types . Title ,
78
- value : panelCatalogs [ DSS ] . types . Default ,
79
- labelWidth : computeLabelWidth ( panelCatalogs [ DSS ] . types . Title )
80
- } ,
81
- [ keyMap [ 'sdsstypes' ] ] : {
82
- fieldKey : keyMap [ 'sdsstypes' ] ,
83
- label : panelCatalogs [ SDSS ] . types . Title ,
84
- value : panelCatalogs [ SDSS ] . types . Default ,
85
- labelWidth : computeLabelWidth ( panelCatalogs [ SDSS ] . types . Title )
86
- } ,
87
- [ keyMap [ 'fitslist' ] ] : {
88
- fieldKey : keyMap [ 'fitslist' ] ,
89
- label : panelCatalogs [ FITS ] . list . Title ,
90
- value : panelCatalogs [ FITS ] . list . Default ,
91
- labelWidth : computeLabelWidth ( panelCatalogs [ FITS ] . list . Title )
92
- } ,
93
- [ keyMap [ 'fitsextinput' ] ] : {
94
- fieldKey : keyMap [ 'fitsextinput' ] ,
95
- label : panelCatalogs [ FITS ] . extinput . Title ,
96
- value : '0' ,
97
- labelWidth : computeLabelWidth ( panelCatalogs [ FITS ] . extinput . Title )
98
- } ,
57
+ [ keyMap [ 'irastypes' ] ] : getTypeData ( 'irastypes' , 'types' , IRAS ) ,
58
+ [ keyMap [ 'twomasstypes' ] ] : getTypeData ( 'twomasstypes' , 'types' , TWOMASS ) ,
59
+ [ keyMap [ 'wisetypes' ] ] : getTypeData ( 'wisetypes' , 'types' , WISE ) ,
60
+ [ keyMap [ 'wisebands' ] ] : getTypeData ( 'wisebands' , 'bands' , WISE ) ,
61
+ [ keyMap [ 'msxtypes' ] ] : getTypeData ( 'msxtypes' , 'types' , MSX ) ,
62
+ [ keyMap [ 'dsstypes' ] ] : getTypeData ( 'dsstypes' , 'types' , DSS ) ,
63
+ [ keyMap [ 'sdsstypes' ] ] : getTypeData ( 'sdsstypes' , 'types' , SDSS ) ,
64
+ [ keyMap [ 'fitslist' ] ] : getTypeData ( 'fitslist' , 'list' , FITS ) ,
65
+ [ keyMap [ 'fitsextinput' ] ] : getTypeData ( 'fitsextinput' , 'extinput' , FITS , '0' ) ,
99
66
/*
100
67
[keyMap['blankinput']]: {
101
68
fieldKey: keyMap['blankinput'],
@@ -107,26 +74,11 @@ function initTabFields(crtCatalogId) {
107
74
labelWidth: computeLabelWidth(panelCatalogs[BLANK].input.Title)
108
75
},
109
76
*/
110
- [ keyMap [ 'urlinput' ] ] : {
111
- fieldKey : keyMap [ 'urlinput' ] ,
112
- label : panelCatalogs [ URL ] . input . Title ,
113
- validator : Validate . validateUrl . bind ( null , 'a url field' ) ,
114
- value : '' ,
115
- labelWidth : computeLabelWidth ( panelCatalogs [ URL ] . input . Title )
116
- } ,
117
- [ keyMap [ 'urllist' ] ] : {
118
- fieldKey : keyMap [ 'urllist' ] ,
119
- label : panelCatalogs [ URL ] . list . Title ,
120
- value : panelCatalogs [ URL ] . list . Default ,
121
- labelWidth : computeLabelWidth ( panelCatalogs [ URL ] . list . Title )
122
-
123
- } ,
124
- [ keyMap [ 'urlextinput' ] ] : {
125
- fieldKey : keyMap [ 'urlextinput' ] ,
126
- label : panelCatalogs [ URL ] . extinput . Title ,
127
- value : '0' ,
128
- labelWidth : computeLabelWidth ( panelCatalogs [ URL ] . extinput . Title )
129
- }
77
+ [ keyMap [ 'urlinput' ] ] : Object . assign (
78
+ getTypeData ( 'urlinput' , 'input' , URL , '' ) ,
79
+ { validator : Validate . validateUrl . bind ( null , 'a url field' ) } ) ,
80
+ [ keyMap [ 'urllist' ] ] : getTypeData ( 'urllist' , 'list' , FITS ) ,
81
+ [ keyMap [ 'urlextinput' ] ] : getTypeData ( 'urlextinput' , 'extinput' , URL , '0' ) ,
130
82
} ) ;
131
83
}
132
84
@@ -188,7 +140,7 @@ var initTargetSize = (crtCatalogId) => {
188
140
// reducer for the child field group (fieldgrouptabs for r, g, b)
189
141
export var ImageSelPanelChangeOneColor = ( inFields , action ) => {
190
142
if ( ! inFields ) {
191
- return initTabFields ( IRAS ) ;
143
+ return initTabFields ( panelCatalogs [ 0 ] . CatalogId ) ;
192
144
} else {
193
145
return inFields ;
194
146
}
0 commit comments