tweak multiple trait models output check..
[sgn.git] / mason / breeders_toolbox / trialtreefolders.mas
blobdd09ce74c7bf52d5b75d8663612a006bf730fc9a
2 <%args>
3 @locations => ()
4 $breeding_programs
5 $preferred_species
6 $editable_stock_props
7 $timestamp
8 </%args>
10 <& /util/import_javascript.mas, classes => [ 'jstree.dist.jstree', 'bootstrap_min.js', 'jquery.iframe-post-form', 'CXGN.List', 'CXGN.BreedersToolbox.AddTrial','CXGN.BreedersToolbox.UploadTrial','CXGN.BreedersToolbox.Trial', 'CXGN.Trial','CXGN.BreedersToolbox.AddMultipleTrial','CXGN.BreedersToolbox.GenotypingTrial','CXGN.BreedersToolbox.Accessions', 'CXGN.BreedersToolbox.UploadPedigrees','CXGN.BreedersToolbox.Crosses','CXGN.BreedersToolbox.FieldBook','CXGN.BreedersToolbox.UploadPhenotype', 'CXGN.BreederSearch', 'CXGN.Trial','CXGN.TrialTreeFolders' ] &>
12 <& /util/import_css.mas, paths => ['/static/documents/inc/jstree_theme/jstree-bstheme-min.css'] &>
14 <& /breeders_toolbox/folder/folder_set.mas, project_type => 'Trial' &>
15 <& /breeders_toolbox/folder/folder_new.mas &>
16 <& /breeders_toolbox/folder/folder_move.mas &>
17 <& /breeders_toolbox/folder/folders_edit.mas, folder_tree_type => 'Trial', folder_tree_identifier => 'trial_list', folder_tree_refresh_name => 'refresh_jstree_html' &>
19 <& /breeders_toolbox/trial/trial_create_dialogs.mas, locations => \@locations, breeding_programs => $breeding_programs &>
20 <& /breeders_toolbox/trial/trial_create_multiloc_dialogs.mas, locations => \@locations, breeding_programs => $breeding_programs &>
22 <& /breeders_toolbox/trial/download_trials_phenotypes_dialog.mas &>
24 <& /breeders_toolbox/trial/trial_upload_dialogs.mas, locations => \@locations, breeding_programs => $breeding_programs &>
25 <& /breeders_toolbox/add_accessions_dialogs.mas, preferred_species=>$preferred_species, editable_stock_props=>$editable_stock_props &>
26 <& /breeders_toolbox/upload_seedlots_dialogs.mas &>
27 <& /breeders_toolbox/add_seedlot_dialogs.mas, timestamp=>$timestamp &>
29 <table class="table table-bordered">
30   <thead>
31     <tr>
32       <th>Information</th>
33       <th>Breeding Programs -- Folders -- Trials&nbsp;&nbsp;&nbsp;&nbsp;<button class="btn btn-sm btn-default" id="refresh_jstree_html_trialtree_button" name="refresh_jstree_html">Refresh</button></th>
34     </tr>
35   </thead>
36   <tbody>
37   <tr>
38     <td>
39         <h4>Search</h4>
40         <input type="text" class="form-control input-sm" id="trial_tree_search" placeholder="Search" />
41         <hr>
42       <h4>Download Trial Phenotypes</h4>
43       <h5><i>Select multiple trials by holding 'Ctrl'.</i></h5>
44       <button class="btn btn-primary" id="trials_download_phenotypes_button" disabled="disabled" title="First Select Trial(s) to Download">Download Phenotypes</button>
45       <hr>
46       <h5><i>Double click<br />trial (&nbsp;<span class="glyphicon glyphicon-leaf text-success"></span>&nbsp;) or folder (&nbsp;<span class="glyphicon glyphicon-folder-open text-danger"></span>&nbsp;)<br/>to view detail page.</i></h5>
47       <h5><i>Breeding programs (&nbsp;<span class="glyphicon glyphicon-briefcase text-info"></span>&nbsp;)</i></h5>
48       <hr>
49       <h4>Folders</h4>
50       <button class="btn btn-sm btn-default" id="new_folder_dialog_link">Create new folder</button><br/><br/>
51       <button class="btn btn-sm btn-default" id="open_folder_dialog_link">Move trial(s) to folder</button><br/><br/>
52       <button class="btn btn-sm btn-default" id="move_folder_dialog_link">Move folder</button>
53       
54       <div id="folder_edit_options" style="display:none">
55           <hr>
56           <h5><i>Select multiple folders by holding 'Ctrl'.</i></h5>
57           <button class="btn btn-primary" id="edit_folders_button" title="First Select Folder(s) to Edit">Edit Folder(s)</button>
58           <br/>
59       </div>
61       <!--<button id="delete" disabled="disabled" >Delete</button -->
62       <br />
63     </td>
64     <td>
65         <div id="trial_list" >[loading...]</div>
66     </td>
67   </tr>
68   </tbody>
69 </table>
72 <script>
74   jQuery.noConflict();
76   jQuery(document).ready(function($) {
78     jQuery.ajax( {
79       url: '/ajax/breeders/get_trials_with_folders_cached?type=trial',
80       success: function(response) {
81         var html = '<ul>'+response.html+'</ul>';
83         jQuery('#trial_list').html(html);
84         //console.log(html);
85         jQuery('#trial_list').jstree( {
86             "core": { 'themes': { 'name': 'proton', 'responsive': true}},
87             "valid_children" : [ "folder", "trial", "breeding_program" ],
88             "types" : {
89                 "breeding_program" : {
90                     "icon": 'glyphicon glyphicon-briefcase text-info',
91                 },
92                 "folder" : {
93                     "icon": 'glyphicon glyphicon-folder-open text-danger',
94                 },
95                 "trial" : {
96                     "icon": 'glyphicon glyphicon-leaf text-success',
97                 }
98             },
99             "search" : {
100                  "case_insensitive" : true,
101              },
102           "plugins" : ["html_data","types","search"],
104         });
106       },
107       error: function(response) {
108         alert("An error occurred while loading the trial data.");
109       }
110   });
112     jQuery("#trial_tree_search").keyup(function() {
113         var v = jQuery("#trial_tree_search").val();
114         jQuery("#trial_list").jstree(true).search(v);
115     });
119   jQuery('#trial_list').on("changed.jstree", function (e, data) {
120     //console.log(data);
121        if ($('#trial_list').jstree('is_leaf', data.node) && data.node.data.jstree.type == 'trial') {
122          jQuery('#trials_download_phenotypes_button').removeAttr('disabled');
123          jQuery("#folder_edit_options").hide();
124        }
125        else if ($('#trial_list').jstree('is_leaf', data.node) && data.node.data.jstree.type == 'folder') {
126          jQuery('#trials_download_phenotypes_button').attr('disabled', 'disabled');
127          jQuery("#folder_edit_options").show();
128        }
129        else {
130          jQuery('#trials_download_phenotypes_button').attr('disabled', 'disabled');
131          jQuery("#folder_edit_options").hide();
132        }
133     });
136     $("#trial_list").delegate("li", "dblclick", function(event){
137       var node = $("#trial_list").jstree("get_node", this);
138       //console.log(node);
139       if (node.id.substr(0,1) !== 'j') {
140         if (node.type == 'folder') {
141             window.open('/folder/'+node.id);
142             event.stopPropagation();
143         } else if (node.type == 'trial') {
144             window.open('/breeders_toolbox/trial/'+node.id);
145             event.stopPropagation();
146         }
147       }
148     });
149   });
151 </script>