Skip to content

Commit

Permalink
FIREFLY-1365,1363: Merge pull request #1461 from FIREFLY-1365-and-FIR…
Browse files Browse the repository at this point in the history
…EFLY-1363

FIREFLY-1365,1363: fixed two issues
  • Loading branch information
robyww authored Dec 12, 2023
2 parents 5f4e25c + 0720591 commit 35b657e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
27 changes: 12 additions & 15 deletions src/firefly/js/ui/tap/TableColumnsConstraints.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {ADQL_LINE_LENGTH} from './TapUtil.js';

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

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

export function TableColumnsConstraints({columnsModel}) {

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

/**
Expand Down Expand Up @@ -171,18 +171,16 @@ function reorganizeTableModel(tableModel, columnNames, reset) {
e.splice(constraintsColIdx, 0, '');
});

// set selections
const selectInfoCls = SelectInfo.newInstance({rowCount: data.length});
if (selectInfoCls.getSelectedCount() === 0) {
let defaultSelected = [];
// default selected are the principal rows
if (isPrincipalSet(tableModel)) {
defaultSelected = getColumnValues(tableModel, 'principal').reduce((sels, v, i) => {
// default selected are either all or the principal rows
const usingPrincipal= isPrincipalSet(tableModel);
const selectInfoCls = SelectInfo.newInstance({selectAll:!usingPrincipal, rowCount: data.length});
if (usingPrincipal) {
getColumnValues(tableModel, 'principal')
.reduce((sels, v, i) => {
if (parseInt(v) === 1) sels.push(i);
return sels;
}, []);
}
defaultSelected.forEach((idx)=>selectInfoCls.setRowSelect(idx, true));
}, [])
.forEach((idx)=>selectInfoCls.setRowSelect(idx, true));
}

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

modifiedTableModel = {tbl_id, totalRows: data.length, tableData: {columns, data},
selectInfo: selectInfoCls.data, request: {tbl_id}};

modifiedTableModel = {tbl_id, totalRows: data.length, tableData: {columns, data}, selectInfo, request: {tbl_id}};
return modifiedTableModel;
}

Expand Down
6 changes: 4 additions & 2 deletions src/firefly/js/ui/tap/TapSearchRootPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function getServiceLabel(serviceUrl) {


export function TapSearchPanel({initArgs= {}, titleOn=true}) {
const [getTapBrowserState]= useFieldGroupMetaState(defTapBrowserState,TAP_PANEL_GROUP_KEY);
const [getTapBrowserState,setTapBrowserState]= useFieldGroupMetaState(defTapBrowserState,TAP_PANEL_GROUP_KEY);
const tapState= getTapBrowserState();
if (!initArgs?.urlApi?.execute) searchFromAPIOnce(true); // if not execute then mark as done, i.e. disable any auto searching
initApiAddedServiceOnce(initArgs); // only look for the extra service the first time
Expand Down Expand Up @@ -133,8 +133,10 @@ export function TapSearchPanel({initArgs= {}, titleOn=true}) {
{fieldKey: 'adqlQuery', placeholder: '', value: ''}
]
);
setServiceUrl(selectedOption.value);
const serviceUrl= selectedOption?.value;
setServiceUrl(serviceUrl);
setObsCoreTableModel(undefined);
setTapBrowserState({...getTapBrowserState(), serviceUrl});
};

useEffect(() => {
Expand Down

0 comments on commit 35b657e

Please sign in to comment.