Revert "Update loading pedigree"
[sgn.git] / js / CXGN / BreedersToolbox / UploadPedigrees.js
blob14adb1ca4cdb8344c7fa10656daf543c6b5058b7
1 /*jslint browser: true, devel: true */
3 /**
5 =head1 UploadPedigrees.js
7 Dialogs for uploading pedigrees
10 =head1 AUTHOR
12 Lukas Mueller <lam87@cornell.edu>, based on code by
13 Jeremy D. Edwards <jde22@cornell.edu>
15 =cut
20 var $j = jQuery.noConflict();
22 jQuery(document).ready(function ($) {
25     $('#upload_pedigrees_link').click(function () {
26         open_upload_pedigrees_dialog();
27     });
29 //    jQuery("#upload_pedigrees_dialog").dialog({
30 //      autoOpen: false,        
31 //      modal: true,
32 //      autoResize:true,
33 //        width: 500,
34 //        position: ['top', 75],
35 //      buttons: {
36 //            "Cancel": function () {
37 //                jQuery('#upload_pedigrees_dialog').dialog("close");
38 //            },
39 //          "Ok": function () {
40 //              upload_pedigrees_file();
41 //                jQuery('#upload_pedigrees_dialog').dialog("close");
42 //              
43 //          },
44 //      }
45 //    });
48 //    $("#pedigrees_upload_spreadsheet_info_dialog").dialog( {
49 //      autoOpen: false,
50 //      buttons: { "OK" :  function() { $("#pedigrees_upload_spreadsheet_info_dialog").dialog("close"); },},
51 //      modal: true,
52 //      position: ['top', 75],
53 //      width: 900,
54 //      autoResize:true,
55 //    });
57     $("#upload_pedigrees_dialog_submit").click( function () { 
58         $('#upload_pedigrees_dialog').modal("hide");
59         upload_pedigrees_file();        
60     });
61     
62     $("#pedigrees_upload_spreadsheet_format_info").click( function () { 
63         $('#upload_pedigrees_dialog').modal("hide");
64         $("#pedigrees_upload_spreadsheet_info_dialog" ).modal("show");  
65     });
67 //    $("#pedigrees_upload_success_dialog_message").dialog({
68 //      autoOpen: false,
69 //      modal: true,
70 //      buttons: {
71 //            Ok: { id: "dismiss_pedigrees_upload_dialog",
72 //                  click: function() {
73 //                    //$("#upload_trial_form").dialog("close");
74 //                    //$( this ).dialog( "close" );
75 //                    location.reload();
76 //                  },
77 //                  text: "OK"
78 //                }
79 //        }
80 //      
81 //    });
83     $('#upload_pedigrees_form').iframePostForm({
84         json: true,
85         post: function () {
86             var uploadedPedigreesFile = $("#pedigrees_uploaded_file").val();
87             $('#working_modal').modal("show");
88             if (uploadedPedigreesFile === '') {
89                 $('#working_modal').modal("hide");
90                 alert("No file selected");
91             }
92         },
93         complete: function (response) {
94             $('#working_modal').modal("hide");
95             if (response.error_string) {
96                 $("#upload_pedigrees_error_display tbody").html('');
97                 $("#upload_pedigrees_error_display tbody").append(response.error_string);
98                 $("#upload_pedigrees_error_display").modal('show');
101                 //$(function () {
102                 //    $("#upload_pedigrees_error_display").dialog({
103                 //      modal: true,
104                 //      autoResize:true,
105                 //      width: 650,
106                 //      position: ['top', 250],
107                 //      title: "Errors in uploaded file",
108                 //      buttons: {
109                 //            Ok: function () {
110                 //              $(this).dialog("close");
111                 //            }
112                 //      }
113                 //    });
114                 //});
115                 return;
116             }
117             if (response.error) {
118                 alert(response.error);
119                 return;
120             }
121             if (response.success) {
122                 $('#pedigrees_upload_success_dialog_message').modal("show");
123                 //alert("File uploaded successfully");
124             }
125         }
126     });
128         function upload_pedigrees_file() {
129         var uploadFile = $("#pedigrees_uploaded_file").val();
130         $('#upload_pedigrees_form').attr("action", "/ajax/pedigrees/upload");
131         if (uploadFile === '') {
132             alert("Please select a file");
133             return;
134         }
135         $("#upload_pedigrees_form").submit();
136     }
138     function open_upload_pedigrees_dialog() {
139         $('#upload_pedigrees_dialog').modal("show");
140         //add a blank line to design method select dropdown that dissappears when dropdown is opened 
142     }