Reset checked status when switching between lists
[sgn.git] / mason / stock / related_stock.mas
blobe91e2fcde48f670b8c925d6993f64aa42539af79
2 <%args>
3 $stock_id
4 $stock_uniquename => undef
5 $stock_type => undef
6 </%args>
8 % if ($stock_type eq 'accession' || $stock_type eq 'plant' || $stock_type eq 'plot' || $stock_type eq 'subplot' || $stock_type eq 'tissue_sample'){
9     <&| /page/info_section.mas, id=>'related_stocks_in_trial', title => 'Related stocks in trial', collapsible=>1, collapsed=>1 &>
10         <div class="well well-sm">
11             <div class="panel panel-default">
12                 <div class="panel-body">
13                     <table id = "trial_related_stock" class="table table-hover table-striped">
14                         <thead>
15                         <tr>
16                             <th>Type</th>
17                             <th>Name</th>
18                         </tr>
19                         </thead>
20                     </table>
21                 </div>
22             </div>
24             <br>
25             <&| /page/info_section.mas, title => 'Copy Stocks to a List', collapsible=>1, collapsed=>1, subtitle=>'<i>Copy the stock names showing in table to a new or exisiting list</i>'&>
26                 <br>
27                 <div style="text-align:right" id="trial_stocks_to_list_menu"></div>
28                 <div id="trial_stock_names" style="display: none;"></div>
29             </&>
30         </div>
31     </&>
32 % }
34 % if ($stock_type eq 'plot' || $stock_type eq 'plant'){
35     <&| /page/info_section.mas, id=>'related_seedlots', title => 'Related seedlots', collapsible=>1, collapsed=>1 &>
36         <div class="well well-sm">
37             <div class="panel panel-default">
38                 <div class="panel-body">
39                     <table id = "plot_plant_related_seedlots" class="table table-hover table-striped">
40                         <thead>
41                             <tr>
42                                 <th>Transaction Type</th>
43                                 <th>Stock Type</th>
44                                 <th>Name</th>
45                             </tr>
46                         </thead>
47                     </table>
48                 </div>
49             </div>
51             <br>
52             <&| /page/info_section.mas, title => 'Copy Stocks to a List', collapsible=>1, collapsed=>1, subtitle=>'<i>Copy the seedlot names showing in table to a new or exisiting list</i>'&>
53                 <br>
54                 <div style="text-align:right" id="seedlots_to_list_menu"></div>
55                 <div id="seedlot_names" style="display: none;"></div>
56             </&>
57         </div>
58     </&>
59 % }
61 % if ($stock_type eq 'accession') {
62     <& /breeders_toolbox/seedlots_section.mas, stock_id=>$stock_id, stock_type=>$stock_type, stock_uniquename=>$stock_uniquename &>
63 % }
65 % if ($stock_type eq 'accession' || $stock_type eq 'plant' || $stock_type eq 'plot' || $stock_type eq 'subplot'){
67     <&| /page/info_section.mas, id=>'related_stock_tissues', title => 'Related tissue samples', collapsible=>1, collapsed=>1 &>
68         <div class="well well-sm">
69             <div class="panel panel-default">
70                 <div class="panel-body">
71                     <table id = "tissue_sample" class="table table-hover table-striped">
72                         <thead>
73                         <tr>
74                             <th>Type</th>
75                             <th>Name</th>
76                         </tr>
77                         </thead>
78                     </table>
79                 </div>
80             </div>
82             <br>
83             <&| /page/info_section.mas, title => 'Copy Stocks to a List', collapsible=>1, collapsed=>1, subtitle=>'<i>Copy the stock names showing in table to a new or exisiting list</i>'&>
84                 <br>
85                 <div style="text-align:right" id="tissue_samples_to_list_menu"></div>
86                 <div id="tissue_sample_names" style="display: none;"></div>
87             </&>
88         </div>
89     </&>
91 % }
93 % if ($stock_type eq 'accession'){
95     <&| /page/info_section.mas, id=>'related_stock_progenies', title => 'Progenies of this Accession (as female or male parent)', collapsible=>1, collapsed=>1 &>
96         <div class="well well-sm">
97             <div class="panel panel-default">
98                 <div class="panel-body">
99                     <table id = "progenies" class="table table-hover table-striped">
100                         <thead>
101                         <tr>
102                             <th>As female or male parent</th>
103                             <th>Cross type</th>
104                             <th>Progeny name</th>
105                         </tr>
106                         </thead>
107                     </table>
108                 </div>
109             </div>
111             <br>
112             <&| /page/info_section.mas, title => 'Copy Stocks to a List', collapsible=>1, collapsed=>1, subtitle=>'<i>Copy the stock names showing in table to a new or exisiting list</i>'&>
113                 <br>
114                 <div style="text-align:right" id="progenies_to_list_menu"></div>
115                 <div id="progeny_names" style="display: none;"></div>
116             </&>
117         </div>
118     </&>
121 <&| /page/info_section.mas, id=>'related_stock_parents', title => 'Parents of this Accession', collapsible=>1, collapsed=>1 &>
122         <div class="well well-sm">
123             <div class="panel panel-default">
124                 <div class="panel-body">
125                     <table id = "parents" class="table table-hover table-striped">
126                         <thead>
127                         <tr>
128                             <th>Female Parent</th>
129                             <th>Male Parent</th>
130                             <th>Cross Type</th>
131                         </tr>
132                         </thead>
133                     </table>
134                 </div>
135             </div>
137         </div>
138     </&>
143     <&| /page/info_section.mas, id=>'related_stock_siblings', title => 'Siblings of this Accession', collapsible=>1, collapsed=>1 &>
144         <div class="well well-sm">
145             <div class="panel panel-default">
146                 <div class="panel-body">
147                     <table id = "siblings" class="table table-hover table-striped">
148                         <thead>
149                         <tr>
150                             <th>Accession Name</th>
151                             <th>Female Parent</th>
152                             <th>Male Parent</th>
153                             <th>Cross Type</th>
154                         </tr>
155                         </thead>
156                     </table>
157                 </div>
158             </div>
160             <br>
161             <&| /page/info_section.mas, title => 'Copy siblings to a List', collapsible=>1, collapsed=>1, subtitle=>'<i>Copy the sibling names showing in table to a new or exisiting list</i>'&>
162                 <br>
163                 <div style="text-align:right" id="siblings_to_list_menu"></div>
164                 <div id="sibling_names" style="display: none;"></div>
165             </&>
166         </div>
167     </&>
169 % }
171 % if ($stock_type eq 'accession' || $stock_type eq 'backcross population' || $stock_type eq 'f2 population' || $stock_type eq 'mutant population' || $stock_type eq 'population' || $stock_type eq 'training population'){
173     <&| /page/info_section.mas, id=>'related_stock_groups', title => 'Groups / members', collapsible=>1, collapsed=>1 &>
174         <div class="well well-sm">
175             <div class="panel panel-default">
176                 <div class="panel-body">
177                     <table id = "group" class="table table-hover table-striped">
178                         <thead>
179                         <tr>
180                             <th>Name</th>
181                             <th>Type</th>
182                         </tr>
183                         </thead>
184                     </table>
185                 </div>
186             </div>
188             <br>
189             <&| /page/info_section.mas, title => 'Copy Stocks to a List', collapsible=>1, collapsed=>1, subtitle=>'<i>Copy the stock names showing in table to a new or exisiting list</i>'&>
190                 <br>
191                 <div style="text-align:right" id="groups_and_members_to_list_menu"></div>
192                 <div id="group_and_member_names" style="display: none;"></div>
193             </&>
194         </div>
195     </&>
197 % }
200 <script>
202 jQuery(document).ready(function(){
205     jQuery('#related_stocks_in_trial_onswitch').one("click", function(){
206         var trial_stock_table = jQuery('#trial_related_stock').DataTable({
207             'order': false,
208             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/trial_related_stock',
209             "fnInitComplete": function(oSettings, json) {
210                 //console.log(json);
211                 if (!isLoggedIn()) {
212                     jQuery('#trial_stocks_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
213                 } else {
214                     var html = "";
215                     for(var i=0; i<json.data.length; i++){
216                         html += json.data[i][2]+"\n";
217                     }
218                     jQuery("#trial_stock_names").html(html);
219                     addToListMenu("trial_stocks_to_list_menu", "trial_stock_names", {
220                         selectText: true,
221                         listType:'null'
222                     });
223                 }
224             }
225         });
226     });
228     jQuery('#related_seedlots_onswitch').one("click", function(){
229         var related_seedlots_table = jQuery('#plot_plant_related_seedlots').DataTable({
230             'order': false,
231             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/plot_plant_related_seedlots',
232             "fnInitComplete": function(oSettings, json) {
233                 //console.log(json);
234                 if (!isLoggedIn()) {
235                     jQuery('#seedlots_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
236                 } else {
237                     var html = "";
238                     for(var i=0; i<json.data.length; i++){
239                         html += json.data[i][3]+"\n";
240                     }
241                     jQuery("#seedlot_names").html(html);
242                     addToListMenu("seedlots_to_list_menu", "seedlot_names", {
243                         selectText: true,
244                         listType:'seedlots'
245                     });
246                 }
247             }
248         });
249     });
251     jQuery('#related_stock_progenies_onswitch').one("click", function(){
252         var progeny_table = jQuery('#progenies').DataTable({
253             'ordering': false,
254             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/progenies',
255             "fnInitComplete": function(oSettings, json) {
256                 //console.log(json);
257                 if (!isLoggedIn()) {
258                     jQuery('#progenies_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
259                 } else {
260                     var html = "";
261                     for(var i=0; i<json.data.length; i++){
262                         html += json.data[i][3]+"\n";
263                     }
264                     jQuery("#progeny_names").html(html);
265                     addToListMenu("progenies_to_list_menu", "progeny_names", {
266                         selectText: true,
267                         listType:'accessions'
268                     });
269                 }
270             }
271         });
272     });
274     jQuery('#related_stock_groups_onswitch').one("click", function(){
275         var group_and_member_table = jQuery('#group').DataTable({
276             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/group_and_member',
277             "fnInitComplete": function(oSettings, json) {
278                 //console.log(json);
279                 if (!isLoggedIn()) {
280                     jQuery('#groups_and_members_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
281                 } else {
282                     var html = "";
283                     for(var i=0; i<json.data.length; i++){
284                         html += json.data[i][2]+"\n";
285                     }
286                     jQuery("#group_and_member_names").html(html);
287                     addToListMenu("groups_and_members_to_list_menu", "group_and_member_names", {
288                         selectText: true,
289                         listType:'null'
290                     });
291                 }
292             }
293         });
294     });
296     jQuery('#related_stock_tissues_onswitch').one("click", function(){
297         var tissue_sample_table = jQuery('#tissue_sample').DataTable({
298             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/stock_for_tissue',
299             "fnInitComplete": function(oSettings, json) {
300                 //console.log(json);
301                 if (!isLoggedIn()) {
302                     jQuery('#tissue_samples_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
303                 } else {
304                     var html = "";
305                     for(var i=0; i<json.data.length; i++){
306                         html += json.data[i][2]+"\n";
307                     }
308                     jQuery("#tissue_sample_names").html(html);
309                     addToListMenu("tissue_samples_to_list_menu", "tissue_sample_names", {
310                         selectText: true,
311                         listType:'tissue_samples'
312                     });
313                 }
314             }
315         });
316     });
319     jQuery('#related_stock_siblings_onswitch').one("click", function(){
320         var siblings_table = jQuery('#siblings').DataTable({
321             'ordering': false,
322             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/siblings',
323             "fnInitComplete": function(oSettings, json) {
324                 //console.log(json);
325                 if (!isLoggedIn()) {
326                     jQuery('#siblings_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
327                 } else {
328                     var html = "";
329                     for(var i=0; i<json.data.length; i++){
330                         html += json.data[i][4]+"\n";
331                     }
332                     jQuery("#sibling_names").html(html);
333                     addToListMenu("siblings_to_list_menu", "sibling_names", {
334                         selectText: true,
335                         listType:'accessions'
336                     });
337                 }
338             }
339         });
340     });
342         jQuery('#related_stock_parents_onswitch').one("click", function(){
343         var siblings_table = jQuery('#parents').DataTable({
344             'ordering': false,
345             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/parents',
346             // "fnInitComplete": function(oSettings, json) {
347             //     //console.log(json);
348             //     if (!isLoggedIn()) {
349             //         jQuery('#siblings_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
350             //     } else {
351             //         var html = "";
352             //         for(var i=0; i<json.data.length; i++){
353             //             html += json.data[i][4]+"\n";
354             //         }
355             //         jQuery("#sibling_names").html(html);
356             //         addToListMenu("siblings_to_list_menu", "sibling_names", {
357             //             selectText: true,
358             //             listType:'accessions'
359             //         });
360             //     }
361             // }
362         });
363     });
369 </script>