autogenerated name function
[sgn.git] / mason / transformation / add_transformant_names_dialog.mas
blob2a02df160841969a5db92b3ce773f1d3638b43cf
1 <%args>
2 $transformation_id
3 $transformation_name
4 $next_new_transformant
5 $last_number
6 $prefix
7 $program_id
8 </%args>
10 <& /util/import_javascript.mas, classes => [ 'jquery', 'jquery.dataTables' ] &>
11 <& /util/import_css.mas, paths => ['/documents/inc/datatables/jquery.dataTables.css'] &>
13 <div class="modal fade" id="add_new_transformant_names_dialog" name="add_new_transformant_names_dialog" tabindex="-1" role="dialog" aria-labelledby="addNewTransformantNamesDialog">
14     <div class="modal-dialog modal-lg" role="document">
15         <div class="modal-content">
16             <div class="modal-header" style="text-align: center">
17                 <button type="reset" class="close" id="add_new_transformants_dismiss_button_1" name="add_new_transformants_dismiss_button" aria-label="Close"><span aria-hidden="true">&times;</span></button>
18                 <h4 class="modal-title" id="addNewTransformantNamesDialog">Add New Transformant (Accession) Names</h4>
19             </div>
20             <div class="modal-body">
21                 <div class="container-fluid">
22                     <form class="form-horizontal" id="create_new_transformants_form" name="create_new_transformants_form">
23                         <div class="form-group">
24                             <label class="col-sm-3 control-label">Prefix: </label>
25                             <div class="col-sm-9">
26                                 <input class="form-control" id="autogenerated_name_prefix" name="autogenerated_name_prefix" type="text" disabled value="<%$prefix%>"/>
27                             </div>
28                         </div>
29                     <!--
30                         <div class="form-group">
31                             <label class="col-sm-3 control-label">Next Name: </label>
32                             <div class="col-sm-9">
33                                 <input class="form-control" id="next_transformant_name" name="next_transformant_name" type="text" disabled value="<%$next_new_transformant%>"/>
34                             </div>
35                         </div>
36                     -->
37                         <div class="form-group">
38                             <label class="col-sm-3 control-label">How many?</label>
39                             <div class="col-sm-9">
40                                 <input class="form-control" id="number_of_new_transformants" name="number_of_new_transformants" type="number" />
41                             </div>
42                         </div>
43                     </form>
44                 </div>
45             </div>
46             <div class="modal-footer">
47                 <button id="add_new_transformants_dismiss_button_2" name="add_new_transformants_dismiss_button" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
48                 <button type="button" class="btn btn-primary" id="new_transformants_submit">Submit</button>
49             </div>
50         </div>
51     </div>
52 </div>
54 <div class="modal fade" id="new_transformants_saved_dialog_message" name="new_transformants_saved_dialog_message" tabindex="-1" role="dialog" aria-labelledby="newTransformantsSavedDialog">
55     <div class="modal-dialog" role="document">
56         <div class="modal-content">
57             <div class="modal-header">
58                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
59                 <h4 class="modal-title" id="newTransformantsSavedDialog">Success</h4>
60             </div>
61             <div class="modal-body">
62                 <div class="container-fluid">
63                     <p>
64                         <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
65                         The new transformants (accessions) were saved successfully.
66                     </p>
67                 </div>
68             </div>
69             <div class="modal-footer">
70                 <button id="dismiss_new_transformants_saved_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close & Reload</button>
71             </div>
72         </div>
73     </div>
74 </div>
77 <script>
79 jQuery(document).ready(function(){
81     var last_number = "<% $last_number %>";
82     var prefix = "<% $prefix %>";
84     jQuery('#add_new_transformants_link').click(function(){
85         if (prefix) {
86             jQuery('#add_new_transformant_names_dialog').modal('show');
87         } else {
88             alert('Please set Prefix for autogenerated names for this project first. You can find Set Autogenerated Names link on the project page')
89         }
90     });
92     jQuery('#new_transformants_submit').click(function(){
93         var new_name_count = jQuery('#number_of_new_transformants').val();
94         jQuery.ajax({
95             url : '/ajax/transformation/add_transformants',
96             dataType: "json",
97             type: 'POST',
98             data : {
99 //                'transformation_name': "<%$transformation_name%>",
100                 'transformation_stock_id': "<%$transformation_id%>",
101                 'program_id': "<%$program_id%>",
102                 'prefix': prefix,
103                 'new_name_count': new_name_count,
104 //                'last_number': last_number,
105             },
106             beforeSend: function(response){
107                 jQuery('#working_modal').modal('show');
108             },
109             success: function(response) {
110                 jQuery('#working_modal').modal('hide');
111                 if (response.success == 1) {
112                     jQuery('#add_new_transformant_names_dialog').modal('hide');
113                     jQuery('#new_transformants_saved_dialog_message').modal("show");
115                 }
116                 if (response.error) {
117                     alert(response.error);
118                 }
119             },
120             error: function(response){
121                 jQuery('#working_modal').modal('hide');
122                 alert('An error occurred creating new transformants');
123             }
124         });
125     });
127     jQuery("[name='add_new_transformants_dismiss_button']").click(function() {
128         jQuery('#add_new_transformant_names_dialog').modal('hide');
129         jQuery('#number_of_new_transformants').val('');
130     });
132     jQuery("#dismiss_new_transformants_saved_dialog").click(function(){
133         jQuery('#number_of_new_transformants').val('');
134         location.reload();
135     });
140 </script>