Skip to content

Commit 35b657e

Browse files
authored
FIREFLY-1365,1363: Merge pull request #1461 from FIREFLY-1365-and-FIREFLY-1363
FIREFLY-1365,1363: fixed two issues
2 parents 5f4e25c + 0720591 commit 35b657e

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

src/firefly/js/ui/tap/TableColumnsConstraints.jsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {ADQL_LINE_LENGTH} from './TapUtil.js';
99

1010
const COLS_TO_DISPLAY_FIRST = ['column_name','unit','ucd','description','datatype','arraysize','utype','xtype','principal'];
1111

12+
const SELECT_ALL_COLUMNS_WHEN_NO_PRINCIPAL=false; //todo- determine what to if not of the principal columns are set
1213

1314
export function TableColumnsConstraints({columnsModel}) {
1415

@@ -125,8 +126,7 @@ function tableEffect(columnsModel, setTableModel, tbl_id, setFilterCount, setSel
125126
* @returns {boolean}
126127
*/
127128
function isPrincipalSet(tableModel) {
128-
// 3 or more principle columns (coordinates and value) might be useful
129-
return getColumnValues(tableModel, 'principal').filter((v)=>v>0).length >= 3;
129+
return getColumnValues(tableModel, 'principal').filter((v)=>v>0).length >= 1;
130130
}
131131

132132
/**
@@ -171,18 +171,16 @@ function reorganizeTableModel(tableModel, columnNames, reset) {
171171
e.splice(constraintsColIdx, 0, '');
172172
});
173173

174-
// set selections
175-
const selectInfoCls = SelectInfo.newInstance({rowCount: data.length});
176-
if (selectInfoCls.getSelectedCount() === 0) {
177-
let defaultSelected = [];
178-
// default selected are the principal rows
179-
if (isPrincipalSet(tableModel)) {
180-
defaultSelected = getColumnValues(tableModel, 'principal').reduce((sels, v, i) => {
174+
// default selected are either all or the principal rows
175+
const usingPrincipal= isPrincipalSet(tableModel);
176+
const selectInfoCls = SelectInfo.newInstance({selectAll:!usingPrincipal, rowCount: data.length});
177+
if (usingPrincipal) {
178+
getColumnValues(tableModel, 'principal')
179+
.reduce((sels, v, i) => {
181180
if (parseInt(v) === 1) sels.push(i);
182181
return sels;
183-
}, []);
184-
}
185-
defaultSelected.forEach((idx)=>selectInfoCls.setRowSelect(idx, true));
182+
}, [])
183+
.forEach((idx)=>selectInfoCls.setRowSelect(idx, true));
186184
}
187185

188186
columns.forEach((c) => {
@@ -192,10 +190,9 @@ function reorganizeTableModel(tableModel, columnNames, reset) {
192190
c.prefWidth= 11;
193191
}
194192
});
193+
const selectInfo= (usingPrincipal||SELECT_ALL_COLUMNS_WHEN_NO_PRINCIPAL) ? selectInfoCls.data : undefined;
195194

196-
modifiedTableModel = {tbl_id, totalRows: data.length, tableData: {columns, data},
197-
selectInfo: selectInfoCls.data, request: {tbl_id}};
198-
195+
modifiedTableModel = {tbl_id, totalRows: data.length, tableData: {columns, data}, selectInfo, request: {tbl_id}};
199196
return modifiedTableModel;
200197
}
201198

src/firefly/js/ui/tap/TapSearchRootPanel.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function getServiceLabel(serviceUrl) {
101101

102102

103103
export function TapSearchPanel({initArgs= {}, titleOn=true}) {
104-
const [getTapBrowserState]= useFieldGroupMetaState(defTapBrowserState,TAP_PANEL_GROUP_KEY);
104+
const [getTapBrowserState,setTapBrowserState]= useFieldGroupMetaState(defTapBrowserState,TAP_PANEL_GROUP_KEY);
105105
const tapState= getTapBrowserState();
106106
if (!initArgs?.urlApi?.execute) searchFromAPIOnce(true); // if not execute then mark as done, i.e. disable any auto searching
107107
initApiAddedServiceOnce(initArgs); // only look for the extra service the first time
@@ -133,8 +133,10 @@ export function TapSearchPanel({initArgs= {}, titleOn=true}) {
133133
{fieldKey: 'adqlQuery', placeholder: '', value: ''}
134134
]
135135
);
136-
setServiceUrl(selectedOption.value);
136+
const serviceUrl= selectedOption?.value;
137+
setServiceUrl(serviceUrl);
137138
setObsCoreTableModel(undefined);
139+
setTapBrowserState({...getTapBrowserState(), serviceUrl});
138140
};
139141

140142
useEffect(() => {

0 commit comments

Comments
 (0)