4 <& /util/import_javascript.mas, classes => [ 'CXGN.BreedersToolbox.GenotypingTrial' ] &>
6 <div class="modal fade" id="field_trial_tissue_sample_dialog" name="field_trial_tissue_sample_dialog" tabindex="-1" role="dialog" aria-labelledby="addFieldTrialTissueSampleDialog">
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="addFieldTrialTissueSampleDialog">Create Tissue Samples for a Field Trial</h4>
13 <div class="modal-body">
15 <div class="container-fluid">
17 <&| /util/workflow.mas, id=> "field_tissue_samples_create_workflow" &>
18 <&| /util/workflow.mas:step, title=> "Intro" &>
19 <& /page/page_title.mas, title=>"This workflow will guide you through creating tissue samples for your field trial" &>
20 <p>Tissue samples 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 needs a globally unique name.</p>
23 <p>Tissue samples can then be transferred into genotyping plates (96 or 384 well plates).</p>
27 <button class="btn btn-primary" onclick="Workflow.complete(this); return false;">Go to Next Step</button>
31 <&| /util/workflow.mas:step, title=> "Select a field trial" &>
32 <& /page/page_title.mas, title=>"Select a field trial" &>
34 <div class="well well-sm">
35 <div class="panel panel-default">
36 <div class="panel-body">
37 <table id="manage_tissue_samples_field_search_results" class="table table-hover table-striped">
43 <th>Breeding program</th>
49 <th>Planting Date</th>
61 <button class="btn btn-primary" id="create_tissue_samples_select_trial">Go to Next Step</button>
65 <&| /util/workflow.mas:step, title=> "Plant Entries" &>
66 <& /page/page_title.mas, title=>"Plant entries in your field trial" &>
68 <div id="create_tissue_samples_plant_entries_exist_section" style="display:none">
69 <h4>Plant entries exist for this trial. Go to next step.</h4>
71 <button class="btn btn-primary" onclick="Workflow.complete(this); return false;">Go to Next Step</button>
74 <div id="create_tissue_samples_plant_entries_dont_exist_section" style="display:none">
75 <h4>Please create plant entries for this trial.</h4>
76 <form class="form-horizontal">
77 <div class="form-group">
78 <label class="col-sm-3 control-label">Number of plants per plot: </label>
79 <div class="col-sm-9" >
80 <input name="create_tissue_samples_plants_per_plot_num" id="create_tissue_samples_plants_per_plot_num" class="form-control" type="number" autofocus/>
83 <div class="form-group">
84 <label class="col-sm-3 control-label">Inherits Management Factor(s) From Plots: </label>
85 <div class="col-sm-9" >
86 <input name="create_tissue_samples_plants_per_plot_inherit_treatments" id="create_tissue_samples_plants_per_plot_inherit_treatments" type="checkbox" checked disabled/>
91 <button type="button" class="btn btn-primary" id="create_tissue_samples_plants_per_plot_submit">Submit</button>
96 <&| /util/workflow.mas:step, title=> "Create Tissue Sample Entries" &>
97 <& /page/page_title.mas, title=>"Create tissue sample entries for this trial" &>
99 <form class="form-horizontal" >
100 <div class="form-group">
101 <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>
102 <div class="col-sm-9" >
103 <input name="create_tissue_samples_per_plant_num" id="create_tissue_samples_per_plant_num" class="form-control" type="text" autofocus/>
107 <div id="create_tissue_samples_names_div">
110 <div class="form-group">
111 <label class="col-sm-3 control-label">Inherits Management Factor(s) From Plots: </label>
112 <div class="col-sm-9" >
113 <input name="create_tissue_samples_per_plant_inherit_treatments" id="create_tissue_samples_per_plant_inherit_treatments" type="checkbox" checked disabled/>
118 <button type="button" class="btn btn-primary" name="create_tissue_samples_plants_per_plant_submit" id="create_tissue_samples_plants_per_plant_submit">Submit</button>
121 <&| /util/workflow.mas:complete, title=> "Complete" &>
122 <& /page/page_title.mas, title=>"Complete! Your field trial's tissue samples were saved." &>
125 <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
126 Tissue samples saved successfully
130 <li>You may want to go to the trial detail page for the trial now that it has plants.</li>
131 <li>You can print barcodes for the new tissue samples.</li>
132 <li>You can use these tissue samples as source material for a genotyping plates (96 or 384 well plate)</li>
140 <div class="modal-footer">
141 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
148 jQuery(document).ready(function(){
150 var create_tissue_sample_trial_table = jQuery('#manage_tissue_samples_field_search_results').DataTable( {
152 'url':'/ajax/search/trials',
153 'data': function(d) {
154 d.select_checkbox_name = 'create_tissue_sample_select_trial';
161 jQuery('#create_tissue_samples_select_trial').click(function(){
163 jQuery('input[name="create_tissue_sample_select_trial"]:checked').each(function() {
164 selected.push(jQuery(this).val());
166 if (selected.length !== 1){
167 alert('Only select one trial!');
171 url: '/ajax/breeders/trial/'+selected[0]+'/has_plants',
173 beforeSend: function() {
174 jQuery("#working_modal").modal("show");
176 success: function (response) {
177 jQuery("#working_modal").modal("hide");
178 if (response.has_plants){
179 jQuery('#create_tissue_samples_plant_entries_exist_section').show();
180 jQuery('#create_tissue_samples_plant_entries_dont_exist_section').hide();
181 Workflow.complete('#create_tissue_samples_select_trial');
182 Workflow.skip('#create_tissue_samples_plant_entries_exist_section');
183 Workflow.focus("#field_tissue_samples_create_workflow", 3);
185 jQuery('#create_tissue_samples_plant_entries_dont_exist_section').show();
186 jQuery('#create_tissue_samples_plant_entries_exist_section').hide();
187 Workflow.complete('#create_tissue_samples_select_trial');
188 Workflow.focus("#field_tissue_samples_create_workflow", 2);
192 jQuery("#working_modal").modal("hide");
193 alert('An error occurred checking trial for plants.');
199 jQuery('#create_tissue_samples_plants_per_plot_submit').click(function(){
201 if(jQuery('#create_tissue_samples_plants_per_plot_inherit_treatments').is(":checked")){
206 url: '/ajax/breeders/trial/'+selected[0]+'/create_plant_entries/',
208 beforeSend: function() {
209 jQuery("#working_modal").modal("show");
212 'plants_per_plot' : jQuery('#create_tissue_samples_plants_per_plot_num').val(),
213 'inherits_plot_treatments' : is_checked
215 success: function(response) {
216 jQuery("#working_modal").modal("hide");
217 if (response.error) {
218 alert(response.error);
221 alert("Successfully created plant entries.");
222 Workflow.complete('#create_tissue_samples_plants_per_plot_submit');
223 Workflow.focus("#field_tissue_samples_create_workflow", 3);
226 error: function(response) {
227 jQuery("#working_modal").modal("hide");
228 alert("An error occurred saving plant entries");
233 jQuery('#create_tissue_samples_per_plant_num').keyup(function(){
234 var num_tissues = jQuery(this).val();
236 for (var i=1; i<=num_tissues; i++){
237 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="create_tissue_samples_tissue_name" id="create_tissue_samples_tissue_name_'+i+'" class="form-control" type="text" placeholder="examples: leaf or root or stem" /></div></div>';
239 jQuery('#create_tissue_samples_names_div').html(html);
242 jQuery('#create_tissue_samples_plants_per_plant_submit').click(function(){
244 if(jQuery('#create_tissue_samples_per_plant_inherit_treatments').is(":checked")){
248 var tissue_names = [];
249 jQuery('input[name="create_tissue_samples_tissue_name"]').each(function() {
250 tissue_names.push(this.value);
254 url: '/ajax/breeders/trial/'+selected[0]+'/create_tissue_samples/',
256 beforeSend: function() {
257 jQuery("#working_modal").modal("show");
260 'tissue_samples_per_plant' : jQuery('#create_tissue_samples_per_plant_num').val(),
261 'inherits_plot_treatments' : is_checked,
262 'tissue_samples_names' : JSON.stringify(tissue_names)
264 success: function(response) {
265 jQuery("#working_modal").modal("hide");
266 if (response.error) {
267 alert(response.error);
270 alert("Successfully created tissue sample entries.");
271 Workflow.complete('#create_tissue_samples_plants_per_plant_submit');
272 Workflow.focus("#field_tissue_samples_create_workflow", -1); //go to success
275 error: function(response) {
276 jQuery("#working_modal").modal("hide");
277 alert("An error occurred creating tissue sample entries");