9 <& /util/import_javascript.mas, classes => [ 'jquery.iframe-post-form','CXGN.BreedersToolbox.AddTrial','CXGN.BreedersToolbox.UploadTrial','CXGN.BreedersToolbox.Trial', 'jstree.dist.jstree' ] &>
11 <& /breeders_toolbox/trial/trial_create_dialogs.mas, locations => \@locations, breeding_programs => $breeding_programs &>
12 <& /breeders_toolbox/trial/trial_upload_dialogs.mas, locations => \@locations, breeding_programs => $breeding_programs &>
14 <table class="table table-bordered">
18 <th>Breeding Programs -- -- Trials</th>
24 <h4>Download Trial</h4>
25 <button class="btn btn-primary" id="download_button" disabled="disabled" title="First Select a Trial to Download">Excel</button>
26 <button class="btn btn-primary" id="download_button_csv" disabled="disabled" title="First Select a Trial to Download">CSV</button><br />
28 <h5><i>Double click<br />trial to view</i></h5>
30 <button id="delete" disabled="disabled" >Delete</button -->
34 <div id="trial_list" >[loading...]</div>
45 jQuery(document).ready(function($) {
48 url: '/ajax/breeders/get_trials',
49 success: function(response) {
50 var html = format(response);
51 jQuery('#trial_list').html(html);
52 jQuery('#trial_list').jstree();
55 error: function(response) {
56 alert("An error occurred");
63 if(s.hasOwnProperty(k)) {
67 for (var n=0; n<s[k].length; n++) {
69 html += '<li id="'+s[k][n][0]+'">'+s[k][n][1]+"</li>";
83 $('#trial_list').on("changed.jstree", function (e, data) {
84 if ($('#trial_list').jstree('is_leaf', data.node)) {
85 $('#download_button').removeAttr('disabled');
86 $('#download_button_csv').removeAttr('disabled');
89 $('#download_button').attr('disabled', 'disabled');
90 $('#download_button_csv').attr('disabled', 'disabled');
97 $('#download_button').on('click', function () {
98 var selected = $('#trial_list').jstree('get_bottom_selected');
99 if (selected.length !== 0) {
100 window.open('/breeders/trials/phenotype/download/'+selected.join(","));
102 else { alert("No leaf nodes selected for download."); }
106 $('#download_button_csv').on('click', function () {
107 var selected = $('#trial_list').jstree('get_bottom_selected');
108 if (selected.length !== 0) {
109 window.open('/breeders/trials/phenotype/download/'+selected.join(",")+'?format=csv');
111 else { alert("No leaf nodes selected for download."); }
115 $("#trial_list").delegate("li", "dblclick", function(){
116 var node = $("#trial_list").jstree("get_node", this);
117 if ($('#trial_list').jstree('is_leaf', node) && node.id.substr(0,1) !== 'j') {
118 window.open('/breeders_toolbox/trial/'+node.id);