message dialog and js
[sgn.git] / mason / stock / related_stock.mas
blob3c2fb86a9185d3a89e247b8fba586f3313bb84c3
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'){
10     <&| /page/info_section.mas, id=>'related_stocks_in_trial', title => 'Related stocks in trials', collapsible=>1, collapsed=>1 &>
11         <div class="well well-sm">
12             <div class="panel panel-default">
13                 <div class="panel-body">
14                     <table id = "trial_related_stock" class="table table-hover table-striped">
15                         <thead>
16                         <tr>
17                             <th>Name</th>
18                             <th>Type</th>
19                         </tr>
20                         </thead>
21                     </table>
22                 </div>
23             </div>
25             <br>
26             <&| /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>'&>
27                 <br>
28                 <div style="text-align:right" id="trial_stocks_to_list_menu"></div>
29                 <div id="trial_stock_names" style="display: none;"></div>
30             </&>
31         </div>
32     </&>
34 % }
36 % if ($stock_type eq 'accession'){
38     <& /breeders_toolbox/seedlots_section.mas, stock_id=>$stock_id, stock_type=>$stock_type, stock_uniquename=>$stock_uniquename &>
40 % }
42 % if ($stock_type eq 'accession'){
44     <&| /page/info_section.mas, id=>'related_stock_progenies', title => 'Progenies of this Accession (as female or male parent)', collapsible=>1, collapsed=>1 &>
45         <div class="well well-sm">
46             <div class="panel panel-default">
47                 <div class="panel-body">
48                     <table id = "progenies" class="table table-hover table-striped">
49                         <thead>
50                         <tr>
51                             <th>As female or male parent</th>
52                             <th>Progeny name</th>
53                         </tr>
54                         </thead>
55                     </table>
56                 </div>
57             </div>
59             <br>
60             <&| /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>'&>
61                 <br>
62                 <div style="text-align:right" id="progenies_to_list_menu"></div>
63                 <div id="progeny_names" style="display: none;"></div>
64             </&>
65         </div>
66     </&>
68     <&| /page/info_section.mas, id=>'related_stock_siblings', title => 'Siblings of this Accession', collapsible=>1, collapsed=>1 &>
69         <div class="well well-sm">
70             <div class="panel panel-default">
71                 <div class="panel-body">
72                     <table id = "siblings" class="table table-hover table-striped">
73                         <thead>
74                         <tr>
75                             <th>Accession Name</th>
76                             <th>Female Parent</th>
77                             <th>Male Parent</th>
78                             <th>Cross Type</th>
79                         </tr>
80                         </thead>
81                     </table>
82                 </div>
83             </div>
85             <br>
86             <&| /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>'&>
87                 <br>
88                 <div style="text-align:right" id="siblings_to_list_menu"></div>
89                 <div id="sibling_names" style="display: none;"></div>
90             </&>
91         </div>
92     </&>
94 % }
96 % 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'){
98     <&| /page/info_section.mas, id=>'related_stock_groups', title => 'Groups / members', collapsible=>1, collapsed=>1 &>
99         <div class="well well-sm">
100             <div class="panel panel-default">
101                 <div class="panel-body">
102                     <table id = "group" class="table table-hover table-striped">
103                         <thead>
104                         <tr>
105                             <th>Name</th>
106                             <th>Type</th>
107                         </tr>
108                         </thead>
109                     </table>
110                 </div>
111             </div>
113             <br>
114             <&| /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>'&>
115                 <br>
116                 <div style="text-align:right" id="groups_and_members_to_list_menu"></div>
117                 <div id="group_and_member_names" style="display: none;"></div>
118             </&>
119         </div>
120     </&>
122 % }
124 % if ($stock_type eq 'accession' || $stock_type eq 'plant' || $stock_type eq 'plot' || $stock_type eq 'subplot' || $stock_type eq 'tissue_sample'){
126     <&| /page/info_section.mas, id=>'related_stock_tissues', title => 'Related stocks for tissue sample', collapsible=>1, collapsed=>1 &>
127         <div class="well well-sm">
128             <div class="panel panel-default">
129                 <div class="panel-body">
130                     <table id = "tissue_sample" class="table table-hover table-striped">
131                         <thead>
132                         <tr>
133                             <th>Name</th>
134                             <th>Type</th>
135                         </tr>
136                         </thead>
137                     </table>
138                 </div>
139             </div>
141             <br>
142             <&| /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>'&>
143                 <br>
144                 <div style="text-align:right" id="tissue_samples_to_list_menu"></div>
145                 <div id="tissue_sample_names" style="display: none;"></div>
146             </&>
147         </div>
148     </&>
150 % }
152 <script>
154 jQuery(document).ready(function(){
157     jQuery('#related_stocks_in_trial_onswitch').one("click", function(){
158         var trial_stock_table = jQuery('#trial_related_stock').DataTable({
159             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/trial_related_stock',
160             "fnInitComplete": function(oSettings, json) {
161                 //console.log(json);
162                 if (!isLoggedIn()) {
163                     jQuery('#trial_stocks_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
164                 } else {
165                     var html = "";
166                     for(var i=0; i<json.data.length; i++){
167                         html += json.data[i][2]+"\n";
168                     }
169                     jQuery("#trial_stock_names").html(html);
170                     addToListMenu("trial_stocks_to_list_menu", "trial_stock_names", {
171                         selectText: true,
172                         listType:'null'
173                     });
174                 }
175             }
176         });
177     });
179     jQuery('#related_stock_progenies_onswitch').one("click", function(){
180         var progeny_table = jQuery('#progenies').DataTable({
181             'ordering': false,
182             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/progenies',
183             "fnInitComplete": function(oSettings, json) {
184                 //console.log(json);
185                 if (!isLoggedIn()) {
186                     jQuery('#progenies_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
187                 } else {
188                     var html = "";
189                     for(var i=0; i<json.data.length; i++){
190                         html += json.data[i][2]+"\n";
191                     }
192                     jQuery("#progeny_names").html(html);
193                     addToListMenu("progenies_to_list_menu", "progeny_names", {
194                         selectText: true,
195                         listType:'accessions'
196                     });
197                 }
198             }
199         });
200     });
202     jQuery('#related_stock_groups_onswitch').one("click", function(){
203         var group_and_member_table = jQuery('#group').DataTable({
204             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/group_and_member',
205             "fnInitComplete": function(oSettings, json) {
206                 //console.log(json);
207                 if (!isLoggedIn()) {
208                     jQuery('#groups_and_members_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
209                 } else {
210                     var html = "";
211                     for(var i=0; i<json.data.length; i++){
212                         html += json.data[i][2]+"\n";
213                     }
214                     jQuery("#group_and_member_names").html(html);
215                     addToListMenu("groups_and_members_to_list_menu", "group_and_member_names", {
216                         selectText: true,
217                         listType:'null'
218                     });
219                 }
220             }
221         });
222     });
224     jQuery('#related_stock_tissues_onswitch').one("click", function(){
225         var tissue_sample_table = jQuery('#tissue_sample').DataTable({
226             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/stock_for_tissue',
227             "fnInitComplete": function(oSettings, json) {
228                 //console.log(json);
229                 if (!isLoggedIn()) {
230                     jQuery('#tissue_samples_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
231                 } else {
232                     var html = "";
233                     for(var i=0; i<json.data.length; i++){
234                         html += json.data[i][2]+"\n";
235                     }
236                     jQuery("#tissue_sample_names").html(html);
237                     addToListMenu("tissue_samples_to_list_menu", "tissue_sample_names", {
238                         selectText: true,
239                         listType:'null'
240                     });
241                 }
242             }
243         });
244     });
247     jQuery('#related_stock_siblings_onswitch').one("click", function(){
248         var siblings_table = jQuery('#siblings').DataTable({
249             'ordering': false,
250             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/siblings',
251             "fnInitComplete": function(oSettings, json) {
252                 //console.log(json);
253                 if (!isLoggedIn()) {
254                     jQuery('#siblings_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
255                 } else {
256                     var html = "";
257                     for(var i=0; i<json.data.length; i++){
258                         html += json.data[i][4]+"\n";
259                     }
260                     jQuery("#sibling_names").html(html);
261                     addToListMenu("siblings_to_list_menu", "sibling_names", {
262                         selectText: true,
263                         listType:'accessions'
264                     });
265                 }
266             }
267         });
268     });
273 </script>