Skip to content

Commit 3fb6099

Browse files
authored
Merge pull request #237 from Caltech-IPAC/DM-7964-prefilled-period
DM-7964: get period from table/plot
2 parents c6ba3af + b38bc13 commit 3fb6099

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

src/firefly/js/templates/lightcurve/LcPhaseFoldingPanel.jsx

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@ import {SuggestBoxInputField} from '../../ui/SuggestBoxInputField.jsx';
1515
import Histogram from '../../charts/ui/Histogram.jsx';
1616
import CompleteButton from '../../ui/CompleteButton.jsx';
1717
import {FieldGroup} from '../../ui/FieldGroup.jsx';
18-
import {dispatchMultiValueChange, dispatchRestoreDefaults} from '../../fieldGroup/FieldGroupCntlr.js';
18+
import {dispatchValueChange, dispatchRestoreDefaults} from '../../fieldGroup/FieldGroupCntlr.js';
1919
import DialogRootContainer from '../../ui/DialogRootContainer.jsx';
2020
import {PopupPanel} from '../../ui/PopupPanel.jsx';
2121
import FieldGroupUtils, {revalidateFields} from '../../fieldGroup/FieldGroupUtils';
22-
import {makeTblRequest,getTblById} from '../../tables/TableUtil.js';
22+
import {makeTblRequest,getTblById,getCellValue} from '../../tables/TableUtil.js';
2323

2424
import {CollapsiblePanel} from '../../ui/panel/CollapsiblePanel.jsx';
2525
import {Tabs, Tab,FieldGroupTabs} from '../../ui/panel/TabPanel.jsx';
2626
import {dispatchShowDialog} from '../../core/ComponentCntlr.js';
27-
import {dispatchTableSearch} from '../../tables/TablesCntlr.js';
27+
import {dispatchTableSearch, TABLE_HIGHLIGHT} from '../../tables/TablesCntlr.js';
2828

2929
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';
3131
import {showPhaseFoldingPopup} from './LcPhaseFoldingPopup.jsx';
3232

33+
import {isUndefined, get,set,isNil} from 'lodash';
34+
import {take} from 'redux-saga/effects';
3335
import './LCPanels.css';
3436

3537
const grpkey = 'LC_FORM_Panel';
@@ -135,7 +137,7 @@ var LcPhaseFoldingDialog = React.createClass({
135137
return (
136138
<div style={{padding:'5px', minWidth: 480}}>
137139
<div>
138-
<Tabs componentKey='LCInputTabs' defaultSelected={0} useFlex={true}>
140+
<Tabs componentKey='LCInputTabs' defaultSelected={0} keepState={true} useFlex={true}>
139141
<Tab name='Phase Folding'>
140142
<LcPhaseFoldingForm />
141143
</Tab>
@@ -225,7 +227,6 @@ export function LcPFOptionsPanel ({fields}) {
225227

226228
<br/>
227229
<ValidationField fieldKey='flux'
228-
forceReinit={true}
229230
initialState= {{
230231
fieldKey: 'flux',
231232
value: '2.0',
@@ -238,7 +239,6 @@ export function LcPFOptionsPanel ({fields}) {
238239
<br/>
239240

240241
<ValidationField fieldKey='fluxerror'
241-
forceReinit={true}
242242
initialState= {{
243243
fieldKey: 'fluxerror',
244244
value: '0.02',
@@ -250,7 +250,6 @@ export function LcPFOptionsPanel ({fields}) {
250250
<br/>
251251

252252
<ValidationField fieldKey='period'
253-
forceReinit={true}
254253
initialState= {{
255254
fieldKey: 'period',
256255
value: '1.0',
@@ -408,6 +407,42 @@ function makeField1(hide) {
408407
return hide ? hidden : f1;
409408
}
410409

410+
export function* listenerPanel() {
411411

412+
while (true) {
413+
const action = yield take([
414+
TABLE_HIGHLIGHT
415+
]);
412416

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+
}
413433
//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+
}

src/firefly/js/templates/lightcurve/LcViewer.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {flux, firefly} from '../../Firefly.js';
1111
import {getMenu, isAppReady, dispatchSetMenu, dispatchOnAppReady} from '../../core/AppDataCntlr.js';
1212
import {LO_VIEW, getLayouInfo, SHOW_DROPDOWN} from '../../core/LayoutCntlr.js';
1313
import {lcManager, PERIODOGRAM, PHASE_FOLDED, RAW_TABLE, PEAK_TABLE} from './LcManager.js';
14+
import {listenerPanel} from './LcPhaseFoldingPanel.jsx';
1415
import {LcResult} from './LcResult.jsx';
1516
import {Menu} from '../../ui/Menu.jsx';
1617
import {Banner} from '../../ui/Banner.jsx';
@@ -40,6 +41,7 @@ export class LcViewer extends Component {
4041
super(props);
4142
this.state = this.getNextState();
4243
dispatchAddSaga(lcManager);
44+
dispatchAddSaga(listenerPanel);
4345
dispatchAddSaga(syncChartViewer);
4446
}
4547

0 commit comments

Comments
 (0)