display obsoleted and current number of transformants
[sgn.git] / mason / breeders_toolbox / trialtreefolders.mas
blobb51ec09343cae8ed18b881bee7c59db10bd93722
2 <%args>
3 @locations => ()
4 $breeding_programs
5 $preferred_species
6 $editable_stock_props => {}
7 $editable_stock_props_definitions => {}
8 $timestamp
9 $management_factor_types => ()
10 $design_types => ()
11 </%args>
13 <& /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.GenotypingTrial','CXGN.BreedersToolbox.Accessions', 'CXGN.BreedersToolbox.UploadPedigrees','CXGN.BreedersToolbox.Crosses','CXGN.BreedersToolbox.FieldBook','CXGN.BreedersToolbox.UploadPhenotype', 'CXGN.BreederSearch', 'CXGN.Trial','CXGN.TrialTreeFolders' ] &>
15 <& /util/import_css.mas, paths => ['/static/documents/inc/jstree_theme/jstree-bstheme-min.css'] &>
17 <& /breeders_toolbox/folder/folder_set.mas, project_type => 'field_trial' &>
18 <& /breeders_toolbox/folder/folder_new.mas, project_type => 'field_trial' &>
19 <& /breeders_toolbox/folder/folder_move.mas, project_type => 'field_trial' &>
20 <& /breeders_toolbox/folder/folders_edit.mas, folder_tree_type => 'Trial', folder_tree_identifier => 'trial_list', folder_tree_refresh_name => 'refresh_jstree_html' &>
22 <& /breeders_toolbox/trial/trial_create_dialogs.mas, locations => \@locations, breeding_programs => $breeding_programs, management_factor_types => $management_factor_types, design_types => $design_types &>
24 <& /breeders_toolbox/trial/download_trials_phenotypes_dialog.mas &>
26 <& /breeders_toolbox/trial/trial_upload_dialogs.mas, locations => \@locations, breeding_programs => $breeding_programs, design_types => $design_types &>
27 <& /breeders_toolbox/add_accessions_dialogs.mas, preferred_species=>$preferred_species, editable_stock_props=>$editable_stock_props, editable_stock_props_definitions=>$editable_stock_props_definitions &>
28 <& /breeders_toolbox/upload_seedlots_dialogs.mas &>
29 <& /breeders_toolbox/add_seedlot_dialogs.mas, timestamp=>$timestamp &>
31 <table class="table table-bordered">
32   <thead>
33     <tr>
34       <th>Information</th>
35       <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>
36     </tr>
37   </thead>
38   <tbody>
39   <tr>
40     <td>
41         <h4>Search</h4>
42         <input type="text" class="form-control input-sm" id="trial_tree_search" placeholder="Search" />
43         <hr>
44       <h4>Download Trial Phenotypes</h4>
45       <h5><i>Select multiple trials by holding 'Ctrl'.</i></h5>
46       <button class="btn btn-primary" id="trials_download_phenotypes_button" disabled="disabled" title="First Select Trial(s) to Download">Download Phenotypes</button>
47       <hr>
48       <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>
49       <h5><i>Breeding programs (&nbsp;<span class="glyphicon glyphicon-briefcase text-info"></span>&nbsp;)</i></h5>
50       <h5><i>Analyses (&nbsp;<span class="glyphicon glyphicon-stats text-success"></span>&nbsp;)</i></h5>
51       <h5><i>Sampling trials (&nbsp;<span class="glyphicon glyphicon-th text-success"></span>&nbsp;)</i></h5>
52       <hr>
53       <h4>Folders</h4>
54       <button class="btn btn-sm btn-default" id="new_folder_dialog_link">Create new folder</button><br/><br/>
55       <button class="btn btn-sm btn-default" id="open_folder_dialog_link">Move trial(s) to folder</button><br/><br/>
56       <button class="btn btn-sm btn-default" id="move_folder_dialog_link">Move folder</button>
58       <div id="folder_edit_options" style="display:none">
59           <hr>
60           <h5><i>Select multiple folders by holding 'Ctrl'.</i></h5>
61           <button class="btn btn-primary" id="edit_folders_button" title="First Select Folder(s) to Edit">Edit Folder(s)</button>
62           <br/>
63       </div>
65       <!--<button id="delete" disabled="disabled" >Delete</button -->
66       <br />
67     </td>
68     <td>
69         <div id="trial_list" >[loading...]</div>
70     </td>
71   </tr>
72   </tbody>
73 </table>
76 <script>
78   jQuery.noConflict();
80   jQuery(document).ready(function($) {
82     jQuery.ajax( {
83       url: '/ajax/breeders/get_trials_with_folders_cached?type=trial',
84       success: function(response) {
85         var html = '<ul>'+response.html+'</ul>';
87         jQuery('#trial_list').html(html);
88         //console.log(html);
89         jQuery('#trial_list').jstree( {
90             "core": { 'themes': { 'name': 'proton', 'responsive': true}},
91             "valid_children" : [ "folder", "trial", "breeding_program", "analyses" ],
92             "types" : {
93                 "breeding_program" : {
94                     "icon": 'glyphicon glyphicon-briefcase text-info',
95                 },
96                 "folder" : {
97                     "icon": 'glyphicon glyphicon-folder-open text-danger',
98                 },
99                 "trial" : {
100                     "icon": 'glyphicon glyphicon-leaf text-success',
101                 },
102                 "analyses" : {
103                     "icon": 'glyphicon glyphicon-stats text-success',
104                 },
105                 "sampling_trial" : {
106                     "icon": 'glyphicon glyphicon-th text-success',
107                 },
108             },
109             "search" : {
110                  "case_insensitive" : true,
111              },
112           "plugins" : ["html_data","types","search"],
114         });
116       },
117       error: function(response) {
118         alert("An error occurred while loading the trial data.");
119       }
120   });
122   jQuery('#refresh_jstree_html_trialtree_button').click(function(){
123       jQuery.ajax( {
124         url: '/ajax/breeders/get_trials_with_folders_cached?type=trial',
125         success: function(response) {
126           var html = '<ul>'+response.html+'</ul>';
128           jQuery('#trial_list').html(html);
129           //console.log(html);
130           jQuery('#trial_list').jstree( {
131               "core": { 'themes': { 'name': 'proton', 'responsive': true}},
132               "valid_children" : [ "folder", "trial", "breeding_program", "analyses", "sampling_trial" ],
133               "types" : {
134                   "breeding_program" : {
135                       "icon": 'glyphicon glyphicon-briefcase text-info',
136                   },
137                   "folder" : {
138                       "icon": 'glyphicon glyphicon-folder-open text-danger',
139                   },
140                   "trial" : {
141                       "icon": 'glyphicon glyphicon-leaf text-success',
142                   },
143                   "analyses" : {
144                       "icon": 'glyphicon glyphicon-stats text-success',
145                   },
146                   "sampling_trial" : {
147                       "icon": 'glyphicon glyphicon-th text-success',
148                   }
149               },
150               "search" : {
151                    "case_insensitive" : true,
152                },
153             "plugins" : ["html_data","types","search"],
155           });
157         },
158         error: function(response) {
159           alert("An error occurred while loading the trial data.");
160         }
161     });
162   });
164     jQuery("#trial_tree_search").keyup(function() {
165         var v = jQuery("#trial_tree_search").val();
166         jQuery("#trial_list").jstree(true).search(v);
167     });
171   jQuery('#trial_list').on("changed.jstree", function (e, data) {
172     //console.log(data);
173        if ($('#trial_list').jstree('is_leaf', data.node) && data.node.data.jstree.type == 'trial') {
174          jQuery('#trials_download_phenotypes_button').removeAttr('disabled');
175          jQuery("#folder_edit_options").hide();
176        }
177        else if ($('#trial_list').jstree('is_leaf', data.node) && data.node.data.jstree.type == 'folder') {
178          jQuery('#trials_download_phenotypes_button').attr('disabled', 'disabled');
179          jQuery("#folder_edit_options").show();
180        }
181        else {
182          jQuery('#trials_download_phenotypes_button').attr('disabled', 'disabled');
183          jQuery("#folder_edit_options").hide();
184        }
185     });
188     $("#trial_list").delegate("li", "dblclick", function(event){
189       var node = $("#trial_list").jstree("get_node", this);
190       //console.log(node);
191       if (node.id.substr(0,1) !== 'j') {
192         if (node.type == 'folder') {
193             window.open('/folder/'+node.id);
194             event.stopPropagation();
195         } else if (node.type == 'breeding_program') {
196             window.open('/breeders/program/'+node.id);
197             event.stopPropagation();
198         } else if (node.type == 'analyses') {
199             window.open('/analyses/'+node.id);
200             event.stopPropagation();
201         } else if (node.type == 'trial') {
202             window.open('/breeders_toolbox/trial/'+node.id);
203             event.stopPropagation();
204         } else if (node.type == 'sampling_trial') {
205             window.open('/breeders_toolbox/trial/'+node.id);
206             event.stopPropagation();
207         }
208       }
209     });
210   });
212 </script>