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">
111 <div class="form-group">
112 <label class="col-sm-3 control-label">Inherits Management Factor(s) From Plots: </label>
113 <div class="col-sm-9" >
114 <input name="create_tissue_samples_per_plant_inherit_treatments" id="create_tissue_samples_per_plant_inherit_treatments" type="checkbox"/>
117 <div class="form-group">
118 <label class="col-sm-3 control-label">Use Tissue Numbers: </label>
119 <div class="col-sm-9" >
120 <input name="create_tissue_samples_per_plant_use_tissue_numbers" id="create_tissue_samples_per_plant_use_tissue_numbers" type="checkbox"/>
125 <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>
128 <&| /util/workflow.mas:complete, title=> "Complete" &>
129 <& /page/page_title.mas, title=>"Complete! Your field trial's tissue samples were saved." &>
132 <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
133 Tissue samples saved successfully
137 <li>You may want to go to the trial detail page for the trial now that it has plants.</li>
138 <li>You can print barcodes for the new tissue samples.</li>
139 <li>You can use these tissue samples as source material for a genotyping plates (96 or 384 well plate)</li>
147 <div class="modal-footer">
148 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
155 jQuery(document).ready(function(){
157 var create_tissue_sample_trial_table = jQuery('#manage_tissue_samples_field_search_results').DataTable( {
159 'url':'/ajax/search/trials',
160 'data': function(d) {
161 d.select_checkbox_name = 'create_tissue_sample_select_trial';
168 jQuery('#create_tissue_samples_select_trial').click(function(){
170 jQuery('input[name="create_tissue_sample_select_trial"]:checked').each(function() {
171 selected.push(jQuery(this).val());
173 if (selected.length !== 1){
174 alert('Only select one trial!');
178 url: '/ajax/breeders/trial/'+selected[0]+'/has_plants',
180 beforeSend: function() {
181 jQuery("#working_modal").modal("show");
183 success: function (response) {
184 jQuery("#working_modal").modal("hide");
185 if (response.has_plants){
186 jQuery('#create_tissue_samples_plant_entries_exist_section').show();
187 jQuery('#create_tissue_samples_plant_entries_dont_exist_section').hide();
188 Workflow.complete('#create_tissue_samples_select_trial');
189 Workflow.skip('#create_tissue_samples_plant_entries_exist_section');
190 Workflow.focus("#field_tissue_samples_create_workflow", 3);
192 jQuery('#create_tissue_samples_plant_entries_dont_exist_section').show();
193 jQuery('#create_tissue_samples_plant_entries_exist_section').hide();
194 Workflow.complete('#create_tissue_samples_select_trial');
195 Workflow.focus("#field_tissue_samples_create_workflow", 2);
199 jQuery("#working_modal").modal("hide");
200 alert('An error occurred checking trial for plants.');
206 jQuery('#create_tissue_samples_plants_per_plot_submit').click(function(){
208 if(jQuery('#create_tissue_samples_plants_per_plot_inherit_treatments').is(":checked")){
213 url: '/ajax/breeders/trial/'+selected[0]+'/create_plant_entries/',
215 beforeSend: function() {
216 jQuery("#working_modal").modal("show");
219 'plants_per_plot' : jQuery('#create_tissue_samples_plants_per_plot_num').val(),
220 'inherits_plot_treatments' : is_checked
222 success: function(response) {
223 jQuery("#working_modal").modal("hide");
224 if (response.error) {
225 alert(response.error);
228 alert("Successfully created plant entries.");
229 Workflow.complete('#create_tissue_samples_plants_per_plot_submit');
230 Workflow.focus("#field_tissue_samples_create_workflow", 3);
233 error: function(response) {
234 jQuery("#working_modal").modal("hide");
235 alert("An error occurred saving plant entries");
240 jQuery('#create_tissue_samples_per_plant_num').keyup(function(){
241 var num_tissues = jQuery(this).val();
243 for (var i=1; i<=num_tissues; i++){
244 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 or seed or fruit" /></div></div>';
246 jQuery('#create_tissue_samples_names_div').html(html);
249 jQuery('#create_tissue_samples_plants_per_plant_submit').click(function(){
251 if(jQuery('#create_tissue_samples_per_plant_inherit_treatments').is(":checked")){
255 var use_tissue_numbers;
256 if(jQuery('#create_tissue_samples_per_plant_use_tissue_numbers').is(":checked")){
257 use_tissue_numbers = 1;
260 var tissue_names = [];
261 jQuery('input[name="create_tissue_samples_tissue_name"]').each(function() {
262 tissue_names.push(this.value);
267 url: '/ajax/breeders/trial/'+selected[0]+'/create_tissue_samples/',
269 beforeSend: function() {
270 jQuery("#working_modal").modal("show");
273 'tissue_samples_per_plant' : jQuery('#create_tissue_samples_per_plant_num').val(),
274 'inherits_plot_treatments' : is_checked,
275 'use_tissue_numbers' : use_tissue_numbers,
276 'tissue_samples_names' : JSON.stringify(tissue_names)
278 success: function(response) {
279 jQuery("#working_modal").modal("hide");
280 if (response.error) {
281 alert(response.error);
284 alert("Successfully created tissue sample entries.");
285 Workflow.complete('#create_tissue_samples_plants_per_plant_submit');
286 Workflow.focus("#field_tissue_samples_create_workflow", -1); //go to success
289 error: function(response) {
290 jQuery("#working_modal").modal("hide");
291 alert("An error occurred creating tissue sample entries");