99import pandas as pd
1010import io
1111from shinylims .ui_helpers .table_controls import (
12+ COLVIS_COLUMN_TEXT ,
1213 DATE_VALUE_RENDERER ,
14+ FILTER_BUILDER_LANGUAGE ,
1315 batch_filter_button ,
1416 build_filter_status_bar ,
1517 clear_all_filters_script ,
1618 deselect_all_columns_button ,
1719 filter_state_draw_callback ,
1820 select_all_columns_button ,
21+ truncated_text_renderer ,
1922 visibility_preset_button ,
2023)
2124import re
@@ -440,17 +443,27 @@ def data_samples():
440443 column_index = 0
441444 date_column_index = - 1
442445
446+ # Indices for columns whose content is truncated with a hover tooltip
447+ nird_filename_index = dat .columns .get_loc ("NIRD Filename" ) if "NIRD Filename" in dat .columns else - 1
448+ experiment_name_index = dat .columns .get_loc ("Experiment Name" ) if "Experiment Name" in dat .columns else - 1
449+ billing_description_index = dat .columns .get_loc ("Billing Description" ) if "Billing Description" in dat .columns else - 1
450+ reagent_label_index = dat .columns .get_loc ("Reagent Label" ) if "Reagent Label" in dat .columns else - 1
451+
443452 return ITable (
444453 dat ,
445454 select = True ,
446- layout = {"topStart" : "buttons" , "topEnd" : "search" },
455+ layout = {"topStart" : "buttons" , "topEnd" : "search" , "bottomEnd" : None },
447456 lengthMenu = [[200 , 500 , 1000 , 2000 , - 1 ], [200 , 500 , 1000 , 2000 , "All" ]],
448- column_filters = "footer " ,
457+ column_filters = "header " ,
449458 search = {"smart" : True },
450459 classes = "nowrap compact hover order-column cell-border" ,
451460 scrollY = "84vh" ,
452461 scrollX = True ,
453462 paging = True ,
463+ scroller = True ,
464+ deferRender = True ,
465+ colReorder = True ,
466+ language = FILTER_BUILDER_LANGUAGE ,
454467 autoWidth = True ,
455468 maxBytes = 0 ,
456469 allow_html = True ,
@@ -464,6 +477,7 @@ def data_samples():
464477 "extend" : "colvis" ,
465478 "text" : "Selection" ,
466479 "collectionLayout" : "two-column" ,
480+ "columnText" : COLVIS_COLUMN_TEXT ,
467481 },
468482 {
469483 "extend" : "collection" ,
@@ -474,11 +488,11 @@ def data_samples():
474488 visibility_preset_button ([2 , 3 , 4 , 5 , 9 , 10 , 21 ]),
475489 ]
476490 },
477- # ── Row settings ──────────────────────────────────────────
478491 {'extend' : "spacer" ,
479492 'style' : 'bar' ,
480- 'text' : 'Rows' },
481- "pageLength" ,
493+ 'text' : 'Filter' },
494+ batch_filter_button (),
495+ {"extend" : "searchBuilder" },
482496 {
483497 "text" : "☑️ Select All Filtered Rows" ,
484498 "action" : JavascriptFunction ("""
@@ -497,29 +511,25 @@ def data_samples():
497511 }
498512 """ )
499513 },
500- # ── Export ────────────────────────────────────────────────
501514 {'extend' : "spacer" ,
502515 'style' : 'bar' ,
503516 'text' : 'Export' },
504517 {
505518 "extend" : "collection" ,
506519 "text" : "📤 Export" ,
507520 "buttons" : [
508- # Export to CSV — selected rows, visible columns
509521 {
510522 "extend" : "csvHtml5" ,
511523 "exportOptions" : {"columns" : ":visible" },
512524 "text" : "📄 Export to CSV" ,
513525 "title" : "Sample Data Export"
514526 },
515- # Export to Excel — selected rows, visible columns
516527 {
517528 "extend" : "excelHtml5" ,
518529 "exportOptions" : {"columns" : ":visible" },
519530 "text" : "📊 Export to Excel" ,
520531 "title" : "Sample Data Export"
521532 },
522- # Send selected rows to SAGA via FTP — triggers Shiny server logic
523533 {
524534 "text" : "🖥️ Send to SAGA for ATLAS" ,
525535 "action" : JavascriptFunction ("""
@@ -537,11 +547,6 @@ def data_samples():
537547 },
538548 ]
539549 },
540- {'extend' : "spacer" ,
541- 'style' : 'bar' ,
542- 'text' : 'Filter' },
543- batch_filter_button (),
544- {"extend" : "searchBuilder" },
545550 {'extend' : "spacer" ,
546551 'style' : 'bar' },
547552 ],
@@ -554,7 +559,31 @@ def data_samples():
554559 "targets" : date_column_index ,
555560 "type" : "date" ,
556561 "render" : DATE_VALUE_RENDERER
557- }
562+ },
563+ {
564+ "targets" : nird_filename_index ,
565+ "className" : "left-column" ,
566+ "width" : "805px" ,
567+ "render" : truncated_text_renderer (max_chars = 172 , max_width_px = 805 ),
568+ } if nird_filename_index != - 1 else {},
569+ {
570+ "targets" : experiment_name_index ,
571+ "className" : "left-column" ,
572+ "width" : "260px" ,
573+ "render" : truncated_text_renderer (max_chars = 60 , max_width_px = 260 ),
574+ } if experiment_name_index != - 1 else {},
575+ {
576+ "targets" : billing_description_index ,
577+ "className" : "left-column" ,
578+ "width" : "320px" ,
579+ "render" : truncated_text_renderer (max_chars = 100 , max_width_px = 320 ),
580+ } if billing_description_index != - 1 else {},
581+ {
582+ "targets" : reagent_label_index ,
583+ "className" : "left-column" ,
584+ "width" : "690px" ,
585+ "render" : truncated_text_renderer (max_chars = 156 , max_width_px = 690 ),
586+ } if reagent_label_index != - 1 else {},
558587 ]
559588 )
560589
0 commit comments