Skip to content

Commit ffa9e65

Browse files
author
Cindy Wang
committed
DM-10115 reset the chart column select dropdown content whenever the active table is changed.
1 parent 369fb6f commit ffa9e65

File tree

6 files changed

+40
-31
lines changed

6 files changed

+40
-31
lines changed

src/firefly/js/charts/ui/ColumnOrExpression.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import React, {PropTypes} from 'react';
66
import {get} from 'lodash';
77
import {Expression} from '../../util/expr/Expression.js';
88
import {dispatchValueChange} from '../../fieldGroup/FieldGroupCntlr.js';
9-
import {TextButton} from '../../ui/TextButton.jsx';
109
import {SuggestBoxInputField} from '../../ui/SuggestBoxInputField.jsx';
1110
import ColValuesStatistics from '../ColValuesStatistics.js';
1211
import {showColSelectPopup} from './ColSelectView.jsx';

src/firefly/js/charts/ui/HistogramOptions.jsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {PropTypes} from 'react';
22

3-
import {get, defer, has} from 'lodash';
3+
import {get, defer, isEmpty} from 'lodash';
44
import ColValuesStatistics from './../ColValuesStatistics.js';
55
import {DATATYPE_HISTOGRAM} from '../dataTypes/HistogramCDT.js';
66
import CompleteButton from '../../ui/CompleteButton.jsx';
@@ -68,21 +68,16 @@ function isSingleColumn(colName, colValStats) {
6868
}
6969
return false;
7070
}
71-
var columnNameReducer= (colValStats) => {
72-
if (!colValStats) {
73-
return {};
74-
}
71+
var columnNameReducer = () => {
7572
return (inFields, action) => {
7673

7774
if (!inFields) {
7875
return {};
7976
}
80-
if (has(action.payload, 'colValStats')) {
81-
colValStats = get(action.payload, 'colValStats'); // reset column stats
82-
}
77+
const colValStats = get(action.payload, 'colValStats');
8378

8479
let fieldKey = undefined;
85-
if (action.type === VALUE_CHANGE) {
80+
if (!isEmpty(colValStats) && action.type === VALUE_CHANGE) {
8681
// when column name changes, update the min/max input
8782
fieldKey = get(action.payload, 'fieldKey');
8883
switch (fieldKey){
@@ -297,7 +292,7 @@ export class HistogramOptions extends React.Component {
297292
return (
298293
<div style={{padding:'0 5px', minHeight: 250}}>
299294
<FieldGroup groupKey={groupKey} validatorFunc={null} keepState={true}
300-
reducerFunc={columnNameReducer(colValStats)}>
295+
reducerFunc={columnNameReducer()}>
301296

302297
{onOptionsSelected &&
303298
<div style={{display: 'flex', flexDirection: 'row', padding: '5px 0 15px'}}>
@@ -377,7 +372,7 @@ function renderFixedBinSizeOptions(groupKey, histogramParams, disabled){
377372
<RadioGroupInputField
378373
initialState= {{
379374
value: get(histogramParams, 'fixedBinSizeSelection', 'numBins'),
380-
tooltip: 'Please select number of bins or bin width',
375+
tooltip: 'Please select number of bins or bin width'
381376
//label: 'BinSize:'
382377
}}
383378
options={binSizeOptions}
@@ -390,7 +385,7 @@ function renderFixedBinSizeOptions(groupKey, histogramParams, disabled){
390385
initialState= {{
391386
value: get(histogramParams, 'numBins', '50'),
392387
validator:Validate.intRange.bind(null, 1, 500, 'numBins'),
393-
tooltip: 'Number of bins',
388+
tooltip: 'Number of bins'
394389

395390
}}
396391
disabled = {disabled}
@@ -403,7 +398,7 @@ function renderFixedBinSizeOptions(groupKey, histogramParams, disabled){
403398
initialState= {{
404399
value: get(histogramParams, 'binWidth', ''),
405400
validator:Validate.isFloat.bind(null, 'binWidth'),
406-
tooltip: 'Bin width',
401+
tooltip: 'Bin width'
407402

408403
}}
409404
disabled = {!disabled}

src/firefly/js/fieldGroup/FieldGroupCntlr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ export function dispatchInitFieldGroup(groupKey,keepState=false,
107107

108108

109109
/**
110-
*
111110
* @param groupKey
112111
* @param mounted
113112
* @param keepState
114113
* @param initValues
115114
* @param reducerFunc
116115
* @param actionTypes any action types (beyond the FieldGroup action types) that the reducer should allow though
117116
* @param wrapperGroupKey
117+
* @param forceUnmount
118118
*/
119119
export function dispatchMountFieldGroup(groupKey, mounted, keepState= false,
120120
initValues=null, reducerFunc= null,

src/firefly/js/templates/fireflyviewer/FireflyViewerManager.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {isMetaDataTable, isCatalogTable} from '../../metaConvert/converterUtils.
1515
import {META_VIEWER_ID} from '../../visualize/ui/TriViewImageSection.jsx';
1616
import {REPLACE_VIEWER_ITEMS, DEFAULT_FITS_VIEWER_ID, getViewerItemIds, getMultiViewRoot} from '../../visualize/MultiViewCntlr.js';
1717
import {visRoot} from '../../visualize/ImagePlotCntlr.js';
18+
import {resetChartSelectOptions} from '../../ui/ChartSelectDropdown.jsx';
1819

1920
/**
2021
* this manager manages what main components get display on the screen.
@@ -158,6 +159,8 @@ function handleActiveTableChange (layoutInfo, action) {
158159
var {images={}, showImages} = layoutInfo;
159160
var {coverageLockedOn, showCoverage, showMeta, metaDataTableId} = images;
160161

162+
resetChartSelectOptions();
163+
161164
const showFits= shouldShowFits();
162165
showImages= showFits||coverageLockedOn;
163166

src/firefly/js/ui/ChartSelectDropdown.jsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@ import * as TblUtil from '../tables/TableUtil.js';
1212
import * as TableStatsCntlr from '../charts/TableStatsCntlr.js';
1313
import * as ChartsCntlr from '../charts/ChartsCntlr.js';
1414
import {uniqueChartId} from '../charts/ChartUtil.js';
15-
import {XYPlotOptions} from '../charts/ui/XYPlotOptions.jsx';
1615
import {DT_XYCOLS} from '../charts/dataTypes/XYColsCDT.js';
17-
import {resultsSuccess as onXYPlotOptsSelected} from '../charts/ui/XYPlotOptions.jsx';
18-
import {HistogramOptions} from '../charts/ui/HistogramOptions.jsx';
16+
import {XYPlotOptions, resultsSuccess as onXYPlotOptsSelected,
17+
setOptions as XYPlotSetOptions} from '../charts/ui/XYPlotOptions.jsx';
1918
import {DT_HISTOGRAM} from '../charts/dataTypes/HistogramCDT.js';
20-
import {resultsSuccess as onHistogramOptsSelected} from '../charts/ui/HistogramOptions.jsx';
19+
import {HistogramOptions, resultsSuccess as onHistogramOptsSelected,
20+
setOptions as HistogramSetOptions} from '../charts/ui/HistogramOptions.jsx';
21+
2122
//import {uniqueChartId} from '../charts/ChartUtil.js';
2223

2324
import {FormPanel} from './FormPanel.jsx';
2425
import CompleteButton from './CompleteButton.jsx';
2526
import {dispatchHideDropDown} from '../core/LayoutCntlr.js';
27+
import FieldGroupUtils from '../fieldGroup/FieldGroupUtils';
28+
import {isEmpty} from 'lodash';
2629

2730
import LOADING from 'html/images/gxt/loading.gif';
2831

@@ -257,3 +260,22 @@ ChartSelectDropdown.propTypes = {
257260
ChartSelectDropdown.defaultProps = {
258261
name: dropdownName
259262
};
263+
264+
265+
/**
266+
* @summary reset chart column select dropdown value if the relevant field group exists
267+
*/
268+
export function resetChartSelectOptions() {
269+
const chartHandler = {
270+
[SCATTER]: XYPlotSetOptions,
271+
[HISTOGRAM]: HistogramSetOptions
272+
};
273+
274+
Object.keys(chartHandler).forEach((chartType) => {
275+
const formGroupName = getFormName(chartType);
276+
277+
if (!isEmpty(FieldGroupUtils.getGroupFields(formGroupName))) {
278+
chartHandler[chartType](formGroupName);
279+
}
280+
});
281+
}

src/firefly/js/visualize/ui/CatalogSelectViewPanel.jsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ import {FileUpload} from '../../ui/FileUpload.jsx';
2727
import {convertAngle} from '../VisUtil.js';
2828
import {masterTableFilter} from './IrsaMasterTableFilters.js';
2929
import {getAppOptions} from '../../core/AppDataCntlr.js';
30+
/*
3031
import {SCATTER, HISTOGRAM, getFormName} from '../../ui/ChartSelectDropdown.jsx';
3132
import {setOptions as HistogramSetOptions} from '../../charts/ui/HistogramOptions.jsx';
3233
import {setOptions as XYPlotSetOptions} from '../../charts/ui/XYPlotOptions.jsx';
33-
34+
*/
3435

3536
import './CatalogTableListField.css';
3637
import './CatalogSelectViewPanel.css';
@@ -215,19 +216,8 @@ function doCatalog(request) {
215216
if (colsSearched.length > 0) {
216217
tReq.selcols = colsSearched;
217218
}
218-
219219
//console.log('final request: ' + JSON.stringify(tReq));
220-
//reset column select dropdown value if there is the field group
221-
const chartHandler = {[SCATTER]: XYPlotSetOptions,
222-
[HISTOGRAM]: HistogramSetOptions};
223220

224-
Object.keys(chartHandler).forEach((chartType) => {
225-
const formGroupName = getFormName(chartType);
226-
227-
if (!isEmpty(FieldGroupUtils.getGroupFields(formGroupName))) {
228-
chartHandler[chartType](formGroupName);
229-
}
230-
});
231221
dispatchTableSearch(tReq);
232222
}
233223

0 commit comments

Comments
 (0)