@@ -307,15 +307,30 @@ export const MappedColumnFld = ({cols, fieldKey, name, ...props}) => (
307
307
* @param cols {Columns} - all column options for the ColumnFld
308
308
* @param colTblId {string} - id of the column selection table that appears in a popup when the search button is clicked on a ColumnFld
309
309
* @param ucd {string} - UCD to filter by
310
+ * @param operator {string} filter type (like, in, etc.)
310
311
*/
311
- export function filterMappedColFldTbl ( cols , colTblId , ucd ) {
312
+ export function filterMappedColFldTbl ( cols , colTblId , ucd , operator = 'like' ) {
312
313
onTableLoaded ( colTblId ) . then ( ( tbl ) => {
313
- const colsWithUcd = cols . filter ( ( col ) => { if ( col . ucd ) { return col . ucd . includes ( ucd ) ; } } ) ;
314
+ const ucdList = ucd . split ( ',' ) . map ( ( s ) => s . trim ( ) ) . filter ( Boolean ) ;
315
+ const colsWithUcd = cols . filter ( ( col ) =>
316
+ col . ucd && ucdList . some ( ( u ) => col . ucd . includes ( u ) )
317
+ ) ;
314
318
if ( colsWithUcd . length > 1 ) {
315
319
if ( ! tbl ) return ;
316
320
const filterInfo = tbl ?. request ?. filters ;
317
321
const filterInfoCls = FilterInfo . parse ( filterInfo ) ;
318
- const ucdFilter = `like '%${ ucd } %'` ;
322
+ let ucdFilter ;
323
+ if ( operator === 'like' ) {
324
+ //build LIKE expression: like '%ucd1%' OR like '%ucd2%' ...
325
+ ucdFilter = ucdList . map ( ( ucd ) => `like '%${ ucd } %'` ) . join ( ' OR ' ) ;
326
+ } else if ( operator === 'in' ) {
327
+ //build IN expression: in ('ucd1','ucd2','ucd3')
328
+ const quoted = ucdList . map ( ( ucd ) => `'${ ucd } '` ) . join ( ', ' ) ;
329
+ ucdFilter = `in (${ quoted } )` ;
330
+ } else {
331
+ console . warn ( `Unsupported filter type: ${ operator } ` ) ;
332
+ return ;
333
+ }
319
334
filterInfoCls . setFilter ( 'UCD' , ucdFilter ) ;
320
335
const newRequest = { tbl_id : tbl . tbl_id , filters : filterInfoCls . serialize ( ) } ;
321
336
dispatchTableFilter ( newRequest ) ;
@@ -371,11 +386,13 @@ export function UploadTableSelectorPosCol(props) {
371
386
372
387
export function CenterColumns ( { lonCol, latCol, sx, cols, lonKey, latKey, openKey,
373
388
doQuoteNonAlphanumeric, headerTitle= 'Position Columns:' ,
374
- headerPostTitle = '' , posDefaultOpenMsg= '' , setPosDefaultOpenMsg, slotProps} ) {
389
+ headerPostTitle = '' , posDefaultOpenMsg= '' , setPosDefaultOpenMsg, tableName , slotProps} ) {
375
390
const columnFields = positionColumnFields (
376
- { fieldKey : lonKey , doQuoteNonAlphanumeric} ,
377
- { fieldKey : latKey , doQuoteNonAlphanumeric}
378
- ) ;
391
+ { fieldKey : lonKey , doQuoteNonAlphanumeric, colTblId : 'posCol' + tableName , onSearchBtnClicked : ( ) =>
392
+ filterMappedColFldTbl ( cols , 'posCol' + tableName , 'pos.eq.ra, pos.eq.ra;meta.main, pos.galactic.lon, pos.galactic.lon;meta.main, pos.ecliptic.lon, pos.ecliptic.lon;meta.main, pos.eq;meta.main,' , 'in' ) } ,
393
+ { fieldKey : latKey , doQuoteNonAlphanumeric, colTblId : 'posCol' + tableName , onSearchBtnClicked : ( ) =>
394
+ filterMappedColFldTbl ( cols , 'posCol' + tableName , 'pos.eq.dec, pos.eq.dec;meta.main, pos.galactic.lat, pos.galactic.lat;meta.main, pos.ecliptic.lat, pos.ecliptic.lat;meta.main, pos.eq;meta.main' , 'in' ) }
395
+ ) ; //colTblId: posCol+tableName is to give the col select popups for each table a unique tblId, otherwise it may lead to bugs with different tables sharing the same tblId
379
396
380
397
const customSlotProps = defaultsDeep ( { openPreMessage : { level : 'body-sm' } } , slotProps , selectorPosColSlotProps . columnMappingPanel . slotProps ) ;
381
398
0 commit comments