@@ -48,7 +48,6 @@ type ProductTypeOption = {
4848 label : string ;
4949 icon : string ;
5050 external ?: boolean ;
51- comingSoon ?: boolean ;
5251 description ?: string ;
5352} ;
5453
@@ -129,14 +128,12 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
129128 label : "Papers" ,
130129 icon : "pi pi-book" ,
131130 external : true ,
132- comingSoon : true ,
133131 } ,
134132 {
135133 key : "patents" ,
136134 label : "Patents" ,
137135 icon : "pi pi-briefcase" ,
138136 external : true ,
139- comingSoon : true ,
140137 } ,
141138 ] ;
142139 private productTypesSub ?: Subscription ;
@@ -145,6 +142,7 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
145142 "Toggle to include external products like open-source code (patents & papers coming soon). Results and filters will blend with NIST data." ;
146143 externalInfoVisible : boolean = false ;
147144 examplesDialogVisible = false ;
145+ toastKey = "productToast" ;
148146 placeHolderText : string [ ] = [
149147 "Artificial Intelligence" ,
150148 "Kinetics database" ,
@@ -345,6 +343,22 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
345343 onExternalToggle ( enabled : boolean ) {
346344 this . includeExternalProducts = enabled ;
347345 this . searchService . setExternalProducts ( enabled ) ;
346+ if ( enabled ) {
347+ // Turn on all external products; keep data as-is.
348+ this . searchService . setProductTypes ( {
349+ code : true ,
350+ papers : true ,
351+ patents : true ,
352+ } ) ;
353+ } else {
354+ // Disable external products and ensure data stays on.
355+ this . searchService . setProductTypes ( {
356+ code : false ,
357+ papers : false ,
358+ patents : false ,
359+ data : true ,
360+ } ) ;
361+ }
348362 }
349363
350364 openExternalInfo ( ) {
@@ -356,20 +370,37 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
356370 }
357371
358372 get visibleProductTypes ( ) : ProductTypeOption [ ] {
359- return this . productTypeOptions . filter (
360- ( option ) => this . includeExternalProducts || ! option . external
361- ) ;
373+ return this . productTypeOptions ;
362374 }
363375
364376 isProductTypeActive ( key : ProductTypeKey ) : boolean {
365377 return ! ! this . productTypes && ! ! this . productTypes [ key ] ;
366378 }
367379
368380 onProductTypeToggle ( option : ProductTypeOption ) {
369- if ( option . comingSoon ) return ;
370- if ( option . external && ! this . includeExternalProducts ) return ;
381+ // If external toggle is off and user taps an external product, turn external on first.
382+ if ( option . external && ! this . includeExternalProducts ) {
383+ this . includeExternalProducts = true ;
384+ this . searchService . setExternalProducts ( true ) ;
385+ }
386+ // When external is off, data is locked on.
387+ if ( ! this . includeExternalProducts && option . key === "data" ) {
388+ return ;
389+ }
371390 const nextState = ! this . isProductTypeActive ( option . key ) ;
372391 this . searchService . setProductTypeEnabled ( option . key , nextState ) ;
392+
393+ // If external is on but no external products remain active, switch external off.
394+ if ( this . includeExternalProducts && ! this . hasActiveExternalProducts ( ) ) {
395+ this . includeExternalProducts = false ;
396+ this . searchService . setExternalProducts ( false ) ;
397+ }
398+ }
399+
400+ private hasActiveExternalProducts ( ) : boolean {
401+ const state : ProductTypeState =
402+ this . productTypes || { ...DEFAULT_PRODUCT_TYPES } ;
403+ return ! ! ( state . code || state . papers || state . patents ) ;
373404 }
374405
375406 /**
@@ -530,6 +561,17 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
530561 * @param searchTaxonomyKey
531562 */
532563 search ( searchValue : string , searchTaxonomyKey : string ) {
564+ const activeProducts = this . searchService . getActiveProductTypes ( ) ;
565+ if ( ! activeProducts || activeProducts . length === 0 ) {
566+ this . messageService . add ( {
567+ severity : "warn" ,
568+ summary : "Select a product" ,
569+ detail : "Choose at least one product type before searching." ,
570+ life : 3500 ,
571+ key : this . toastKey ,
572+ } ) ;
573+ return ;
574+ }
533575 this . searchTaxonomyKey = searchTaxonomyKey ;
534576
535577 this . searchService . search ( searchValue , this . router . url ) ;
0 commit comments