3 @media (min-width: 768px) {
11 <div class="modal fade" id="create_cross_wishlist_dialog" name="create_cross_wishlist_dialog" tabindex="-1" role="dialog" aria-labelledby="createCrossWishlistDialog">
12 <div class="modal-dialog modal-xl" role="document">
13 <div class="modal-content">
14 <div class="modal-header">
15 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
16 <h4 class="modal-title" id="createCrossWishlistDialog">Create Cross Wishlist</h4>
19 <div class="modal-body">
20 <div class="container-fluid">
22 <form class="form-horizontal" id="cross_wishlist_create_select_form_id" name="cross_wishlist_create_select_form_id">
23 <div class="form-group">
24 <label class="col-sm-4 control-label">Select An ODK Form on ONA: </label>
25 <div class="col-sm-8" >
26 <div id="cross_wishlist_create_select_form_id_div">LOADING...</div>
32 <ul class="nav nav-pills nav-justified" id="cross_wishlist_tab_select">
33 <li id="cross_wishlist_list_tab"><a data-toggle="tab" href="#with_lists">Using Accession Lists</a></li>
34 <li class="active" id="cross_wishlist_no_list_tab"><a data-toggle="tab" href="#not_with_lists">Using Crossing Blocks</a></li>
37 <div class="tab-content">
39 <div id="with_lists" class="tab-pane fade">
41 <form class="form-horizontal" >
42 <div class="form-group" style="display:none" <!-- location name is coming from the trial they select --> >
43 <label class="col-sm-3 control-label">Location Name (Optional): </label>
44 <div class="col-sm-9" >
45 <div id="cross_wishlist_location_select_list_div">
49 <div class="form-group">
50 <label class="col-sm-3 control-label">Female's Trial Name: </label>
51 <div class="col-sm-9" >
52 <div id="cross_wishlist_female_trial_select_list_div">
56 <div class="form-group">
57 <label class="col-sm-3 control-label">Male's Trial Name: </label>
58 <div class="col-sm-9" >
59 <div id="cross_wishlist_male_trial_select_list_div">
63 <div class="well well-sm">
64 <div class="form-group">
65 <label class="col-sm-6 control-label">Cross plan will be added to the cross wishlist named: </label>
66 <div class="col-sm-6" >
67 <div id="cross_wishlist_trial_select_list_cross_wishlist_name_div">
68 <input class="form-control" type="text" disabled value="Please Select a Trial First" />
73 <div class="form-group">
74 <label class="col-sm-3 control-label">Female Accession List: </label>
75 <div class="col-sm-9" id="female_accession_list_div" name="female_accession_list_div">
78 <div class="form-group">
79 <label class="col-sm-3 control-label">Male Accession List: </label>
80 <div class="col-sm-9" id="male_accession_list_div" name="male_accession_list_div">
85 <div id="cross_wishlist_cross_grid_div"></div>
88 <div id="not_with_lists" class="tab-pane fade in active">
91 <form class="form-horizontal" >
92 <div class="form-group">
93 <label class="col-sm-3 control-label">Female's Trial Name: </label>
94 <div class="col-sm-9" >
95 <div id="cross_wishlist_female_trial_select_no_list_div">
99 <div class="form-group">
100 <label class="col-sm-3 control-label">Male's Trial Name: </label>
101 <div class="col-sm-9" >
102 <div id="cross_wishlist_male_trial_select_no_list_div">
106 <div class="well well-sm">
107 <div class="form-group">
108 <label class="col-sm-6 control-label">Cross plan will be added to the cross wishlist named: </label>
109 <div class="col-sm-6" >
110 <div id="cross_wishlist_trial_select_no_list_cross_wishlist_name_div">
111 <input class="form-control" type="text" disabled value="Please Select a Trial First" />
116 <div class="form-group">
117 <label class="col-sm-3 control-label">Female Accession Name(s):</label>
118 <div class="col-sm-9" >
119 <div id="cross_wishlist_female_accession_select_div">
120 <p>First Select A Trial</p>
124 <div id ="cross_wishlist_male_parent_div">
133 <div class="modal-footer">
134 <button class="btn btn-info" id="show_cross_wishlists_select_submits" name="show_cross_wishlists_select_submits">Available Cross Wishlist(s) for ODK Use</button>
135 <button class="btn btn-primary" id="cross_wishlist_submit" name="cross_wishlist_submits">Next</button>
136 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
142 <div class="modal fade" id="create_cross_wishlist_select_dialog" name="create_cross_wishlist_select_dialog" tabindex="-1" role="dialog" aria-labelledby="createCrossWishlistSelectDialog">
143 <div class="modal-dialog modal-xl" role="document">
144 <div class="modal-content">
145 <div class="modal-header">
146 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
147 <h4 class="modal-title" id="createCrossWishlistSelectDialog">Select Plots for Cross Wishlist</h4>
148 <h4>Female Plots are in <span class="bg-primary">Blue</span><!-- and Male Plots are in <span class="bg-success">Green</span>.--></h4>
151 <div class="modal-body">
152 <div class="container-fluid">
153 <div id="cross_wishlist_cross_select_div"></div>
157 <div class="modal-footer">
158 <button class="btn btn-primary" id="cross_wishlist_select_submits" name="cross_wishlist_select_submits">Create Wishlist</button>
159 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
165 <div class="modal fade" id="create_cross_wishlist_response_dialog" name="create_cross_wishlist_response_dialog" tabindex="-1" role="dialog" aria-labelledby="createCrossWishlistResponseDialog">
166 <div class="modal-dialog modal-xl" role="document">
167 <div class="modal-content">
168 <div class="modal-header">
169 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
170 <h4 class="modal-title" id="createCrossWishlistResponseDialog">Cross Wishlist</h4>
173 <div class="modal-body">
174 <div class="container-fluid">
175 <div id="cross_wishlist_response_div"></div>
179 <div class="modal-footer">
180 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
186 <div class="modal fade" id="show_cross_wishlists_response_dialog" name="show_cross_wishlists_response_dialog" tabindex="-1" role="dialog" aria-labelledby="showCrossWishlistsResponseDialog">
187 <div class="modal-dialog modal-xl" role="document">
188 <div class="modal-content">
189 <div class="modal-header">
190 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
191 <h4 class="modal-title" id="showCrossWishlistsResponseDialog">Cross Wishlists Previously Created</h4>
194 <div class="modal-body">
195 <div class="container-fluid">
196 <div id="show_cross_wishlists_response_div"></div>
200 <div class="modal-footer">
201 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
209 var lo = new CXGN.List();
211 function draw_cross_grid(female_accessions, male_accessions){
212 console.log("draw cross grid");
213 var cross_grid_html = '<h3>Set Cross Priorities: 1 is highest and 10 is lowest</h3><h4>Female Accessions Are in First Column and Male Accessions Are in Header</h4><table class="table table-bordered"><thead><tr><th>Female Accessions</th>';
214 for(var i=0; i<male_accessions.length; i++){
215 cross_grid_html = cross_grid_html + '<th>' + male_accessions[i] + '</th>';
217 cross_grid_html = cross_grid_html + '</tr></thead><tbody>';
218 for(var i=0; i<female_accessions.length; i++){
219 cross_grid_html = cross_grid_html + '<tr><td>' + female_accessions[i] + '</td>';
220 for(var j=0; j<male_accessions.length; j++){
221 cross_grid_html = cross_grid_html + '<td><input type="text" name="cross_wishlist_cross_grid_inputs" class="form-control" data-female="'+female_accessions[i]+'" data-male="'+male_accessions[j]+'"/></td>';
223 cross_grid_html = cross_grid_html + '</tr>';
225 cross_grid_html = cross_grid_html + '</tbody></table>';
226 jQuery('#cross_wishlist_cross_grid_div').html(cross_grid_html);
229 jQuery(document).ready(function($) {
231 jQuery('#show_cross_wishlists_select_submits').click(function(){
232 jQuery('#show_cross_wishlists_response_dialog').modal('show');
235 url: '/ajax/cross/list_cross_wishlists',
237 beforeSend: function() {
238 jQuery('#working_modal').modal('show');
240 success: function(response) {
241 //console.log(response);
242 jQuery('#working_modal').modal('hide');
244 if(response.success){
245 html += "<table class='table table-bordered table-hover'><thead><tr><th>File</th><th>Created By</th><th>Date</th></tr></thead><tbody>";
246 for(var i=0; i<response.files.length; i++){
247 html += "<tr><td><a href='/breeders/phenotyping/download/"+response.files[i][0]+"' >"+response.files[i][1]+"</a></td><td><a href='/solpeople/personal-info.pl?sp_person_id="+response.files[i][6]+"' >"+response.files[i][7]+" "+response.files[i][8]+"</a></td><td>"+response.files[i][5]+"</td></tr>";
249 html += "</tbody></table>";
251 html = 'Something went wrong here.'
253 jQuery('#show_cross_wishlists_response_div').html(html);
255 error: function(response) {
256 jQuery('#working_modal').modal('hide');
257 alert("An error occurred getting cross wishlists");
263 jQuery("#create_cross_wishlist").click(function() {
264 jQuery("#create_cross_wishlist_dialog").modal("show");
265 jQuery("#female_accession_list_div").html(lo.listSelect('female_accession_list_div', ["accessions"], "Please select list with < 100 accessions", undefined, undefined ));
266 jQuery("#male_accession_list_div").html(lo.listSelect('male_accession_list_div', ["accessions"], "Please select list with < 100 accessions", undefined, undefined ));
267 var female_accessions;
269 if (jQuery('#female_accession_list_div_list_select').val() != '' && jQuery('#male_accession_list_div_list_select').val() != '' ) {
270 female_accessions = lo.getList(jQuery('#female_accession_list_div_list_select').val());
271 male_accessions = lo.getList(jQuery('#male_accession_list_div_list_select').val());
275 url : '/ajax/odk/get_crossing_available_forms',
276 beforeSend: function() {
277 jQuery("#working_modal").modal("show");
279 success: function(response){
280 console.log(response);
281 jQuery("#working_modal").modal("hide");
284 alert(response.error);
286 if (response.success){
290 url : '/ajax/odk/get_crossing_saved_ona_forms',
291 success: function(response_forms){
292 console.log(response_forms);
294 if (response_forms.error){
295 alert(response.error);
297 if (response_forms.success){
299 var form_dropdown_select_html = '<select class="form-control" id="cross_wishlist_availabe_odk_crossing_forms"><option value="">Not Using ONA</option>';
300 var allowed_forms = response_forms.odk_ona_forms;
301 allowed_forms.push('<% $c->config->{odk_crossing_data_test_form_name} %>');
302 for(var i=0; i<response.forms.length; i++){
303 if (jQuery.inArray(response.forms[i].id_string, allowed_forms) != -1){
304 form_dropdown_select_html = form_dropdown_select_html + '<option value="'+response.forms[i].id+'">'+response.forms[i].id_string+'</option>';
307 form_dropdown_select_html = form_dropdown_select_html + '</select>';
308 jQuery('#cross_wishlist_create_select_form_id_div').html(form_dropdown_select_html);
312 error: function(response_forms){
313 alert("Error retrieving saved ODK ONA forms");
319 error: function(response){
320 jQuery("#working_modal").modal("hide");
321 alert("Error retrieving available ODK crossing forms");
325 if (jQuery('#female_accession_list_div_list_select').val() != '' && jQuery('#male_accession_list_div_list_select').val() != '' ) {
326 draw_cross_grid(female_accessions, male_accessions);
330 jQuery(document).on('change', '#female_accession_list_div_list_select', function(){
331 if (jQuery('#female_accession_list_div_list_select').val() != '' && jQuery('#male_accession_list_div_list_select').val() != '' ) {
332 var female_accessions = lo.getList(jQuery('#female_accession_list_div_list_select').val());
333 var male_accessions = lo.getList(jQuery('#male_accession_list_div_list_select').val());
334 draw_cross_grid(female_accessions, male_accessions);
337 jQuery(document).on('change', '#male_accession_list_div_list_select', function(){
338 if (jQuery('#female_accession_list_div_list_select').val() != '' && jQuery('#male_accession_list_div_list_select').val() != '' ) {
339 var female_accessions = lo.getList(jQuery('#female_accession_list_div_list_select').val());
340 var male_accessions = lo.getList(jQuery('#male_accession_list_div_list_select').val());
341 draw_cross_grid(female_accessions, male_accessions);
345 get_select_box('locations', 'cross_wishlist_location_select_list_div', { 'name' : 'cross_wishlist_location_id', 'id' : 'cross_wishlist_location_id', 'empty':1 });
346 get_select_box('trials', 'cross_wishlist_female_trial_select_no_list_div', { 'name' : 'cross_wishlist_female_trial_id', 'id' : 'cross_wishlist_female_trial_id', 'empty':1, 'multiple':0 });
347 get_select_box('trials', 'cross_wishlist_male_trial_select_no_list_div', { 'name' : 'cross_wishlist_male_trial_id', 'id' : 'cross_wishlist_male_trial_id', 'empty':1, 'multiple':0 });
349 get_select_box('trials', 'cross_wishlist_female_trial_select_list_div', { 'name' : 'cross_wishlist_list_female_trial_id', 'id' : 'cross_wishlist_list_female_trial_id', 'empty':1, 'multiple':0 });
350 get_select_box('trials', 'cross_wishlist_male_trial_select_list_div', { 'name' : 'cross_wishlist_list_male_trial_id', 'id' : 'cross_wishlist_list_male_trial_id', 'empty':1, 'multiple':0 });
352 jQuery(document).on('change', "#cross_wishlist_list_female_trial_id", function() {
353 cross_wishlist_change_trials_lists();
356 jQuery(document).on('change', "#cross_wishlist_female_trial_id", function() {
357 cross_wishlist_change_trials();
363 var female_male_tracker = {};
364 var selected_plot_ids = [];
365 jQuery('.nav-pills a').on('shown.bs.tab', function(event){
367 female_male_tracker = {};
368 selected_plot_ids = [];
373 var female_trial_ids_array = [];
374 var male_trial_ids_array = [];
375 function cross_wishlist_change_trials () {
376 var female_trial_ids = jQuery('#cross_wishlist_female_trial_id').val();
377 var female_trial_ids_string = '';
378 if ( jQuery.isArray(female_trial_ids) ) {
379 female_trial_ids_array = female_trial_ids;
380 trial_ids_string = female_trial_ids.join();
382 female_trial_ids_array = [female_trial_ids];
383 female_trial_ids_string = female_trial_ids;
387 url: '/ajax/breeders/trial/'+female_trial_ids_array[0]+'/location',
388 success: function(response) {
389 //console.log(response);
390 var cross_wishlist_name;
391 if ('<% $c->config->{odk_crossing_data_test_form_name} %>' == jQuery("#cross_wishlist_availabe_odk_crossing_forms option:selected").text()){
392 cross_wishlist_name = 'cross_wishlist_test.csv';
393 } else if ('<% $c->config->{odk_crossing_data_separate_wishlist_by_location} %>' == '1') {
394 cross_wishlist_name = 'cross_wishlist_'+response.location[1]+'.csv'
396 cross_wishlist_name = 'cross_wishlist_<% $c->config->{project_name} %>.csv';
398 jQuery('#cross_wishlist_trial_select_no_list_cross_wishlist_name_div').html('<input type="text" class="form-control" disabled value="'+cross_wishlist_name+'" />');
400 error: function(response) {
401 alert("An error occurred getting trial location");
405 get_select_box('stocks', 'cross_wishlist_female_accession_select_div', { 'name' : 'cross_wishlist_female_accession_ids', 'id' : 'cross_wishlist_female_accession_ids', 'size' : 7, 'stock_type_name':'accession', 'trial_id_list':female_trial_ids_array, 'names_as_select':1 });
408 function cross_wishlist_change_trials_lists () {
409 var female_trial_ids = jQuery('#cross_wishlist_list_female_trial_id').val();
410 var female_trial_ids_string = '';
411 if ( jQuery.isArray(female_trial_ids) ) {
412 female_trial_ids_array = female_trial_ids;
413 female_trial_ids_string = female_trial_ids.join();
415 female_trial_ids_array = [female_trial_ids];
416 female_trial_ids_string = female_trial_ids;
420 url: '/ajax/breeders/trial/'+female_trial_ids_array[0]+'/location',
421 success: function(response) {
422 //console.log(response);
423 var cross_wishlist_name;
424 if ('<% $c->config->{odk_crossing_data_test_form_name} %>' == jQuery("#cross_wishlist_availabe_odk_crossing_forms option:selected").text()){
425 cross_wishlist_name = 'cross_wishlist_test.csv';
426 } else if ('<% $c->config->{odk_crossing_data_separate_wishlist_by_location} %>' == '1') {
427 cross_wishlist_name = 'cross_wishlist_'+response.location[1]+'.csv'
429 cross_wishlist_name = 'cross_wishlist_<% $c->config->{project_name} %>.csv';
431 jQuery('#cross_wishlist_trial_select_list_cross_wishlist_name_div').html('<input type="text" class="form-control" disabled value="'+cross_wishlist_name+'" />');
433 error: function(response) {
434 alert("An error occurred getting trial location");
439 jQuery(document).on('change', "#cross_wishlist_female_accession_ids", function() {
440 cross_wishlist_select_females();
443 function cross_wishlist_select_females () {
445 var male_trial_ids = jQuery('#cross_wishlist_male_trial_id').val();
446 var male_trial_ids_string = '';
447 if ( jQuery.isArray(male_trial_ids) ) {
448 male_trial_ids_array = male_trial_ids;
449 male_trial_ids_string = male_trial_ids.join();
451 male_trial_ids_array = [male_trial_ids];
452 male_trial_ids_string = male_trial_ids;
454 if (male_trial_ids.length == 0){
455 alert('Please select a male trial first!');
459 var female_accession_ids = jQuery('#cross_wishlist_female_accession_ids').val();
460 var html = '<table class="table table-bordered" id="cross_wishlist_male_select_table"><thead><tr><th>Female Parent</th><th>Select Male Parent</th><th>Priority ( 1 : highest, 10 : lowest )</th></tr></thead><tbody>';
461 for(var i=0; i<female_accession_ids.length; i++){
462 html = html + '<tr><td>' + female_accession_ids[i] + '</td><td><div name="cross_wishlist_male_selects" id="cross_wishlist_male_select_' +i+ '"></div></td><td><span id="cross_wishlist_male_accession_id_'+ i +'_priority" data-related="'+encodeURI(female_accession_ids[i])+'" >Select Male(s)</span></td></tr>';
464 html = html + '</tbody></table>';
465 jQuery('#cross_wishlist_male_parent_div').html(html);
467 var cross_wishlist_male_parents = jQuery('#cross_wishlist_male_select_table')
469 .map(function() { return this.id; })
471 //console.log(cross_wishlist_male_parents);
472 for(var i=0; i<cross_wishlist_male_parents.length; i++){
473 var female_id = jQuery('#cross_wishlist_male_accession_id_'+ i +'_priority').data('related');
474 get_select_box('stocks', cross_wishlist_male_parents[i], { 'name' : 'cross_wishlist_male_accession_id_select', 'id' : 'cross_wishlist_male_accession_id_'+i, 'size' : 7, 'stock_type_name':'accession', 'trial_id_list':male_trial_ids_array, 'names_as_select':1, 'data-related':female_id });
478 jQuery(document).on('change', "select[name='cross_wishlist_male_accession_id_select']", function() {
479 var div_id = '#' + this.id;
480 var male_ids = jQuery(div_id).val();
481 if (male_ids.length > 0){
482 cross_wishlist_change_males(div_id, div_id + '_priority');
486 function cross_wishlist_change_males(div_id, select_id){
487 var female_accession_ids = jQuery('#cross_wishlist_female_accession_ids').val();
488 var male_ids = jQuery(div_id).val();
489 var female_id = jQuery(div_id).data('related');
490 var html = '<table class="table table-bordered" div="' + div_id +'_table"><thead><tr><th>Male Parent</th><th>Priority</th></tr></thead><tbody>';
491 for (var i=0; i<male_ids.length; i++){
492 html = html + '<tr><td>' + male_ids[i] + '</td><td><input class="form-control" male_id="' + male_ids[i] + '" female_id="' + female_id + '" name ="cross_wishlist_final_priority" id="cross_wishlist_male_priority_'+ i +'" value="1" placeholder="1"/></td></tr>';
494 html = html + '</tbody></table>';
495 jQuery(select_id).html(html);
499 jQuery('#cross_wishlist_submit').click(function(e){
501 var active_tab = jQuery('ul#cross_wishlist_tab_select li.active').attr('id');
502 //console.log(active_tab);
504 female_male_tracker = {};
505 selected_plot_ids = [];
509 var male_accession_limit = 10;
510 if (active_tab == 'cross_wishlist_no_list_tab'){
511 jQuery('input[name="cross_wishlist_final_priority"]').each(function() {
513 var male_id = jQuery(this).attr('male_id');
514 var female_id = jQuery(this).attr('female_id');
515 cross_data.push({ 'female_id':female_id, 'male_id':male_id, 'priority':value });
516 if (female_id in female_male_tracker){
517 female_male_tracker[female_id].push(male_id);
519 female_male_tracker[female_id] = [male_id];
522 female_trial_id = jQuery('#cross_wishlist_female_trial_id').val();
523 male_trial_id = jQuery('#cross_wishlist_male_trial_id').val();
525 if (active_tab == 'cross_wishlist_list_tab'){
526 jQuery('input[name="cross_wishlist_cross_grid_inputs"]').each(function() {
529 var male_id = jQuery(this).data('male');
530 var female_id = jQuery(this).data('female');
531 cross_data.push({ 'female_id':female_id, 'male_id':male_id, 'priority':value });
532 if (female_id in female_male_tracker){
533 female_male_tracker[female_id].push(male_id);
535 female_male_tracker[female_id] = [male_id];
539 female_trial_id = jQuery('#cross_wishlist_list_female_trial_id').val();
540 male_trial_id = jQuery('#cross_wishlist_list_male_trial_id').val();
542 //console.log(cross_data);
543 //console.log(trial_id);
544 //console.log(female_male_tracker);
545 if(!female_trial_id){
546 alert('You must select a female trial!');
550 alert('You must select a male trial! It can be the same trial as the female trial.');
553 for (f in female_male_tracker){
554 var male_array = female_male_tracker[f];
555 if (male_array.length > male_accession_limit){
556 alert('A maximum of 10 male accessions can be selected for each cross!');
561 url: '/ajax/cross/create_cross_wishlist',
564 'crosses': JSON.stringify(cross_data),
565 'female_trial_id': female_trial_id,
566 'male_trial_id': male_trial_id
569 beforeSend: function() {
570 jQuery('#working_modal').modal('show');
572 success: function(response) {
573 //console.log(response);
574 jQuery('#working_modal').modal('hide');
576 alert(response.error);
578 jQuery('#cross_wishlist_cross_select_div').html(response.data);
579 jQuery('#create_cross_wishlist_select_dialog').modal('show');
582 error: function(response) {
583 jQuery('#working_modal').modal('hide');
584 alert("An error occurred submitting plots for cross wishlist");
589 jQuery('#cross_wishlist_select_submits').click(function(){
590 var male_plot_limit = 10;
591 female_male_tracker = {};
592 selected_plot_ids = [];
594 jQuery('input[name="cross_wishlist_plot_select_female_input"]').each(function() {
596 selected_plot_ids.push({
597 'cross_female_accession_name' : jQuery(this).data('female_accession_name'),
598 'female_plot_id' : jQuery(this).val(),
599 'male_genotypes_string' : jQuery(this).data('male_genotypes_string')
603 jQuery('input[name="cross_wishlist_plot_select_male_input"]').each(function() {
605 selected_plot_ids.push({
606 'cross_female_accession_name' : jQuery(this).data('female_accession_name'),
607 'male_plot_id' : jQuery(this).val()
609 if (jQuery(this).data('female_accession_name') in female_male_tracker){
610 female_male_tracker[jQuery(this).data('female_accession_name')].push(jQuery(this).val());
612 female_male_tracker[jQuery(this).data('female_accession_name')] = [jQuery(this).val()];
616 //console.log(selected_plot_ids);
617 //console.log(female_male_tracker);
618 for (f in female_male_tracker){
619 var male_array = female_male_tracker[f];
620 if (male_array.length > male_plot_limit){
621 alert('A maximum of 10 male plots can be selected for each cross!');
627 url: '/ajax/cross/create_cross_wishlist_submit',
630 'crosses': JSON.stringify(cross_data),
631 'selected_plot_ids': JSON.stringify(selected_plot_ids),
632 'female_trial_id': female_trial_id,
633 'male_trial_id': male_trial_id,
634 'form_id': jQuery('#cross_wishlist_availabe_odk_crossing_forms').val(),
635 'form_name': jQuery("#cross_wishlist_availabe_odk_crossing_forms option:selected").text()
638 beforeSend: function() {
639 jQuery('#working_msg').html('Creating cross wishlist files and sending information to ONA... This can take time...');
640 jQuery('#working_modal').modal('show');
642 success: function(response) {
643 //console.log(response);
644 jQuery('#working_msg').html('');
645 jQuery('#working_modal').modal('hide');
646 if (response.filename) {
647 window.location.href = "/download/"+response.filename;
649 if (response.error) {
650 jQuery('#cross_wishlist_response_div').html(response.error);
652 if (response.success){
653 jQuery('#cross_wishlist_response_div').html(response.success);
655 jQuery('#create_cross_wishlist_response_dialog').modal('show');
657 error: function(response) {
658 jQuery('#working_msg').html('');
659 jQuery('#working_modal').modal('hide');
660 alert("An error occurred creating cross wishlist");