Changed trials-in-common page to use a single database query to get analyses. Changed...
[sgn.git] / mason / breeders_toolbox / genotyping_data_project / genotyping_project_tree.mas
blob65fcaea72e73420fae2e1b8db419f562a85b1b74
1 <%args>
2 @programs => ()
3 @locations => ()
4 $facilities
6 </%args>
8 <& /util/import_javascript.mas, classes => [ 'jquery.iframe-post-form', 'jstree.dist.jstree', 'CXGN.TrialTreeFolders'] &>
10 <& /util/import_css.mas, paths => ['/static/documents/inc/jstree_theme/jstree-bstheme-min.css'] &>
12 <& /breeders_toolbox/genotyping_trials/upload_genotyping_data_dialogs.mas, facilities => $facilities &>
13 <& /breeders_toolbox/genotyping_trials/create_genotyping_trial_dialogs.mas, facilities => $facilities &>
14 <& /breeders_toolbox/genotyping_data_project/create_genotyping_project_dialog.mas, facilities => $facilities &>
15 <& /breeders_toolbox/folder/folder_set.mas, project_type=>'genotyping_project' &>
16 <& /breeders_toolbox/folder/folder_new.mas, project_type=>'genotyping_project' &>
17 <& /breeders_toolbox/folder/folder_move.mas, project_type=>'genotyping_project' &>
18 <& /breeders_toolbox/folder/folders_edit.mas, folder_tree_type => 'genotyping_project', folder_tree_identifier => 'genotyping_project_list', folder_tree_refresh_name => 'refresh_genotyping_project_jstree_html' &>
20 <table class="table table-bordered">
21     <thead>
22         <tr>
23             <th>Information</th>
24             <th>Breeding Programs -- Folders -- Genotyping Projects&nbsp;&nbsp;&nbsp;&nbsp;<button class="btn btn-sm btn-default" id="refresh_genotyping_project_jstree_html_button" name="refresh_genotyping_project_jstree_html">Refresh</button></th>
25         </tr>
26     </thead>
27     <tbody>
28         <tr>
29             <td>
30                 <h4>Search</h4>
31                 <input type="text" class="form-control input-sm" id="genotyping_project_tree_search" placeholder="Search" />
32                 <hr>
34                 <h5><i>Double click<br />genotyping project (&nbsp;<span class="glyphicon glyphicon-align-left text-warning"></span>&nbsp;) or folder (&nbsp;<span class="glyphicon glyphicon-folder-open text-danger"></span>&nbsp;)<br/>to view detail page.</i></h5>
35                 <h5><i>Breeding programs (&nbsp;<span class="glyphicon glyphicon-briefcase text-info"></span>&nbsp;)</i></h5>
36                 <hr>
37                 <h4>Folders</h4>
38                 <button class="btn btn-sm btn-default" id="new_folder_dialog_link">Create new folder</button><br/><br/>
39                 <button class="btn btn-sm btn-default" id="open_folder_dialog_link">Move genotyping project(s) to folder</button><br/><br/>
40                 <button class="btn btn-sm btn-default" id="move_folder_dialog_link">Move folder</button>
42                 <div id="folder_edit_options" style="display:none">
43                     <hr>
44                     <h5><i>Select multiple folders by holding 'Ctrl'.</i></h5>
45                     <button class="btn btn-primary" id="edit_folders_button" title="First Select Folder(s) to Edit">Edit Folder(s)</button>
46                     <br/>
47                 </div>
49                 <!--<button id="delete" disabled="disabled" >Delete</button -->
50                 <br />
51             </td>
52             <td>
53                 <div id="genotyping_project_list" >[loading...]</div>
54             </td>
55         </tr>
56     </tbody>
57 </table>
60 <script>
62 jQuery.noConflict();
64 jQuery(document).ready(function($) {
66     jQuery.ajax( {
67         url: '/ajax/breeders/get_trials_with_folders_cached?type=genotyping_project',
68         success: function(response) {
69             var html = '<ul>'+response.html+'</ul>';
71             jQuery('#genotyping_project_list').html(html);
72             //console.log(html);
73             jQuery('#genotyping_project_list').jstree( {
74                 "core": { 'themes': { 'name': 'proton', 'responsive': true}},
75                 "valid_children" : [ "folder", "breeding_program", "genotyping_project"],
76                 "types" : {
77                     "breeding_program" : {
78                         "icon": 'glyphicon glyphicon-briefcase text-info',
79                     },
80                     "folder" : {
81                         "icon": 'glyphicon glyphicon-folder-open text-danger',
82                     },
83                     "genotyping_project" : {
84                         "icon": 'glyphicon glyphicon-align-left text-warning',
85                     },
86                 },
87                 "search" : {
88                     "case_insensitive" : true,
89                 },
90                 "plugins" : ["html_data","types","search"],
91             });
92         },
93         error: function(response) {
94             alert("An error occurred while loading the genotyping projects.");
95         }
96     });
98     jQuery("#genotyping_project_tree_search").keyup(function() {
99         var v = jQuery("#genotyping_project_tree_search").val();
100         jQuery("#genotyping_project_list").jstree(true).search(v);
101     });
103     jQuery("#genotyping_project_list").delegate("li", "dblclick", function(event){
104         var node = $("#genotyping_project_list").jstree("get_node", this);
105         if (node.id.substr(0,1) !== 'j') {
106             if (node.type == 'folder') {
107                 window.open('/folder/'+node.id);
108                 event.stopPropagation();
109             } else if (node.type == 'genotyping_project') {
110                 window.open('/breeders_toolbox/trial/'+node.id);
111                 event.stopPropagation();
112             }
113         }
114     });
118 </script>