Skip to content

DM-6909: Filtering from expanded mode cancels expanded mode #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 19, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions src/firefly/html/css/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,7 @@
display: inline-block;
position: relative;
text-shadow: 0 1px 0 #fff;
width: 12px;
height: 14px;
}
.btn-close:hover {
background-color: #949494;
border-radius: 50%;
cursor: pointer;
}
.btn-close:after {
content: '×'; /* UTF-8 symbol */
}

.btn-close {
color: #666;
font-size: 10px;
display: inline-block;
position: relative;
text-shadow: 0 1px 0 #fff;
width: 12px;
width: 14px;
height: 14px;
}
.btn-close:hover {
Expand All @@ -267,6 +249,10 @@
}
.btn-close:after {
content: '×'; /* UTF-8 symbol */
left: 50%;
position: absolute;
transform: translate(-50%, 0);
font-weight: bold;
}

/*-------------------< loading mask ---------------------*/
Expand Down
7 changes: 5 additions & 2 deletions src/firefly/js/charts/ui/ChartsTableViewPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ class ChartsPanel extends React.Component {
if (optionsShown) {
return (
<div className='ChartPanelOptions'>
<OptionsWrapper {...{chartId, tableModel, tblStatsData, tblPlotData, tblHistogramData, chartType}}/>
<OptionsWrapper toggleOptions={this.toggleOptions}
{...{chartId, tableModel, tblStatsData, tblPlotData, tblHistogramData, chartType}}/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if toggleOptions can be handled here.
Otherwise we need to propagate this prop to all options components (for now it included HistogramOptions) and handle situations when toggleOptions do not make sense, like in Charts dropdown.

</div>
);
}
Expand Down Expand Up @@ -597,7 +598,7 @@ export class OptionsWrapper extends React.Component {
// }

render() {
const { chartId, tableModel, tblStatsData, chartType, tblPlotData, tblHistogramData} = this.props;
const { chartId, tableModel, tblStatsData, chartType, tblPlotData, tblHistogramData, toggleOptions} = this.props;

if (get(tblStatsData,'isColStatsReady')) {
const formName = 'ChartOpt_' + chartType + chartId;
Expand All @@ -606,6 +607,7 @@ export class OptionsWrapper extends React.Component {
<XYPlotOptions key={formName} groupKey={formName}
colValStats={tblStatsData.colStats}
xyPlotParams={get(tblPlotData, 'xyPlotParams')}
toggleOptions={toggleOptions}
onOptionsSelected={(xyPlotParams) => {
XYPlotCntlr.dispatchLoadPlotData(chartId, xyPlotParams, tableModel.tbl_id);
}
Expand Down Expand Up @@ -637,6 +639,7 @@ OptionsWrapper.propTypes = {
tblStatsData : PropTypes.object,
tblPlotData : PropTypes.object,
tblHistogramData: PropTypes.object,
toggleOptions: PropTypes.func,
chartType: PropTypes.string
};

Expand Down
10 changes: 9 additions & 1 deletion src/firefly/js/charts/ui/XYPlotOptions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class XYPlotOptions extends React.Component {
}

render() {
const { colValStats, groupKey, xyPlotParams, onOptionsSelected}= this.props;
const { colValStats, groupKey, xyPlotParams, onOptionsSelected, toggleOptions}= this.props;

// the suggestions are indexes in the colValStats array - it makes it easier to render then with labels
const allSuggestions = colValStats.map((colVal,idx)=>{return idx;});
Expand Down Expand Up @@ -262,6 +262,13 @@ export class XYPlotOptions extends React.Component {

return (
<div style={{padding:'7px 5px'}}>
<div style={{ right: -11,
top: -6,
float: 'right'}}
className='btn-close'
title='Remove Tab'
onClick={() => toggleOptions()}/>

<FieldGroup groupKey={groupKey} validatorFunc={null} keepState={true}>
{onOptionsSelected &&
<div style={{display: 'flex', flexDirection: 'row', padding: '5px 0 15px'}}>
Expand Down Expand Up @@ -461,5 +468,6 @@ XYPlotOptions.propTypes = {
groupKey: PropTypes.string.isRequired,
colValStats: PropTypes.arrayOf(PropTypes.instanceOf(ColValuesStatistics)).isRequired,
onOptionsSelected: PropTypes.func,
toggleOptions: PropTypes.func,
xyPlotParams: plotParamsShape
};
50 changes: 36 additions & 14 deletions src/firefly/js/core/layout/FireflyLayoutManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function* layoutManager({title, views='tables | images | xyPlots'}) {
SHOW_DROPDOWN, SET_LAYOUT_MODE
]);

var {hasImages, hasTables, hasXyPlots, mode, ...others} = getLayouInfo();
var {hasImages, hasTables, hasXyPlots, mode, dropDown={}, ...others} = getLayouInfo();
// eslint-disable-next-line
var {images, tables, xyPlots} = others; //images, tables, and xyPlots are additional states relevant only to them.
var {expanded, standard} = mode || {};
Expand Down Expand Up @@ -67,26 +67,48 @@ export function* layoutManager({title, views='tables | images | xyPlots'}) {
if (ignore) continue; // ignores, don't update layout.

const count = filter([showTables, showXyPlots, showImages]).length;
if (count === 1) {
// set mode into expanded view when there is only 1 component visible.
closeable = false;
expanded = showImages ? LO_VIEW.images :
showXyPlots ? LO_VIEW.xyPlots :
showTables ? LO_VIEW.tables : expanded;
} else {
expanded = LO_VIEW.none;

// change mode when new UI elements are added or removed from results
switch (action.type) {
case TBL_RESULTS_ADDED:
case REPLACE_IMAGES :
case ImagePlotCntlr.PLOT_IMAGE :
case TABLE_REMOVE:
case ImagePlotCntlr.DELETE_PLOT_VIEW:
if (count === 1) {
// set mode into expanded view when there is only 1 component visible.
closeable = false;
expanded = showImages ? LO_VIEW.images :
showXyPlots ? LO_VIEW.xyPlots :
showTables ? LO_VIEW.tables : expanded;
} else {
expanded = LO_VIEW.none;
}
mode = {expanded, standard, closeable};
}

// calculate dropDown when new UI elements are added or removed from results
switch (action.type) {
case TBL_RESULTS_ADDED:
case REPLACE_IMAGES :
case ImagePlotCntlr.PLOT_IMAGE :
dropDown = {visible: count === 0};
break;
case TABLE_REMOVE:
case ImagePlotCntlr.DELETE_PLOT_VIEW:
if (!get(dropDown, 'visible', false)) {
dropDown = {visible: count === 0};
}
break;
}
mode = {expanded, standard, closeable};
const dropDown = {visible: count === 0};

dispatchUpdateLayoutInfo(omitBy({title, views, mode, searchDesc, dropDown, showTables, showImages, showXyPlots, images}, isNil));
}
}

function handleLayoutChanges(action) {
if (action.type === SHOW_DROPDOWN && get(action, 'payload.visible', true)) {
return true;
} else if (action.type === SET_LAYOUT_MODE && get(action, 'payload.mode') === LO_MODE.expanded){
if ((action.type === SHOW_DROPDOWN && get(action, 'payload.visible', true)) ||
(action.type === SET_LAYOUT_MODE && get(action, 'payload.mode') === LO_MODE.expanded)) {
return true;
} else {
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/firefly/js/tables/ui/BasicTableView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function makeColWidth(columns, showUnits) {
}, {});
}

function makeColumns ({columns, columnWidths, data, selectable, showUnits, showFilters, renderers, bgColor,
function makeColumns ({columns, columnWidths, data, selectable, showUnits, showFilters, renderers, bgColor='white',
selectInfoCls, filterInfo, sortInfo, onRowSelect, onSelectAll, onSort, onFilter, onFilterSelected}) {
if (!columns) return false;

Expand All @@ -259,7 +259,7 @@ function makeColumns ({columns, columnWidths, data, selectable, showUnits, showF
const HeadRenderer = get(renderers, [col.name, 'headRenderer'], HeaderCell);
const CellRenderer = get(renderers, [col.name, 'cellRenderer'], TextCell);
const fixed = col.fixed || false;
const style = col.fixed && bgColor && {backgroundColor: bgColor};
const style = col.fixed && {backgroundColor: bgColor};

return (
<Column
Expand Down
3 changes: 2 additions & 1 deletion src/firefly/js/tables/ui/TablePanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export class TablePanel extends Component {
showUnits={showUnits}
showFilters={showFilters}
onChange={this.onOptionUpdate}
toggleOptions={this.toggleOptions}
/> }
</div>
</div>
Expand Down Expand Up @@ -255,7 +256,7 @@ function TableTitle({tbl_id, title, removable}) {
<div style={{display: 'inline-block', marginLeft: 5, marginTop: 2}}
title={title}>{truncate(title)}</div>
{removable &&
<div style={{right: -5, paddingLeft: 3}} className='btn-close'
<div style={{right: -5}} className='btn-close'
title='Remove Tab'
onClick={() => dispatchTableRemove(tbl_id)}/>
}
Expand Down
13 changes: 11 additions & 2 deletions src/firefly/js/tables/ui/TablePanelOptions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class TablePanelOptions extends React.Component {
// }

render() {
const {columns, origColumns, pageSize, showUnits, showFilters, onChange, optSortInfo, filterInfo} = this.props;
const {columns, origColumns, pageSize, showUnits, showFilters, onChange, optSortInfo, filterInfo, toggleOptions} = this.props;
if (isEmpty(columns)) return false;

const {onPageSize, onPropChanged, onReset} = makeCallbacks(onChange, columns, origColumns);
Expand Down Expand Up @@ -64,6 +64,14 @@ export class TablePanelOptions extends React.Component {
</div>
</div>
<span>
<div style={{ position: 'relative',
display: 'block',
right: -42,
top: -4}}
className='btn-close'
title='Remove Tab'
onClick={() => toggleOptions()}/>

<button className='TablePanelOptions__button' onClick={onReset}
title='Reset all options to defauls'>Reset</button>
</span>
Expand All @@ -89,7 +97,8 @@ TablePanelOptions.propTypes = {
pageSize: React.PropTypes.number,
showUnits: React.PropTypes.bool,
showFilters: React.PropTypes.bool,
onChange: React.PropTypes.func
onChange: React.PropTypes.func,
toggleOptions: React.PropTypes.func
};

function makeCallbacks(onChange, columns, origColumns, data) {
Expand Down
2 changes: 1 addition & 1 deletion src/firefly/js/tables/ui/TableRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class TextCell extends React.Component {
const lineHeight = this.props.height - 6 + 'px'; // 6 is the top/bottom padding.
val = (val.search && val.search(html_regex) >= 0) ? <div dangerouslySetInnerHTML={{__html: val}}/> : val;
return (
<div style={{lineHeight}} className='public_fixedDataTableCell_cellContent'>{val}</div>
<div style={{lineHeight, ...this.props.style}} className='public_fixedDataTableCell_cellContent'>{val}</div>
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/firefly/js/ui/panel/TabPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export class Tab extends Component {
{name}
</div>
{removable &&
<div style={{right: -4, top: -3}} className='btn-close'
<div style={{right: -4, top: -2}} className='btn-close'
title='Remove Tab'
onClick={() => onTabRemove && onTabRemove(name)}/>
}
Expand Down
13 changes: 13 additions & 0 deletions src/firefly/js/util/WebUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export function decodeParams(queryStr) {
if (val.includes('&')) {
val = decodeParams(val);
}
if (isBooleanString(val)) {
val = toBoolean(val);
}
rval[parts[0]] = val;
return rval;
}, {});
Expand Down Expand Up @@ -452,3 +455,13 @@ export function toBoolean(val, def=undefined) {
typeof val === 'boolean'? val :
String(val).toLowerCase() === 'true';
}

/**
* return true if val is 'true' or 'fase' case-insensitive
* @param val the string value to check.
* @returns {*}
*/
export function isBooleanString(val) {
const s = String(val).toLowerCase();
return s === 'true' || s === 'false';
}