Skip to content

Commit eec0bc5

Browse files
authored
Merge pull request #196 from Caltech-IPAC/DM-7488_text_view
DM-7488: Text View does not show column's label, only name.
2 parents 0925535 + 9b145db commit eec0bc5

File tree

8 files changed

+32
-20
lines changed

8 files changed

+32
-20
lines changed

src/firefly/java/edu/caltech/ipac/firefly/server/util/ipactable/JsonTableUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ private static List<JSONObject> toJsonTableColumn(DataGroup dataGroup, TableDef
210210
if (!StringUtils.isEmpty(sortable)) {
211211
c.put("sortable", Boolean.parseBoolean(sortable));
212212
}
213+
String filterable = getColAttr(tableDef, FILTERABLE_TAG, cname);
214+
if (!StringUtils.isEmpty(filterable)) {
215+
c.put("filterable", Boolean.parseBoolean(filterable));
216+
}
213217
String units = getColAttr(tableDef, UNIT_TAG, cname);
214218
if (!StringUtils.isEmpty(units)) {
215219
c.put("units", units);

src/firefly/java/edu/caltech/ipac/firefly/util/DataSetParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class DataSetParser {
3838
public static final String FORMAT_TAG = "[email protected]"; // can be AUTO, NONE or a valid java format string. defaults to AUTO.
3939
public static final String FORMAT_DISP_TAG = "[email protected]";
4040
public static final String SORTABLE_TAG = "[email protected]";
41+
public static final String FILTERABLE_TAG = "[email protected]";
4142
public static final String ITEMS_TAG = "[email protected]";
4243
public static final String SORT_BY_TAG = "[email protected]";
4344
public static final String ENUM_VALS_TAG = "[email protected]";

src/firefly/java/edu/caltech/ipac/util/IpacTableUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ public static DataObject parseRow(DataGroup source, String line, boolean isFixed
279279
if (String.valueOf(type.getDataUnit()).equalsIgnoreCase("html") ||
280280
rval.trim().matches("<[^>]+>.*")) {
281281
source.addAttribute(DataSetParser.makeAttribKey(DataSetParser.SORTABLE_TAG, type.getKeyName()), "false");
282+
source.addAttribute(DataSetParser.makeAttribKey(DataSetParser.FILTERABLE_TAG, type.getKeyName()), "false");
282283
}
283284
}
284285
}

src/firefly/js/tables/TableUtil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ export function getTableSourceUrl(tbl_ui_id) {
670670
*/
671671
export function calcColumnWidths(columns, dataAry) {
672672
return columns.reduce( (pv, cv, idx) => {
673-
const cname = cv.name;
673+
const cname = cv.label || cv.name;
674674
var width = Math.max(cname.length, get(cv, 'units.length', 0), get(cv, 'type.length', 0));
675675
width = dataAry.reduce( (maxWidth, row) => {
676676
return Math.max(maxWidth, get(row, [idx, 'length'], 0));

src/firefly/js/tables/tables-typedefs.jsdoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@
4848
* @prop {string} units data units
4949
* @prop {string} desc description of the column
5050
* @prop {number} width column display width
51-
* @prop {number} prefWidth preferred width. if width is not defined
52-
* @prop {boolean} sortable true if undefined
51+
* @prop {number} prefWidth preferred width. if width is not defined
52+
* @prop {boolean} sortable true if undefined
53+
* @prop {boolean} filterable true if undefined
5354
* @prop {string} visibility show, hide, or hidden. hidden columns are not viewable by users.
5455
* @prop {string} sortByCols for multi-columns sorting. column names separated by comma(',').
5556
* @prop {string} related highlight related rows based on this column's value.

src/firefly/js/tables/ui/BasicTableView.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ function tableToText(columns, dataAry, showUnits=false) {
297297

298298
// column's name
299299
var textHead = columns.reduce( (pval, col, idx) => {
300-
return pval + (get(columns, [idx,'visibility'], 'show') === 'show' ? `${padEnd(col.name, colWidths[idx])}|` : '');
300+
return pval + (get(columns, [idx,'visibility'], 'show') === 'show' ? `${padEnd(col.label || col.name, colWidths[idx])}|` : '');
301301
}, '|');
302302

303303
// column's type

src/firefly/js/tables/ui/FilterEditor.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {createInputCell} from './TableRenderer.js';
1212
import {FILTER_CONDITION_TTIPS, FILTER_TTIPS, FilterInfo} from '../FilterInfo.js';
1313
import {sortTableData, calcColumnWidths} from '../TableUtil.js';
1414
import {InputAreaField} from '../../ui/InputAreaField.jsx';
15-
// import {deepDiff} from '../../util/WebUtil.js';
15+
import {toBoolean} from '../../util/WebUtil.js';
1616

1717
const wrapperStyle = {display: 'block', flexGrow: 0};
1818
const style = {display: 'block', width: '100%', resize: 'none', boxSizing: 'border-box', backgroundColor: 'white'};
@@ -95,8 +95,8 @@ function prepareOptionData(columns, sortInfo, filterInfo, selectable) {
9595
const filterInfoCls = FilterInfo.parse(filterInfo);
9696
columns = columns.filter((c) => c.visibility !== 'hidden');
9797
var data = columns.map( (v) => {
98-
const filter = filterInfoCls.getFilter(v.name) || '';
99-
return [v.name||'', filter, v.units||'', v.desc||'', v.visibility !== 'hide'];
98+
const filter = toBoolean(v.filterable, true) ? filterInfoCls.getFilter(v.name) || '' : undefined;
99+
return [v.label||v.name||'', filter, v.units||'', v.desc||'', v.visibility !== 'hide'];
100100
} );
101101
sortTableData(data, cols, sortInfo);
102102

src/firefly/js/tables/ui/TableRenderer.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -240,19 +240,24 @@ export const createInputCell = (tooltips, size = 10, validator, onChange, style)
240240
};
241241

242242
return ({rowIndex, data, colIdx}) => {
243-
return (
244-
<div style={{margin: 2}}>
245-
<InputField
246-
validator={validator}
247-
tooltip={tooltips}
248-
size={size}
249-
style={style}
250-
value={get(data, [rowIndex, colIdx],'')}
251-
onChange={(v) => changeHandler(rowIndex, data, colIdx, v) }
252-
actOn={['blur','enter']}
253-
/>
254-
</div>
255-
);
243+
const val = get(data, [rowIndex, colIdx]);
244+
if (val === undefined) {
245+
return null;
246+
} else {
247+
return (
248+
<div style={{margin: 2}}>
249+
<InputField
250+
validator={validator}
251+
tooltip={tooltips}
252+
size={size}
253+
style={style}
254+
value={val}
255+
onChange={(v) => changeHandler(rowIndex, data, colIdx, v) }
256+
actOn={['blur','enter']}
257+
/>
258+
</div>
259+
);
260+
}
256261
};
257262
};
258263

0 commit comments

Comments
 (0)