4 <& /util/import_javascript.mas, classes => [ 'CXGN.BreedersToolbox.GenotypingTrial' ] &>
6 <div class="modal fade" id="tissue_sample_help_dialog" name="tissue_sample_help_dialog" tabindex="-1" role="dialog" aria-labelledby="tissueSampleHelpDialog">
7 <div class="modal-dialog modal-xl" role="document">
8 <div class="modal-content">
9 <div class="modal-header">
10 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
11 <h4 class="modal-title" id="tissueSampleHelpDialog">Tissue Sampling</h4>
13 <div class="modal-body">
15 <div class="container-fluid">
17 <&| /util/workflow.mas, id=> "tissue_sample_help_workflow" &>
18 <&| /util/workflow.mas:step, title=> "Intro" &>
19 <& /page/page_title.mas, title=>"This workflow will guide you through tissue sampling an experiment" &>
20 <p>Tissue samples collected from the field are linked to a single plant, which is in turn linked to a single plot.</p>
21 <p>Many tissue samples can be created for each plant.</p>
22 <p>Each tissue sample has a globally unique name.</p>
24 <p>A unique tissue sample is present in each well of a genotyping plate (96 or 384 well plates).</p>
25 <p>The tissue sample in a 96 well plate can originate from another tissue sample name, plant name, plot name, or accession name.</p>
29 <button class="btn btn-primary" onclick="Workflow.complete(this); return false;">Go to Next Step</button>
33 <&| /util/workflow.mas:step, title=> "Sampling Level" &>
34 <& /page/page_title.mas, title=>"At which level do you plan to keep track of your sampling?" &>
36 <input type="radio" name="tissue_sample_help_select_level" value="accession"> Accession Level: The sample is not from a field trial entity and only the accession name is known.<br/>
37 <input type="radio" name="tissue_sample_help_select_level" value="plot"> Plot Level: Each plot in the field has a unique identifier, ideally with a barcode label.<br/>
38 <input type="radio" name="tissue_sample_help_select_level" value="plant"> Plant Level: Each plant in the field has a unique identifier, ideally with a barcode label.<br/>
39 <input type="radio" name="tissue_sample_help_select_level" value="tissue_sample"> Tissue Sample Level: Each tissue sample collected from the field has a unique identifier, ideally with a barcode label.
43 <button class="btn btn-primary" id="tissue_sample_help_select_level_submit">Go to Next Step</button>
46 <&| /util/workflow.mas:step, title=> "Select a field trial" &>
47 <& /page/page_title.mas, title=>"Select a field trial" &>
49 <div id="tissue_sample_help_trial_select_not_relevant" style="display:none">
50 <h4>Field trial is not relevant for the type of tissue sampling you selected. Go to next step.</h4>
52 <button class="btn btn-primary" onclick="Workflow.complete(this); return false;">Go to Next Step</button>
55 <div id="tissue_sample_help_trial_select_relevant" style="display:none">
56 <div class="well well-sm">
57 <div class="panel panel-default">
58 <div class="panel-body">
59 <table id="tissue_sample_help_field_search_results" class="table table-hover table-striped">
65 <th>Breeding program</th>
71 <th>Planting Date</th>
83 <button class="btn btn-primary" id="tissue_sample_help_select_trial_submit">Go to Next Step</button>
88 <&| /util/workflow.mas:step, title=> "Plant Entries" &>
89 <& /page/page_title.mas, title=>"Plant entries in your field trial" &>
91 <div id="tissue_sample_help_plant_entries_not_relevant" style="display:none">
92 <h4>Plant entries not relevant for the type of tissue sampling you selected. Go to next step.</h4>
94 <button class="btn btn-primary" onclick="Workflow.complete(this); return false;">Go to Next Step</button>
97 <div id="tissue_sample_help_plant_entries_exist_section" style="display:none">
98 <h4>Plant entries exist for this trial. Go to next step.</h4>
100 <button class="btn btn-primary" onclick="Workflow.complete(this); return false;">Go to Next Step</button>
103 <div id="tissue_sample_help_plant_entries_dont_exist_section" style="display:none">
104 <h4>Please create plant entries for this trial.</h4>
105 <form class="form-horizontal">
106 <div class="form-group">
107 <label class="col-sm-3 control-label">Number of plants per plot: </label>
108 <div class="col-sm-9" >
109 <input name="tissue_sample_help_plants_per_plot_num" id="tissue_sample_help_plants_per_plot_num" class="form-control" type="number" autofocus/>
112 <div class="form-group">
113 <label class="col-sm-3 control-label">Inherits Management Factor(s) From Plots: </label>
114 <div class="col-sm-9" >
115 <input name="tissue_sample_help_plants_per_plot_inherit_treatments" id="tissue_sample_help_plants_per_plot_inherit_treatments" type="checkbox" checked disabled/>
120 <button type="button" class="btn btn-primary" id="tissue_sample_help_plants_per_plot_submit">Submit</button>
125 <&| /util/workflow.mas:step, title=> "Create Tissue Sample Entries" &>
126 <& /page/page_title.mas, title=>"Create tissue sample entries for this trial" &>
128 <div id="tissue_sample_help_tissue_samples_not_relevant" style="display:none">
129 <h4>Field trial tissue sample entries not relevant for the type of tissue sampling you selected. Go to next step.</h4>
131 <button class="btn btn-primary" onclick="Workflow.complete(this); return false;">Go to Next Step</button>
134 <div id="tissue_sample_help_tissue_samples_exist_section" style="display:none">
135 <h4>Tissue sample entries exist for this trial. Go to next step.</h4>
137 <button class="btn btn-primary" onclick="Workflow.complete(this); return false;">Go to Next Step</button>
140 <div id="tissue_sample_help_tissue_samples_relevant" style="display:none">
141 <form class="form-horizontal" >
142 <div class="form-group">
143 <label class="col-sm-3 control-label"><span title="You can use the same tissue name, e.g. root and root, more than once below. The tissue name will still be unique because of a tissue index e.g. 1 and 2 added to the end." </span><span class="glyphicon glyphicon-info-sign"></span> Number of tissue samples per plant: </span></label>
144 <div class="col-sm-9" >
145 <input name="tissue_sample_help_tissue_samples_per_plant_num" id="tissue_sample_help_tissue_samples_per_plant_num" class="form-control" type="number" autofocus/>
149 <div id="tissue_sample_help_tissue_samples_names_div">
152 <div class="form-group">
153 <label class="col-sm-3 control-label">Inherits Management Factor(s) From Plots: </label>
154 <div class="col-sm-9" >
155 <input name="tissue_sample_help_per_plant_inherit_treatments" id="tissue_sample_help_per_plant_inherit_treatments" type="checkbox" checked disabled/>
161 <button type="button" class="btn btn-primary" name="tissue_sample_help_per_plant_submit" id="tissue_sample_help_per_plant_submit">Submit</button>
165 <&| /util/workflow.mas:complete, title=> "Complete" &>
166 <& /page/page_title.mas, title=>"Complete! You have all the entities you need to conduct your sampling." &>
168 <li>All of the entities that you want to sample are saved in the database and available to use!</li>
169 <li>You can print barcodes for the entities you intend to sample on. These barcodes can be attached to your collection vials/containers to assist during sampling.</li>
172 <button class="btn btn-primary" onclick="final_download_layout_button_click()">Download Field Trial Layout!</button>
177 <li>After you have finished sampling, you can use these entities as source material for a genotyping plate (96 or 384 well plate). Click the button below to create a genotyping plate now, if you will create a 96 or 384 well plate.</li>
178 <li>The Android Coordinate application can help you create 96 or 384 well plates. Alternatively you can create your plate layout in Excel and upload it.</li>
181 <button class="btn btn-primary" name="create_genotyping_trial_link">Create Genotyping Plate Now!</button>
188 <div class="modal-footer">
189 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
200 jQuery(document).ready(function(){
202 jQuery('button[name="tissue_sample_guided_help"]').click(function(){
203 jQuery('#tissue_sample_help_dialog').modal('show');
206 var tissue_sample_help_trial_table = jQuery('#tissue_sample_help_field_search_results').DataTable( {
208 'url':'/ajax/search/trials',
209 'data': function(d) {
210 d.select_checkbox_name = 'tissue_sample_help_select_trial_checkbox';
216 jQuery('#tissue_sample_help_select_level_submit').click(function(){
217 selected_level = jQuery('input[name="tissue_sample_help_select_level"]:checked').val();
218 if (selected_level == '' || !selected_level){
219 alert('Please select one');
221 Workflow.complete('#tissue_sample_help_select_level_submit');
222 if (selected_level == 'accession'){
223 jQuery('#tissue_sample_help_plant_entries_not_relevant').show();
224 jQuery('#tissue_sample_help_plant_entries_exist_section').hide();
225 jQuery('#tissue_sample_help_plant_entries_dont_exist_section').hide();
226 jQuery('#tissue_sample_help_trial_select_not_relevant').show();
227 jQuery('#tissue_sample_help_trial_select_relevant').hide();
228 jQuery('#tissue_sample_help_tissue_samples_not_relevant').show();
229 jQuery('#tissue_sample_help_tissue_samples_relevant').hide();
230 Workflow.skip('#tissue_sample_help_select_trial_submit');
231 Workflow.skip('#tissue_sample_help_plants_per_plot_submit');
232 Workflow.skip('#tissue_sample_help_per_plant_submit');
233 Workflow.focus("#tissue_sample_help_workflow", -1);
235 jQuery('#tissue_sample_help_plant_entries_not_relevant').hide();
236 jQuery('#tissue_sample_help_plant_entries_exist_section').hide();
237 jQuery('#tissue_sample_help_plant_entries_dont_exist_section').hide();
238 jQuery('#tissue_sample_help_trial_select_not_relevant').hide();
239 jQuery('#tissue_sample_help_trial_select_relevant').show();
240 jQuery('#tissue_sample_help_tissue_samples_not_relevant').hide();
241 jQuery('#tissue_sample_help_tissue_samples_relevant').hide();
242 jQuery('#tissue_sample_help_tissue_samples_exist_section').hide();
243 Workflow.focus("#tissue_sample_help_workflow", 2);
248 jQuery('#tissue_sample_help_select_trial_submit').click(function(){
250 jQuery('input[name="tissue_sample_help_select_trial_checkbox"]:checked').each(function() {
251 selected.push(jQuery(this).val());
253 selected_level = jQuery('input[name="tissue_sample_help_select_level"]:checked').val();
254 if (selected.length !== 1){
255 alert('Only select one trial!');
257 Workflow.complete('#tissue_sample_help_select_trial_submit');
258 if (selected_level == 'plot'){
259 jQuery('#tissue_sample_help_plant_entries_not_relevant').show();
260 jQuery('#tissue_sample_help_plant_entries_exist_section').hide();
261 jQuery('#tissue_sample_help_plant_entries_dont_exist_section').hide();
262 jQuery('#tissue_sample_help_tissue_samples_not_relevant').show();
263 jQuery('#tissue_sample_help_tissue_samples_relevant').hide();
264 Workflow.skip('#tissue_sample_help_plants_per_plot_submit');
265 Workflow.skip('#tissue_sample_help_per_plant_submit');
266 Workflow.focus("#tissue_sample_help_workflow", -1);
270 url: '/ajax/breeders/trial/'+selected[0]+'/has_plants',
272 beforeSend: function() {
273 jQuery("#working_modal").modal("show");
275 success: function (response) {
276 jQuery("#working_modal").modal("hide");
277 if (response.has_plants){
278 jQuery('#tissue_sample_help_plant_entries_exist_section').show();
279 jQuery('#tissue_sample_help_plant_entries_dont_exist_section').hide();
280 Workflow.complete('#tissue_sample_help_select_trial_submit');
281 Workflow.skip('#tissue_sample_help_plant_entries_exist_section');
282 if (selected_level == 'plant'){
283 jQuery('#tissue_sample_help_tissue_samples_not_relevant').show();
284 jQuery('#tissue_sample_help_tissue_samples_relevant').hide();
285 Workflow.skip('#tissue_sample_help_per_plant_submit');
286 Workflow.focus("#tissue_sample_help_workflow", -1);
290 url: '/ajax/breeders/trial/'+selected[0]+'/has_tissue_samples',
292 beforeSend: function() {
293 jQuery("#working_modal").modal("show");
295 success: function (response) {
296 jQuery("#working_modal").modal("hide");
297 if (response.has_tissue_samples){
298 jQuery('#tissue_sample_help_tissue_samples_not_relevant').hide();
299 jQuery('#tissue_sample_help_tissue_samples_relevant').hide();
300 jQuery('#tissue_sample_help_tissue_samples_exist_section').show();
301 Workflow.skip('#tissue_sample_help_per_plant_submit');
302 Workflow.focus("#tissue_sample_help_workflow", -1);
304 jQuery('#tissue_sample_help_tissue_samples_not_relevant').hide();
305 jQuery('#tissue_sample_help_tissue_samples_relevant').show();
306 jQuery('#tissue_sample_help_tissue_samples_exist_section').hide();
307 Workflow.focus("#tissue_sample_help_workflow", 4);
311 jQuery("#working_modal").modal("hide");
312 alert('An error occurred checking trial for tissue samples.');
317 jQuery('#tissue_sample_help_plant_entries_dont_exist_section').show();
318 jQuery('#tissue_sample_help_plant_entries_exist_section').hide();
319 Workflow.complete('#tissue_sample_help_select_trial_submit');
320 Workflow.focus("#tissue_sample_help_workflow", 3);
324 jQuery("#working_modal").modal("hide");
325 alert('An error occurred checking trial for plants.');
333 jQuery('#tissue_sample_help_plants_per_plot_submit').click(function(){
335 if(jQuery('#tissue_sample_help_plants_per_plot_inherit_treatments').is(":checked")){
340 url: '/ajax/breeders/trial/'+selected[0]+'/create_plant_entries/',
342 beforeSend: function() {
343 jQuery("#working_modal").modal("show");
346 'plants_per_plot' : jQuery('#tissue_sample_help_plants_per_plot_num').val(),
347 'inherits_plot_treatments' : is_checked
349 success: function(response) {
350 jQuery("#working_modal").modal("hide");
351 if (response.error) {
352 alert(response.error);
355 alert("Successfully created plant entries.");
356 Workflow.complete('#tissue_sample_help_plants_per_plot_submit');
357 if (selected_level == 'plant'){
358 jQuery('#tissue_sample_help_tissue_samples_not_relevant').show();
359 jQuery('#tissue_sample_help_tissue_samples_relevant').hide();
360 Workflow.skip('#tissue_sample_help_per_plant_submit');
361 Workflow.focus("#tissue_sample_help_workflow", -1);
365 url: '/ajax/breeders/trial/'+selected[0]+'/has_tissue_samples',
367 beforeSend: function() {
368 jQuery("#working_modal").modal("show");
370 success: function (response) {
371 jQuery("#working_modal").modal("hide");
372 if (response.has_tissue_samples){
373 jQuery('#tissue_sample_help_tissue_samples_not_relevant').hide();
374 jQuery('#tissue_sample_help_tissue_samples_relevant').hide();
375 jQuery('#tissue_sample_help_tissue_samples_exist_section').show();
376 Workflow.skip('#tissue_sample_help_per_plant_submit');
377 Workflow.focus("#tissue_sample_help_workflow", -1);
379 jQuery('#tissue_sample_help_tissue_samples_not_relevant').hide();
380 jQuery('#tissue_sample_help_tissue_samples_relevant').show();
381 jQuery('#tissue_sample_help_tissue_samples_exist_section').hide();
382 Workflow.focus("#tissue_sample_help_workflow", 4);
386 jQuery("#working_modal").modal("hide");
387 alert('An error occurred checking trial for tissue samples.');
393 error: function(response) {
394 jQuery("#working_modal").modal("hide");
395 alert("An error occurred saving plant entries");
400 jQuery('#tissue_sample_help_tissue_samples_per_plant_num').keyup(function(){
401 var num_tissues = jQuery(this).val();
403 for (var i=1; i<=num_tissues; i++){
404 html = html + '<div class="form-group"><label class="col-sm-3 control-label"><span title="The sample names will be a combination of the plant name, the tissue name you give here, and the tissue number."><span class="glyphicon glyphicon-info-sign"></span> Tissue Name '+i+': </span></label><div class="col-sm-9" ><input name="tissue_sample_help_tissue_name" id="tissue_samples_help_tissue_name_'+i+'" class="form-control" type="text" placeholder="examples: leaf or root or stem" /></div></div>';
406 jQuery('#tissue_sample_help_tissue_samples_names_div').html(html);
409 jQuery('#tissue_sample_help_per_plant_submit').click(function(){
411 if(jQuery('#tissue_sample_help_per_plant_inherit_treatments').is(":checked")){
415 var tissue_names = [];
416 jQuery('input[name="tissue_sample_help_tissue_name"]').each(function() {
417 tissue_names.push(this.value);
421 url: '/ajax/breeders/trial/'+selected[0]+'/create_tissue_samples/',
423 beforeSend: function() {
424 jQuery("#working_modal").modal("show");
427 'tissue_samples_per_plant' : jQuery('#tissue_sample_help_tissue_samples_per_plant_num').val(),
428 'inherits_plot_treatments' : is_checked,
429 'tissue_samples_names' : JSON.stringify(tissue_names)
431 success: function(response) {
432 jQuery("#working_modal").modal("hide");
433 if (response.error) {
434 alert(response.error);
437 alert("Successfully created tissue sample entries.");
438 Workflow.complete('#tissue_sample_help_per_plant_submit');
439 Workflow.focus("#tissue_sample_help_workflow", -1); //go to success
442 error: function(response) {
443 jQuery("#working_modal").modal("hide");
444 alert("An error occurred creating tissue sample entries");
451 function final_download_layout_button_click(){
452 if (selected_level == 'accession'){
453 alert('You selected to sample on the accession level, meaning that you wil not sample from a field trial. In this case there is no field layout to download!');
455 if (selected_level == 'plot'){
456 var selected_columns = {'plot_name':1,'plot_id':1,'block_number':1,'plot_number':1,'rep_number':1,'row_number':1,'col_number':1,'accession_name':1,'is_a_control':1};
457 var selected_columns_json = JSON.stringify(selected_columns);
458 window.open("/breeders/trial/"+selected[0]+"/download/layout?format=csv&dataLevel=plots&selected_columns="+selected_columns_json);
460 if (selected_level == 'plant'){
461 var selected_columns = {'plant_name':1,'plant_id':1,'plot_name':1,'block_number':1,'plant_number':1,'plot_number':1,'rep_number':1,'row_number':1,'col_number':1,'accession_name':1,'is_a_control':1};
462 var selected_columns_json = JSON.stringify(selected_columns);
463 window.open("/breeders/trial/"+selected[0]+"/download/layout?format=csv&dataLevel=plants&selected_columns="+selected_columns_json);
465 if (selected_level == 'tissue_sample'){
466 var selected_columns = {'tissue_sample_name':1,'tissue_sample_id':1,'plant_name':1,'plot_name':1,'block_number':1,'plant_number':1,'plot_number':1,'rep_number':1,'row_number':1,'col_number':1,'accession_name':1,'is_a_control':1};
467 var selected_columns_json = JSON.stringify(selected_columns);
468 window.open("/breeders/trial/"+selected[0]+"/download/layout?format=csv&dataLevel=field_trial_tissue_samples&selected_columns="+selected_columns_json);