From 044261197f08f6124d42a83e14ba735a637adabb Mon Sep 17 00:00:00 2001 From: roby Date: Tue, 2 May 2023 16:22:20 -0600 Subject: [PATCH] Firefly-1243: make sure the string conversion has spaces between number - added polygon validation --- src/firefly/js/ui/dynamic/DLGeneratedDropDown.js | 10 ++++++++++ src/firefly/js/ui/dynamic/DynamicUISearchPanel.jsx | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/firefly/js/ui/dynamic/DLGeneratedDropDown.js b/src/firefly/js/ui/dynamic/DLGeneratedDropDown.js index 4e242e1168..bbfa7a67c1 100644 --- a/src/firefly/js/ui/dynamic/DLGeneratedDropDown.js +++ b/src/firefly/js/ui/dynamic/DLGeneratedDropDown.js @@ -22,8 +22,10 @@ import {getHiPSZoomLevelForFOV} from '../../visualize/HiPSUtil.js'; import {dispatchChangeCenterOfProjection, dispatchZoom} from '../../visualize/ImagePlotCntlr.js'; import {getPlotViewById, primePlot} from '../../visualize/PlotViewUtil.js'; import {pointEquals} from '../../visualize/Point.js'; +import {CONE_CHOICE_KEY} from '../../visualize/ui/CommonUIKeys.js'; import {isHiPS} from '../../visualize/WebPlot.js'; import {UserZoomTypes} from '../../visualize/ZoomUtil.js'; +import {getSpacialSearchType, hasValidSpacialSearch} from './DynComponents.jsx'; import {confirmDLMenuItem} from './FetchDatalinkTable.js'; import { getStandardIdType, ingestInitArgs, @@ -511,6 +513,14 @@ function DLGeneratedTableSearch({currentTblId, initArgs, sideBar, regHasUrl, url const submitSearch= (r) => { const {fds, standardID, idx}= findFieldDefInfo(r); + + if (!hasValidSpacialSearch(r,fds)) { + showInfoPopup( getSpacialSearchType(r,fds)===CONE_CHOICE_KEY ? + 'Target is required' : + 'Search Area is require and must have at least 3 point pairs, each separated by commas'); + return false; + } + const convertedR= convertRequest(r,fds,getStandardIdType(standardID)); const numKeys= [...new Set(fds.map( ({key}) => key))].length; diff --git a/src/firefly/js/ui/dynamic/DynamicUISearchPanel.jsx b/src/firefly/js/ui/dynamic/DynamicUISearchPanel.jsx index 12ad9299f1..6ea156cdb1 100644 --- a/src/firefly/js/ui/dynamic/DynamicUISearchPanel.jsx +++ b/src/firefly/js/ui/dynamic/DynamicUISearchPanel.jsx @@ -60,6 +60,12 @@ export function DynamicForm({DynLayoutPanel, groupKey,fieldDefAry, onSubmit, onE ); } +function cleanupPolygonString(inStr='') { + return inStr.replaceAll(',', ' ') + .split(' ') + .filter( (s) => s) + .join(' '); +} export function convertRequest(request, fieldDefAry, standardIDType) { const retReq= fieldDefAry.reduce( (out, {key,type, targetDetails:{raKey,decKey, targetKey,polygonKey, sizeKey}={} }) => { @@ -77,8 +83,8 @@ export function convertRequest(request, fieldDefAry, standardIDType) { case UNKNOWN: return out; case POLYGON: - if (standardIDType===standardIDs.sia) out[key]= 'POLYGON ' +request[polygonKey].replaceAll(',', ''); - else if (standardIDType===standardIDs.soda) out[key]= request[polygonKey].replaceAll(',', ''); + if (standardIDType===standardIDs.sia) out[key]= 'POLYGON ' +cleanupPolygonString(request[polygonKey]); + else if (standardIDType===standardIDs.soda) out[key]= cleanupPolygonString(request[polygonKey]); else out[key]=request[polygonKey]; return out; case CHECKBOX: