Skip to content

Commit

Permalink
Merge pull request #4711 from solgenomics/topic/seedlots_to_list
Browse files Browse the repository at this point in the history
Fixed copy seedlots to list on Manage Seedlots page
  • Loading branch information
lukasmueller authored Oct 26, 2023
2 parents 4cffd0d + 0d59bc8 commit f6656a6
Showing 1 changed file with 53 additions and 61 deletions.
114 changes: 53 additions & 61 deletions mason/breeders_toolbox/seedlots.mas
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ $user_role => undef
<br />
<br />
<br />

<table id="available_seedlots_table" class="table table-hover table-striped table-bordered">
</table>

<div style="overflow:scroll">
<table id="available_seedlots_table" class="table table-hover table-striped table-bordered">
</table>
</div>

<hr>

Expand Down Expand Up @@ -201,84 +201,76 @@ jQuery(document).ready(function(){
source: '/ajax/stock/seedlot_name_autocomplete',
});


var seedlots_table;

//run the query only when the search button is clicked
jQuery('#submit_seedlot_search').click( function() {
if (seedlots_table) { seedlots_table.destroy(); }
seedlots_table = jQuery('#available_seedlots_table').DataTable({
'searching' : false,
if (seedlots_table) { seedlots_table.destroy() };
seedlots_table = jQuery('#available_seedlots_table').DataTable({
'searching' : false,
'ordering' : false,
'processing': true,
'serverSide': true,

'lengthMenu': [10,20,50,100,1000],

columns: [
{ title: "Seedlot Name", "data": null, "render": function ( data, type, row ) { return "<a href='/breeders/seedlot/"+row.seedlot_stock_id+"'>"+row.seedlot_stock_uniquename+"</a>"; } },
{ title: "Breeding Program", "data": "breeding_program_name" },
{ title: "Contents", "data": "contents_html" },
{ title: "Location", "data": "location" },
{ title: "Count", "data": "count" },
{ title: "Weight (g)", "data": "weight_gram" },
{ title: "Submitters", "data": "owners_string" },
{ title: "Organization", "data": "organization" },
{ title: "Box", "data": "box" },
{ title: "Quality", "data": "seedlot_quality" },
{ title: "Delete", "data": "null", "render": function ( data, type, row ) { return "<a onclick='removeSeedlot("+row.seedlot_stock_id+")' >X</a>"; } },
],

columns: [
{ title: "Seedlot Name", "data": null, "render": function ( data, type, row ) { return "<a href='/breeders/seedlot/"+row.seedlot_stock_id+"'>"+row.seedlot_stock_uniquename+"</a>"; } },
{ title: "Breeding Program", "data": "breeding_program_name" },
{ title: "Contents", "data": "contents_html" },
{ title: "Location", "data": "location" },
{ title: "Count", "data": "count" },
{ title: "Weight (g)", "data": "weight_gram" },
{ title: "Submitters", "data": "owners_string" },
{ title: "Organization", "data": "organization" },
{ title: "Box", "data": "box" },
{ title: "Quality", "data": "seedlot_quality" },
{ title: "Delete", "data": "null", "render": function ( data, type, row ) { return "<a onclick='removeSeedlot("+row.seedlot_stock_id+")' >X</a>"; } },
{ title: "", "data": "seedlot_stock_uniquename"}
],
'ajax': { 'url': '/ajax/breeders/seedlots',
'data': function(d) {
d.seedlot_name = jQuery('#search_seedlot_form_seedlot_name').val();
d.breeding_program = jQuery('#search_seedlot_form_breeding_program').val();
d.minimum_count = jQuery('#search_seedlot_form_minimum_count').val();
d.minimum_weight = jQuery('#search_seedlot_form_minimum_weight').val();
d.location = jQuery('#search_seedlot_form_location').val();
d.box_name = jQuery('#search_seedlot_form_box_name').val();
d.contents_accession = jQuery('#search_seedlot_form_contents_accession').val();
d.contents_cross = jQuery('#search_seedlot_form_contents_cross').val();
d.exact_accession = jQuery('#exact_accession').is(":checked") ? 1 : 0;
d.exact_cross = jQuery('#exact_cross').is(":checked") ? 1 : 0;
d.quality = jQuery('#search_seedlot_form_quality').val();
d.only_good_quality = jQuery('#search_seedlot_form_only_good_quality_checkbox').is(":checked") ? 1 : 0;
'data': function(d) {
d.seedlot_name = jQuery('#search_seedlot_form_seedlot_name').val();
d.breeding_program = jQuery('#search_seedlot_form_breeding_program').val();
d.minimum_count = jQuery('#search_seedlot_form_minimum_count').val();
d.minimum_weight = jQuery('#search_seedlot_form_minimum_weight').val();
d.location = jQuery('#search_seedlot_form_location').val();
d.box_name = jQuery('#search_seedlot_form_box_name').val();
d.contents_accession = jQuery('#search_seedlot_form_contents_accession').val();
d.contents_cross = jQuery('#search_seedlot_form_contents_cross').val();
d.exact_accession = jQuery('#exact_accession').is(":checked") ? 1 : 0;
d.exact_cross = jQuery('#exact_cross').is(":checked") ? 1 : 0;
d.quality = jQuery('#search_seedlot_form_quality').val();
d.only_good_quality = jQuery('#search_seedlot_form_only_good_quality_checkbox').is(":checked") ? 1 : 0;
}
},
});

seedlots_table.draw();
seedlots_table.column(11).visible(false);

}
},

"fnInitComplete": function(oSettings, json) {
if (!isLoggedIn()) {
jQuery('#available_seedlots_add_to_list').html("<div class='well well-sm'><h4>Please login to use lists!</h4></div>");
} else {
var html = "";
for (var i=0; i<json.data.length; i++ ) {
html += json.data[i].seedlot_stock_uniquename+"\n";
}
jQuery("#available_seedlots_to_list").html(html);
addToListMenu("available_seedlots_add_to_list", "available_seedlots_to_list", {
selectText: true,
listType: 'seedlots',
listName: 'seedlots'
});
});

}
}});
seedlots_table.draw();
});

//jQuery('#submit_seedlot_search').click( function() {
// seedlots_table.search("available_seedlots_table").draw();
//});
jQuery('#available_seedlots_table').on( 'draw.dt', function () {
var seedlot_names = seedlots_table.column(11).data();
var names = "";

for (var i = 0; i < seedlot_names.length; i++) {
names += seedlot_names[i]+'\n';
}

jQuery('#available_seedlots_to_list').html(names);
addToListMenu('available_seedlots_add_to_list', 'available_seedlots_to_list', {
listType: 'seedlots'
});
});

jQuery('#search_seedlot_form').keypress( function( e ) {
var code = e.keyCode || e.which;
if( code == 13 ) {
jQuery('#submit_seedlot_search').click();
}
});

});

function removeSeedlot(seedlot_stock_id){
Expand Down

0 comments on commit f6656a6

Please sign in to comment.