specify folder type using project type
[sgn.git] / mason / breeders_toolbox / genotyping_trials / genotyping_trial_tree.mas
blob892b29f2c54b009849c7dffc11ac94029cb57c44
2 <%args>
3 </%args>
5 <& /util/import_javascript.mas, classes => [ 'jstree.dist.jstree', 'CXGN.TrialTreeFolders'] &>
7 <& /util/import_css.mas, paths => ['/static/documents/inc/jstree_theme/jstree-bstheme-min.css'] &>
9 <& /breeders_toolbox/folder/folder_set.mas, project_type=>'Genotyping Plate' &>
10 <& /breeders_toolbox/folder/folder_new.mas, project_type=>'genotyping_plate' &>
11 <& /breeders_toolbox/folder/folder_move.mas, project_type=>'Genotyping Plate' &>
12 <& /breeders_toolbox/folder/folders_edit.mas, folder_tree_type => 'Genotyping Plate', folder_tree_identifier => 'genotyping_trial_list', folder_tree_refresh_name => 'refresh_genotyping_trial_jstree_html' &>
14 <table class="table table-bordered">
15     <thead>
16         <tr>
17             <th>Information</th>
18             <th>Breeding Programs -- Folders -- Genotyping Plates&nbsp;&nbsp;&nbsp;&nbsp;<button class="btn btn-sm btn-default" id="refresh_genotyping_trial_jstree_html_trialtree_button" name="refresh_genotyping_trial_jstree_html">Refresh</button></th>
19         </tr>
20     </thead>
21     <tbody>
22         <tr>
23             <td>
24                 <h4>Search</h4>
25                 <input type="text" class="form-control input-sm" id="genotyping_trial_tree_search" placeholder="Search" />
26                 <hr>
28                 <h5><i>Double click<br />genotyping plate (&nbsp;<span class="glyphicon glyphicon-th text-success"></span>&nbsp;) or folder (&nbsp;<span class="glyphicon glyphicon-folder-open text-danger"></span>&nbsp;)<br/>to view detail page.</i></h5>
29                 <h5><i>Breeding programs (&nbsp;<span class="glyphicon glyphicon-briefcase text-info"></span>&nbsp;)</i></h5>
30                 <hr>
32                 <h4>Folders</h4>
33                 <button class="btn btn-sm btn-default" id="new_folder_dialog_link">Create new folder</button><br/><br/>
34                 <button class="btn btn-sm btn-default" id="open_folder_dialog_link">Move genotyping plate(s) to folder</button><br/><br/>
35                 <button class="btn btn-sm btn-default" id="move_folder_dialog_link">Move folder</button>
37                 <div id="folder_edit_options" style="display:none">
38                     <hr>
39                     <h5><i>Select multiple folders by holding 'Ctrl'.</i></h5>
40                     <button class="btn btn-primary" id="edit_folders_button" title="First Select Folder(s) to Edit">Edit Folder(s)</button>
41                     <br/>
42                 </div>
44                 <!--<button id="delete" disabled="disabled" >Delete</button -->
45                 <br />
46             </td>
47             <td>
48                 <div id="genotyping_trial_list" >[loading...]</div>
49             </td>
50         </tr>
51     </tbody>
52 </table>
55 <script>
57 jQuery.noConflict();
59 jQuery(document).ready(function($) {
61     jQuery.ajax( {
62       url: '/ajax/breeders/get_trials_with_folders_cached?type=genotyping_trial',
63       success: function(response) {
64         var html = '<ul>'+response.html+'</ul>';
66         jQuery('#genotyping_trial_list').html(html);
67         //console.log(html);
68         jQuery('#genotyping_trial_list').jstree( {
69             "core": { 'themes': { 'name': 'proton', 'responsive': true}},
70             "valid_children" : [ "folder", "genotyping_trial", "breeding_program" ],
71             "types" : {
72                 "breeding_program" : {
73                     "icon": 'glyphicon glyphicon-briefcase text-info',
74                 },
75                 "folder" : {
76                     "icon": 'glyphicon glyphicon-folder-open text-danger',
77                 },
78                 "genotyping_trial" : {
79                     "icon": 'glyphicon glyphicon-th text-success',
80                 }
81             },
82             "search" : {
83                  "case_insensitive" : true,
84              },
85           "plugins" : ["html_data","types","search"],
87         });
89       },
90       error: function(response) {
91         alert("An error occurred while loading the trial data.");
92       }
93   });
95     jQuery("#genotyping_trial_tree_search").keyup(function() {
96         var v = jQuery("#genotyping_trial_tree_search").val();
97         jQuery("#genotyping_trial_list").jstree(true).search(v);
98     });
100     jQuery('#genotyping_trial_list').on("changed.jstree", function (e, data) {
101         //console.log(data);
102         if ($('#trial_list').jstree('is_leaf', data.node) && data.node.data.jstree.type == 'folder') {
103             jQuery("#folder_edit_options").show();
104         }
105         else {
106             jQuery("#folder_edit_options").hide();
107         }
108     });
110     jQuery("#genotyping_trial_list").delegate("li", "dblclick", function(event){
111         var node = $("#genotyping_trial_list").jstree("get_node", this);
112         //console.log(node);
113         if (node.id.substr(0,1) !== 'j') {
114             if (node.type == 'folder') {
115                 window.open('/folder/'+node.id);
116                 event.stopPropagation();
117             } else if (node.type == 'genotyping_trial') {
118                 window.open('/breeders_toolbox/trial/'+node.id);
119                 event.stopPropagation();
120             }
121         }
122     });
126 </script>