From 44cfecc06451651c5e3e0f0d997f31e45edca1ad Mon Sep 17 00:00:00 2001 From: bellerbrock Date: Mon, 16 Dec 2024 10:59:53 -0500 Subject: [PATCH] match accession coolumn form table by name and reduce logging --- lib/CXGN/BrAPI/v2/ObservationUnits.pm | 2 +- mason/tools/graphicalfiltering/index.mas | 37 +++++++++++++++++------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/CXGN/BrAPI/v2/ObservationUnits.pm b/lib/CXGN/BrAPI/v2/ObservationUnits.pm index 6a699a2778..580b61fad4 100644 --- a/lib/CXGN/BrAPI/v2/ObservationUnits.pm +++ b/lib/CXGN/BrAPI/v2/ObservationUnits.pm @@ -228,7 +228,7 @@ sub _search { ## Format position coordinates my $level_name = $obs_unit->{obsunit_type_name}; - print STDERR "LEVEL NAME: ".Dumper(\%numbers); + # print STDERR "LEVEL NAME: ".Dumper(\%numbers); my $level_order = _order($level_name) + 0; diff --git a/mason/tools/graphicalfiltering/index.mas b/mason/tools/graphicalfiltering/index.mas index b17c4500cf..36b675702f 100644 --- a/mason/tools/graphicalfiltering/index.mas +++ b/mason/tools/graphicalfiltering/index.mas @@ -225,20 +225,35 @@ }); $('#filtered_results').on( 'draw.dt', function () { + var table = $("#filtered_results").DataTable(); + var accessionColumnIndex = -1; - var names = []; - var data = $("#filtered_results").DataTable().context[0].aoData; - var displayed_rows = $("#filtered_results").DataTable().context[0].aiDisplay; - var names = []; - for (var i =0; i< displayed_rows.length; i++){ - var displayed_index = displayed_rows[i]; - names.push(data[displayed_index]._aFilterData[2]+'\n'); + // Determine the correct column index for "Accession" + table.columns().every(function (index) { + var header = this.header(); + if ($(header).text().trim() === "Accession") { + accessionColumnIndex = index; } - $('#graphical_filter_result_names').html(names); - addToListMenu('graphical_filter_results_to_list_menu', 'graphical_filter_result_names', { - listType: 'accessions' - }); }); + + if (accessionColumnIndex === -1) { + console.error("Accession column not found."); + return; + } + + var names = []; + var displayed_rows = table.rows({ filter: 'applied' }).indexes(); + displayed_rows.each(function (index) { + var accessionName = table.cell(index, accessionColumnIndex).data(); + names.push(accessionName + '\n'); + }); + + $('#graphical_filter_result_names').html(names.join('')); + addToListMenu('graphical_filter_results_to_list_menu', 'graphical_filter_result_names', { + listType: 'accessions' + }); + + }); }());