Merge pull request #3313 from solgenomics/topic/add_pedigree_upload_header_check
[sgn.git] / mason / stock / related_stock.mas
blob2a564f2cb715a45d1ab6d1aa23911b6b10967569
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 % }
70 % 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'){
72     <&| /page/info_section.mas, id=>'related_stock_groups', title => 'Groups / members', collapsible=>1, collapsed=>1 &>
73         <div class="well well-sm">
74             <div class="panel panel-default">
75                 <div class="panel-body">
76                     <table id = "group" class="table table-hover table-striped">
77                         <thead>
78                         <tr>
79                             <th>Name</th>
80                             <th>Type</th>
81                         </tr>
82                         </thead>
83                     </table>
84                 </div>
85             </div>
87             <br>
88             <&| /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>'&>
89                 <br>
90                 <div style="text-align:right" id="groups_and_members_to_list_menu"></div>
91                 <div id="group_and_member_names" style="display: none;"></div>
92             </&>
93         </div>
94     </&>
96 % }
98 % if ($stock_type eq 'accession' || $stock_type eq 'plant' || $stock_type eq 'plot' || $stock_type eq 'subplot' || $stock_type eq 'tissue_sample'){
100     <&| /page/info_section.mas, id=>'related_stock_tissues', title => 'Related stocks for tissue sample', collapsible=>1, collapsed=>1 &>
101         <div class="well well-sm">
102             <div class="panel panel-default">
103                 <div class="panel-body">
104                     <table id = "tissue_sample" class="table table-hover table-striped">
105                         <thead>
106                         <tr>
107                             <th>Name</th>
108                             <th>Type</th>
109                         </tr>
110                         </thead>
111                     </table>
112                 </div>
113             </div>
115             <br>
116             <&| /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>'&>
117                 <br>
118                 <div style="text-align:right" id="tissue_samples_to_list_menu"></div>
119                 <div id="tissue_sample_names" style="display: none;"></div>
120             </&>
121         </div>
122     </&>
124 % }
126 <script>
128 jQuery(document).ready(function(){
131     jQuery('#related_stocks_in_trial_onswitch').one("click", function(){
132         var trial_stock_table = jQuery('#trial_related_stock').DataTable({
133             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/trial_related_stock',
134             "fnInitComplete": function(oSettings, json) {
135                 //console.log(json);
136                 if (!isLoggedIn()) {
137                     jQuery('#trial_stocks_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
138                 } else {
139                     var html = "";
140                     for(var i=0; i<json.data.length; i++){
141                         html += json.data[i][2]+"\n";
142                     }
143                     jQuery("#trial_stock_names").html(html);
144                     addToListMenu("trial_stocks_to_list_menu", "trial_stock_names", {
145                         selectText: true,
146                         listType:'null'
147                     });
148                 }
149             }
150         });
151     });
153     jQuery('#related_stock_progenies_onswitch').one("click", function(){
154         var progeny_table = jQuery('#progenies').DataTable({
155             'ordering': false,
156             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/progenies',
157             "fnInitComplete": function(oSettings, json) {
158                 //console.log(json);
159                 if (!isLoggedIn()) {
160                     jQuery('#progenies_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
161                 } else {
162                     var html = "";
163                     for(var i=0; i<json.data.length; i++){
164                         html += json.data[i][2]+"\n";
165                     }
166                     jQuery("#progeny_names").html(html);
167                     addToListMenu("progenies_to_list_menu", "progeny_names", {
168                         selectText: true,
169                         listType:'accessions'
170                     });
171                 }
172             }
173         });
174     });
176     jQuery('#related_stock_groups_onswitch').one("click", function(){
177         var group_and_member_table = jQuery('#group').DataTable({
178             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/group_and_member',
179             "fnInitComplete": function(oSettings, json) {
180                 //console.log(json);
181                 if (!isLoggedIn()) {
182                     jQuery('#groups_and_members_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
183                 } else {
184                     var html = "";
185                     for(var i=0; i<json.data.length; i++){
186                         html += json.data[i][2]+"\n";
187                     }
188                     jQuery("#group_and_member_names").html(html);
189                     addToListMenu("groups_and_members_to_list_menu", "group_and_member_names", {
190                         selectText: true,
191                         listType:'null'
192                     });
193                 }
194             }
195         });
196     });
198     jQuery('#related_stock_tissues_onswitch').one("click", function(){
199         var tissue_sample_table = jQuery('#tissue_sample').DataTable({
200             'ajax':'/stock/'+ <% $stock_id %> + '/datatables/stock_for_tissue',
201             "fnInitComplete": function(oSettings, json) {
202                 //console.log(json);
203                 if (!isLoggedIn()) {
204                     jQuery('#tissue_samples_to_list_menu').html("<div class='well well-sm'><h3>Please login to use lists!</h3></div>");
205                 } else {
206                     var html = "";
207                     for(var i=0; i<json.data.length; i++){
208                         html += json.data[i][2]+"\n";
209                     }
210                     jQuery("#tissue_sample_names").html(html);
211                     addToListMenu("tissue_samples_to_list_menu", "tissue_sample_names", {
212                         selectText: true,
213                         listType:'null'
214                     });
215                 }
216             }
217         });
218     });
225  </script>