8 <& /util/import_javascript.mas, classes => [ 'jquery.iframe-post-form','CXGN.BreedersToolbox.AddTrial','CXGN.BreedersToolbox.UploadTrial','CXGN.BreedersToolbox.Trial', 'jstree.dist.jstree' ] &>
10 <& /breeders_toolbox/trial/trial_create_dialogs.mas, locations => \@locations, breeding_programs => $breeding_programs &>
11 <& /breeders_toolbox/trial/trial_upload_dialogs.mas, locations => \@locations, breeding_programs => $breeding_programs &>
13 <table class="table table-bordered">
17 <th>Breeding Programs -- -- Trials</th>
23 <h4>Download Trial</h4>
24 <button class="btn btn-primary" id="download_button" disabled="disabled" title="First Select a Trial to Download">Excel</button>
25 <button class="btn btn-primary" id="download_button_csv" disabled="disabled" title="First Select a Trial to Download">CSV</button><br />
27 <h5><i>Double click<br />trial to view</i></h5>
29 <button id="delete" disabled="disabled" >Delete</button -->
33 <div id="trial_list" >[loading...]</div>
44 jQuery(document).ready(function($) {
47 url: '/ajax/breeders/get_trials',
48 success: function(response) {
49 var html = format(response);
50 jQuery('#trial_list').html(html);
51 jQuery('#trial_list').jstree();
54 error: function(response) {
55 alert("An error occurred");
62 if(s.hasOwnProperty(k)) {
66 for (var n=0; n<s[k].length; n++) {
68 html += '<li id="'+s[k][n][0]+'">'+s[k][n][1]+"</li>";
82 $('#trial_list').on("changed.jstree", function (e, data) {
83 if ($('#trial_list').jstree('is_leaf', data.node)) {
84 $('#download_button').removeAttr('disabled');
85 $('#download_button_csv').removeAttr('disabled');
88 $('#download_button').attr('disabled', 'disabled');
89 $('#download_button_csv').attr('disabled', 'disabled');
96 $('#download_button').on('click', function () {
97 var selected = $('#trial_list').jstree('get_bottom_selected');
98 if (selected.length !== 0) {
99 window.open('/breeders/trials/phenotype/download/'+selected.join(","));
101 else { alert("No leaf nodes selected for download."); }
105 $('#download_button_csv').on('click', function () {
106 var selected = $('#trial_list').jstree('get_bottom_selected');
107 if (selected.length !== 0) {
108 window.open('/breeders/trials/phenotype/download/'+selected.join(",")+'?format=csv');
110 else { alert("No leaf nodes selected for download."); }
114 $("#trial_list").delegate("li", "dblclick", function(){
115 var node = $("#trial_list").jstree("get_node", this);
116 if ($('#trial_list').jstree('is_leaf', node) && node.id.substr(0,1) !== 'j') {
117 window.open('/breeders_toolbox/trial/'+node.id);