@@ -15,21 +15,23 @@ import {SuggestBoxInputField} from '../../ui/SuggestBoxInputField.jsx';
15
15
import Histogram from '../../charts/ui/Histogram.jsx' ;
16
16
import CompleteButton from '../../ui/CompleteButton.jsx' ;
17
17
import { FieldGroup } from '../../ui/FieldGroup.jsx' ;
18
- import { dispatchMultiValueChange , dispatchRestoreDefaults } from '../../fieldGroup/FieldGroupCntlr.js' ;
18
+ import { dispatchValueChange , dispatchRestoreDefaults } from '../../fieldGroup/FieldGroupCntlr.js' ;
19
19
import DialogRootContainer from '../../ui/DialogRootContainer.jsx' ;
20
20
import { PopupPanel } from '../../ui/PopupPanel.jsx' ;
21
21
import FieldGroupUtils , { revalidateFields } from '../../fieldGroup/FieldGroupUtils' ;
22
- import { makeTblRequest , getTblById } from '../../tables/TableUtil.js' ;
22
+ import { makeTblRequest , getTblById , getCellValue } from '../../tables/TableUtil.js' ;
23
23
24
24
import { CollapsiblePanel } from '../../ui/panel/CollapsiblePanel.jsx' ;
25
25
import { Tabs , Tab , FieldGroupTabs } from '../../ui/panel/TabPanel.jsx' ;
26
26
import { dispatchShowDialog } from '../../core/ComponentCntlr.js' ;
27
- import { dispatchTableSearch } from '../../tables/TablesCntlr.js' ;
27
+ import { dispatchTableSearch , TABLE_HIGHLIGHT } from '../../tables/TablesCntlr.js' ;
28
28
29
29
import { loadXYPlot } from '../../charts/dataTypes/XYColsCDT.js' ;
30
- import { RAW_TABLE , PHASE_FOLDED } from '../../templates/lightcurve/LcManager.js' ;
30
+ import { RAW_TABLE , PHASE_FOLDED , PERIODOGRAM , PEAK_TABLE } from '../../templates/lightcurve/LcManager.js' ;
31
31
import { showPhaseFoldingPopup } from './LcPhaseFoldingPopup.jsx' ;
32
32
33
+ import { isUndefined , get , set , isNil } from 'lodash' ;
34
+ import { take } from 'redux-saga/effects' ;
33
35
import './LCPanels.css' ;
34
36
35
37
const grpkey = 'LC_FORM_Panel' ;
@@ -135,7 +137,7 @@ var LcPhaseFoldingDialog = React.createClass({
135
137
return (
136
138
< div style = { { padding :'5px' , minWidth : 480 } } >
137
139
< div >
138
- < Tabs componentKey = 'LCInputTabs' defaultSelected = { 0 } useFlex = { true } >
140
+ < Tabs componentKey = 'LCInputTabs' defaultSelected = { 0 } keepState = { true } useFlex = { true } >
139
141
< Tab name = 'Phase Folding' >
140
142
< LcPhaseFoldingForm />
141
143
</ Tab >
@@ -225,7 +227,6 @@ export function LcPFOptionsPanel ({fields}) {
225
227
226
228
< br />
227
229
< ValidationField fieldKey = 'flux'
228
- forceReinit = { true }
229
230
initialState = { {
230
231
fieldKey : 'flux' ,
231
232
value : '2.0' ,
@@ -238,7 +239,6 @@ export function LcPFOptionsPanel ({fields}) {
238
239
< br />
239
240
240
241
< ValidationField fieldKey = 'fluxerror'
241
- forceReinit = { true }
242
242
initialState = { {
243
243
fieldKey : 'fluxerror' ,
244
244
value : '0.02' ,
@@ -250,7 +250,6 @@ export function LcPFOptionsPanel ({fields}) {
250
250
< br />
251
251
252
252
< ValidationField fieldKey = 'period'
253
- forceReinit = { true }
254
253
initialState = { {
255
254
fieldKey : 'period' ,
256
255
value : '1.0' ,
@@ -408,6 +407,42 @@ function makeField1(hide) {
408
407
return hide ? hidden : f1 ;
409
408
}
410
409
410
+ export function * listenerPanel ( ) {
411
411
412
+ while ( true ) {
413
+ const action = yield take ( [
414
+ TABLE_HIGHLIGHT
415
+ ] ) ;
412
416
417
+ switch ( action . type ) {
418
+ case TABLE_HIGHLIGHT :
419
+ handleTableHighlight ( action ) ;
420
+ break ;
421
+ }
422
+ }
423
+ }
424
+
425
+ function handleTableHighlight ( action ) {
426
+ const { tbl_id} = action . payload ;
427
+ const per = getPeriodFromTable ( tbl_id ) ;
428
+ if ( per ) {
429
+ dispatchValueChange ( { fieldKey : 'period' , groupKey : grpkey , value : per } ) ;
430
+ }
431
+
432
+ }
413
433
//export default LcPhaseFoldingForm;
434
+
435
+ /**
436
+ * gets the period from either peak or periodogram table, these tables doesn't necesary have a period column and same name
437
+ * @param {string } tbl_id
438
+ * @returns {string } period value
439
+ */
440
+ function getPeriodFromTable ( tbl_id ) {
441
+ const tableModel = getTblById ( tbl_id ) ;
442
+ if ( ! tableModel || isNil ( tableModel . highlightedRow ) ) return ;
443
+ if ( tbl_id === PERIODOGRAM ) {
444
+ return getCellValue ( tableModel , tableModel . highlightedRow , 'PERIOD' ) ;
445
+ } else if ( tbl_id === PEAK_TABLE ) {
446
+ return getCellValue ( tableModel , tableModel . highlightedRow , 'Period' ) ;
447
+ }
448
+ }
0 commit comments