Merge pull request #5243 from solgenomics/topic/observations_upload_catch_error
[sgn.git] / mason / tracking_activities / update_status_dialog.mas
blobbca4f83a82ab70372021be2f9e3d4877bb2cdac3
1 <%args>
2 $identifier_id
3 $identifier_name
4 $material_id
5 $updated_status_type
6 $program_name
7 </%args>
9 <div class="modal fade" id="update_status_dialog" name="_dialog" tabindex="-1" role="dialog" aria-labelledby="updateStatusDialog">
10     <div class="modal-dialog modal-lg" role="document">
11         <div class="modal-content">
12             <div class="modal-header">
13                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
14                 <h4 class="modal-title" id="updateStatusDialog">Mark this experiment as completed or terminated </h4>
15             </div>
16             <div class="modal-body">
17                 <div class="container-fluid">
18                     <form class="form-horizontal" role="form" method="post" id="update_status_form" name="update_status_form">
19                         <div class="form-group">
20                             <label class="col-sm-4 control-label">Tracking Identifier: </label>
21                             <div class="col-sm-8" >
22                                 <input class="form-control" name="tracking_identifier_name" id="tracking_identifier_name" disabled value="<% $identifier_name %>">
23                             </div>
24                         </div>
25                         <div class="form-group">
26                             <label class="col-sm-4 control-label">Status Type: </label>
27                             <div class="col-sm-8">
28                                 <select class="form-control" id="status_type">
29                                     <option value="">Select a status type</option>
30                                     <option value="completed">completed</option>
31                                     <option value="terminated">terminated</option>
32                                 </select>
33                             </div>
34                         </div>
35                         <div class="form-group">
36                             <label class="col-sm-4 control-label">Comments: </label>
37                             <div class="col-sm-8" >
38                                 <textarea class="form-control" id="comments_for_updating" name="comments_for_updating" placeholder="Optional"></textarea>
39                             </div>
40                         </div>
41                     </form>
42                 </div>
43             </div>
44             <div class="modal-footer">
45                 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
46                 <button type="button" class="btn btn-primary" name="update_status_submit" id="update_status_submit">Submit</button>
47             </div>
48         </div>
49     </div>
50 </div>
52 <div class="modal fade" id="updated_saved_dialog_message" name="updated_saved_dialog_message" tabindex="-1" role="dialog" aria-labelledby="updatedSavedDialog">
53     <div class="modal-dialog" role="document">
54         <div class="modal-content">
55             <div class="modal-header">
56                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
57                 <h4 class="modal-title" id="updatedSavedDialog">Success</h4>
58             </div>
59             <div class="modal-body">
60                 <div class="container-fluid">
61                     <p>
62                         <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
63                         The status of this experiment has been updated.
64                     </p>
65                 </div>
66             </div>
67             <div class="modal-footer">
68                 <button id="dismiss_updated_saved_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close & Reload</button>
69             </div>
70         </div>
71     </div>
72 </div>
74 <div class="modal fade" id="reverse_status_dialog_message" name="reverse_status_dialog_message" tabindex="-1" role="dialog" aria-labelledby="reverseStatusDialog">
75     <div class="modal-dialog" role="document">
76         <div class="modal-content">
77             <div class="modal-header">
78                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
79                 <h4 class="modal-title" id="reverseStatusDialog">Success</h4>
80             </div>
81             <div class="modal-body">
82                 <div class="container-fluid">
83                     <p>
84                         <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
85                         This experiment has been restored.
86                     </p>
87                 </div>
88             </div>
89             <div class="modal-footer">
90                 <button id="dismiss_reverse_status_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close & Reload</button>
91             </div>
92         </div>
93     </div>
94 </div>
97 <script>
98 jQuery(document).ready(function(){
100     var identifier_id = "<% $identifier_id %>";
101     var material_id = "<% $material_id %>";
102     var program_name = "<% $program_name %>";
104     jQuery("#update_status_link").click( function() {
105         jQuery('#update_status_dialog').modal('show');
106     });
108     jQuery('#update_status_submit').click(function() {
110         var status_type = jQuery('#status_type').val();
111         var comments = jQuery('#comments_for_updating').val();
113         if (identifier_id === '') {
114             alert("Error retrieving identifier info");
115             return;
116         }
118         if (status_type === '') {
119             alert("Please select a status type");
120             return;
121         }
123         jQuery.ajax({
124             url: '/ajax/tracking_activity/update_status',
125             type: 'POST',
126             dataType: "json",
127             data : {
128                 'identifier_id': identifier_id,
129                 'status_type': status_type,
130                 'material_id': material_id,
131                 'comments': comments,
132                 'program_name': program_name,
133             },
134             beforeSend: function(response){
135                 jQuery('#working_modal').modal('show');
136             },
137             success: function(response) {
138                 jQuery('#working_modal').modal('hide');
139                 if (response.success == 1) {
140                     jQuery('#update_status_dialog').modal('hide');
141                     jQuery('#updated_saved_dialog_message').modal("show");
142                 }
143                 if (response.error_string) {
144                     alert(response.error_string);
145                 }
146             },
147             error: function(response){
148                 jQuery('#working_modal').modal('hide');
149                 alert('An error occurred updating status');
150             }
151         });
152     });
154     jQuery("#dismiss_updated_saved_dialog").click( function() {
155         jQuery('#updated_saved_dialog_message').modal('hide');
156         location.reload();
157     });
159     jQuery('#reverse_status_link').click(function() {
160         var updated_status_type = "<% $updated_status_type %>";
161         var confirmation = confirm("Are you sure you want to reverse status of this tracking identifier ?");
162         if (confirmation) {
163             jQuery.ajax({
164                 url: '/ajax/tracking_activity/reverse_status',
165                 type: 'POST',
166                 dataType: "json",
167                 data : {
168                     'identifier_id' : identifier_id,
169                     'updated_status_type' : updated_status_type,
170                     'material_id' : material_id,
171                     'program_name' : program_name,
172                 },
173                 beforeSend: function(response){
174                     jQuery('#working_modal').modal('show');
175                 },
176                 success: function(response) {
177                     jQuery('#working_modal').modal('hide');
178                     if (response.success == 1) {
179                         jQuery('#reverse_status_dialog_message').modal("show");
180                     }
181                     if (response.error_string) {
182                         alert(response.error_string);
183                     }
184                 },
185                 error: function(response){
186                     jQuery('#working_modal').modal('hide');
187                     alert('An error occurred processing your request');
188                 }
189             });
190         }
191     });
193     jQuery("#dismiss_reverse_status_dialog").click( function() {
194         jQuery('#reverse_status_dialog_message').modal('hide');
195         location.reload();
196     });
201 </script>