diff --git a/js/source/legacy/solGS/loadAcronyms.js b/js/source/legacy/solGS/loadAcronyms.js index 77662f9ac5..119cd4f8be 100644 --- a/js/source/legacy/solGS/loadAcronyms.js +++ b/js/source/legacy/solGS/loadAcronyms.js @@ -4,65 +4,61 @@ * */ - var solGS = solGS || function solGS () {}; solGS.acronyms = { loadAcronyms: function() { - var id; var page = document.URL; + var id = page.match(/breeders\/trial\//) + ? jQuery('#trial_id').val() + : jQuery('#training_pop_id').val(); - if (page.match(/breeders\/trial\//)) { - id = jQuery('#trial_id').val(); - } else { - id = jQuery('#training_pop_id').val(); - } - - var acros = jQuery.ajax({ + return jQuery.ajax({ type : 'POST', dataType: 'json', - data : {'id': id}, + data : { id: id }, url : '/solgs/load/trait/acronyms/', }); - - return acros; }, - displayAcronyms: function(data) { - var table = jQuery('#trait_acronyms_table').DataTable({ - 'searching' : false, - 'ordering' : false, - 'processing': true, - 'paging' : false, - 'info' : false, - }); + if (!data || !data.length) return; + + var table; + if (jQuery.fn.DataTable.isDataTable('#trait_acronyms_table')) { + table = jQuery('#trait_acronyms_table').DataTable(); + } else { + table = jQuery('#trait_acronyms_table').DataTable({ + searching : false, + ordering : false, + processing : true, + paging : false, + info : false, + }); + } table.rows.add(data).draw(); + }, - } - -///////////// -} -//////////// - - -jQuery(document).ready( function() { - jQuery('#trait_acronyms_div').show(); - - solGS.acronyms.loadAcronyms().done( function(res) { - solGS.acronyms.displayAcronyms(res.acronyms); - }); - - solGS.acronyms.loadAcronyms().fail( function(res) { - jQuery('#trait_acronyms_table').hide(); - var errorMsg = 'Error occured loading acronyms'; + showError: function() { + jQuery('#trait_acronyms_table').hide(); jQuery('#acronyms_message') - .html(errorMsg) + .html('Error occurred loading acronyms') .show() - .fadeOut(50000); - }); + .fadeOut(5000); + }, +}; + +jQuery(document).ready(function() { + jQuery('#trait_acronyms_div').show(); + solGS.acronyms.loadAcronyms() + .done(function(res) { + solGS.acronyms.displayAcronyms(res.acronyms); + }) + .fail(function() { + solGS.acronyms.showError(); + }); }); diff --git a/lib/CXGN/Stock/Vector/ParseUpload/Plugin/VectorsGeneric.pm b/lib/CXGN/Stock/Vector/ParseUpload/Plugin/VectorsGeneric.pm index 0fb3eb7274..8be2d87b17 100644 --- a/lib/CXGN/Stock/Vector/ParseUpload/Plugin/VectorsGeneric.pm +++ b/lib/CXGN/Stock/Vector/ParseUpload/Plugin/VectorsGeneric.pm @@ -24,7 +24,7 @@ sub _validate_with_plugin { file => $filename, required_columns => ['uniquename'], optional_columns => $editable_vector_stockprops, - unique_only_columns => {'uniquename' => 1}, + unique_only_columns => ['uniquename'], column_aliases => { 'uniquename' => ['Uniquename', 'Name', 'name', 'vector_name', 'vector name'], 'Strain' => ['strain'], diff --git a/lib/SGN/Controller/solGS/Trait.pm b/lib/SGN/Controller/solGS/Trait.pm index f2e78be629..a549872457 100644 --- a/lib/SGN/Controller/solGS/Trait.pm +++ b/lib/SGN/Controller/solGS/Trait.pm @@ -242,9 +242,20 @@ sub get_acronym_pairs { $pop_id = $c->stash->{training_pop_id} if !$pop_id; #$pop_id = $c->stash->{combo_pops_id} if !$pop_id; + my @acronym_pairs; my $dir = $c->stash->{solgs_cache_dir}; - opendir my $dh, $dir - or die "can't open $dir: $!\n"; + + if ( !defined $dir || !-d $dir ) { + print STDERR "solgs cache dir does not exists: $dir"; + $c->stash->{acronym} = \@acronym_pairs; + return \@acronym_pairs; + } + + opendir my $dh, $dir or do { + print STDERR "can not open $dir: $!"; + $c->stash->{acronym} = \@acronym_pairs; + return \@acronym_pairs; + }; no warnings 'uninitialized'; @@ -256,8 +267,8 @@ sub get_acronym_pairs { my @acronym_pairs; if (-f $acronyms_file) { - @acronym_pairs = map { [ split(/\t/) ] } read_file($acronyms_file, {binmode => ':utf8'}); - shift(@acronym_pairs); # remove header; + @acronym_pairs = map { [ split(/\t/) ] } read_file($acronyms_file, {binmode => ':utf8'}); + shift(@acronym_pairs); # remove header } @acronym_pairs = sort {uc $a->[0] cmp uc $b->[0] } @acronym_pairs; diff --git a/mason/breeders_toolbox/trial.mas b/mason/breeders_toolbox/trial.mas index 816e5993c8..861c139327 100644 --- a/mason/breeders_toolbox/trial.mas +++ b/mason/breeders_toolbox/trial.mas @@ -89,15 +89,25 @@ $project_id => undef % $barcode_section_title = 'Generate barcode labels for plots or plants or accessions in this trial.'; % } - - - - - - - - - + + + + + + + + + + + + + + + + + + +