Merge pull request #5243 from solgenomics/topic/observations_upload_catch_error
[sgn.git] / mason / transformation / transformation_project_deletion.mas
blobd80e6e6c64756d4ee21735a19330ac50f4adf909
1 <%args>
2 $trial_id
3 </%args>
5 <& /util/import_javascript.mas, classes => [ 'jquery', 'jquery.dataTables' ] &>
6 <& /util/import_css.mas, paths => ['/documents/inc/datatables/jquery.dataTables.css'] &>
8 <&| /page/info_section.mas, id=>'delete_transformation_ids_section', title => 'Delete Transformation IDs', subtitle => '<font color="red">Deletion cannot be undone</font>', collapsible=>1, collapsed=>1 &>
9     <div class="well well-sm">
10         <div class="panel panel-default">
11             <div class="panel-body">
12                 <table class="table table-hover table-bordered" id="transformation_ids_deletion_table">
13                 </table>
14             </div>
15         </div>
16         <button class="btn btn-default" id="delete_all_transformation_ids" role="button">Delete all transformation ids in this project</button><br/><br/>
17     </div>
18 </&>
20 <&| /page/info_section.mas, id=>'delete_transformation_project_section', title => 'Delete Transformation Project', subtitle => '<font color="red">Deletion cannot be undone. Please delete transformation ids in this project first</font>', collapsible=>1, collapsed=>1 &>
21     <div class="well well-sm">
22         <div class="panel panel-default">
23             <div class="panel-body">
24                 <button class="btn btn-default" id="delete_transformation_project" role="button">Delete transformation project</button><br/><br/>
25             </div>
26         </div>
27     </div>
28 </&>
31 <script>
33 jQuery(document).ready(function(){
36     jQuery('#delete_transformation_project').click(function() {
37         var trial_id = "<% $trial_id %>";
38         var confirmation = confirm("Are you sure you want to delete this transformation project? The deletion cannot be undone.");
39         if (confirmation) {
40             jQuery.ajax({
41                 url: '/ajax/breeders/trial/'+trial_id+'/delete/transformation_project',
42                 beforeSend: function(){
43                     jQuery('#working_modal').modal("show");
44                 },
45                 success: function(response) {
46                     jQuery('#working_modal').modal('hide');
47                     if (response.success == 1) {
48                         alert('Deletion was successful');
49                         location.reload();
50                     }
51                     if (response.error) {
52                         alert(response.error);
53                     }
54                 },
55                 error: function(response) {
56                     jQuery('#working_modal').modal('hide');
57                     alert('An error occurred during deletion');
58                 }
59             });
60         }
61     });
63 });
66 </script>