Skip to content

Commit 14ffe97

Browse files
author
Cindy Wang
committed
DM-10115 Reset the column select dropdown and table column stats when starting a new catalog search
1 parent 6b3ff9d commit 14ffe97

File tree

4 files changed

+39
-19
lines changed

4 files changed

+39
-19
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ export function ColumnOrExpression({colValStats,params,groupKey,fldPath,label,la
7070
};
7171

7272
var val = get(params, fldPath);
73-
const onColSelected = (colName) => {
74-
val = colName;
75-
dispatchValueChange({fieldKey: fldPath, groupKey, value: colName, valid: true});
73+
const onColSelected = (colValStats) => {
74+
return (colName) => {
75+
val = colName;
76+
dispatchValueChange({fieldKey: fldPath, groupKey, value: colName, valid: true, colValStats});
77+
};
7678
};
7779
const colValidator = getColValidator(colValStats,!nullAllowed);
7880
const value = get(params, fldPath);
@@ -102,7 +104,7 @@ export function ColumnOrExpression({colValStats,params,groupKey,fldPath,label,la
102104
/>
103105
<div style={{display: 'inline-block', cursor:'pointer', paddingLeft: 3, verticalAlign: 'middle', fontSize: 'larger'}}
104106
title={`Select ${name} column`}
105-
onClick={() => showColSelectPopup(colValStats, onColSelected,`Choose ${name}`,'OK',val)}>
107+
onClick={() => showColSelectPopup(colValStats, onColSelected(colValStats),`Choose ${name}`,'OK',val)}>
106108
{cols}
107109
</div>
108110
</div>

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

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

3-
import {get, defer} from 'lodash';
3+
import {get, defer, has} from 'lodash';
44
import ColValuesStatistics from './../ColValuesStatistics.js';
55
import {DATATYPE_HISTOGRAM} from '../dataTypes/HistogramCDT.js';
66
import CompleteButton from '../../ui/CompleteButton.jsx';
@@ -49,8 +49,6 @@ export function setOptions(groupKey, histogramParams) {
4949
{fieldKey: 'binWidth', value: get(histogramParams, 'binWidth','')},
5050
{fieldKey: 'minCutoff', value: get(histogramParams, 'minCutoff','')},
5151
{fieldKey: 'maxCutoff', value: get(histogramParams, 'maxCutoff','')}
52-
53-
5452
];
5553
dispatchMultiValueChange(groupKey, flds);
5654
}
@@ -79,6 +77,10 @@ var columnNameReducer= (colValStats) => {
7977
if (!inFields) {
8078
return {};
8179
}
80+
if (has(action.payload, 'colValStats')) {
81+
colValStats = get(action.payload, 'colValStats'); // reset column stats
82+
}
83+
8284
let fieldKey = undefined;
8385
if (action.type === VALUE_CHANGE) {
8486
// when column name changes, update the min/max input
@@ -87,6 +89,7 @@ var columnNameReducer= (colValStats) => {
8789
case 'columnOrExpr':
8890
const colName = action.payload.value;
8991
if (colName ) {
92+
9093
if (isSingleColumn(colName, colValStats)) {
9194
for (var i=0; i<colValStats.length; i++){
9295
if (colName=== colValStats[i].name) {
@@ -159,13 +162,13 @@ var columnNameReducer= (colValStats) => {
159162
};
160163
export class HistogramOptions extends React.Component {
161164

162-
constructor(props) {
163-
super(props);
164-
this.state = {
165-
fields : FieldGroupUtils.getGroupFields(this.props.groupKey),
166-
fixedAlgorithm: get(getAppOptions(), 'charts.ui.HistogramOptions.fixedAlgorithm') || props.fixedAlgorithm
167-
};
168-
}
165+
constructor(props) {
166+
super(props);
167+
this.state = {
168+
fields : FieldGroupUtils.getGroupFields(this.props.groupKey),
169+
fixedAlgorithm: get(getAppOptions(), 'charts.ui.HistogramOptions.fixedAlgorithm') || props.fixedAlgorithm
170+
};
171+
}
169172

170173

171174
shouldComponentUpdate(np, ns) {

src/firefly/js/ui/ChartSelectDropdown.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ import LOADING from 'html/images/gxt/loading.gif';
2828

2929
const dropdownName = 'ChartSelectDropDownCmd';
3030

31-
const SCATTER = 'scatter';
32-
const HISTOGRAM = 'histogram';
31+
export const SCATTER = 'scatter';
32+
export const HISTOGRAM = 'histogram';
3333
const PREF_CHART_TYPE = 'pref.chartType';
3434

35-
function getFormName(chartType) {
35+
export function getFormName(chartType) {
3636
return chartType+'ChartOpts';
3737
}
3838

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {FormPanel} from '../../ui/FormPanel.jsx';
88
import { get, merge, isEmpty, isFunction} from 'lodash';
99
import {updateMerge} from '../../util/WebUtil.js';
1010
import {ListBoxInputField} from '../../ui/ListBoxInputField.jsx';
11-
import {doFetchTable, makeTblRequest, makeIrsaCatalogRequest, makeVOCatalogRequest} from '../../tables/TableUtil.js';
11+
import {doFetchTable, makeTblRequest, makeIrsaCatalogRequest, makeVOCatalogRequest, getTblIdsByGroup} from '../../tables/TableUtil.js';
1212
import {CatalogTableListField} from './CatalogTableListField.jsx';
1313
import {CatalogConstraintsPanel} from './CatalogConstraintsPanel.jsx';
1414
import {FieldGroup} from '../../ui/FieldGroup.jsx';
@@ -27,6 +27,9 @@ 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+
import {SCATTER, HISTOGRAM, getFormName} from '../../ui/ChartSelectDropdown.jsx';
31+
import {setOptions as HistogramSetOptions} from '../../charts/ui/HistogramOptions.jsx';
32+
import {setOptions as XYPlotSetOptions} from '../../charts/ui/XYPlotOptions.jsx';
3033

3134

3235
import './CatalogTableListField.css';
@@ -213,7 +216,19 @@ function doCatalog(request) {
213216
tReq.selcols = colsSearched;
214217
}
215218

216-
console.log('final request: ' + JSON.stringify(tReq));
219+
//console.log('final request: ' + JSON.stringify(tReq));
220+
if (!isEmpty(getTblIdsByGroup())) { // triview has table already, reset the chart column select form values
221+
const chartHandler = {[SCATTER]: XYPlotSetOptions,
222+
[HISTOGRAM]: HistogramSetOptions};
223+
224+
Object.keys(chartHandler).forEach((chartType) => {
225+
const formGroupName = getFormName(chartType);
226+
227+
if (!isEmpty(FieldGroupUtils.getGroupFields(formGroupName))) {
228+
chartHandler[chartType](formGroupName);
229+
}
230+
});
231+
}
217232
dispatchTableSearch(tReq);
218233
}
219234

0 commit comments

Comments
 (0)