Merge pull request #5248 from solgenomics/topic/batch_update_trials
[sgn.git] / mason / tracking_activities / generate_tracking_identifiers_dialog.mas
blob0a4cffd5ef4936e129e90bd60fc69bcd4bdf393d
1 <%args>
3 $trial_name
4 $breeding_program_name
6 </%args>
9 <div class="modal fade" id="generate_tracking_identifiers_dialog" name="generate_tracking_identifiers_dialog" tabindex="-1" role="dialog" aria-labelledby="generateTrackingIdentifiersDialog">
10     <div class="modal-dialog modal-xl" role="document">
11         <div class="modal-content ui-front">
12             <div class="modal-header">
13                 <button type="reset" class="close" id="generate_tracking_identifiers_dismiss_button_1" name="generate_tracking_identifiers_dismiss_button" aria-label="Close"><span aria-hidden="true">&times;</span></button>
14                 <center><h4 class="modal-title" id="addTransactions">Generate Tracking Identifiers</h4></center>
15             </div>
16             <div class="modal-body">
17                 <div class="container-fluid">
19                     <&| /util/workflow.mas, id=> "add_transactions_workflow" &>
20                         <&| /util/workflow.mas:step, title=> "Intro" &>
21                             <& /page/page_title.mas, title=>"Tracking Identifiers" &>
22                             <p>Tracking identifier is a globally unique name assigned to each material for capturing tracking information. By providing a list of materials, tracking identifier for each item is auto-generated by combining project name, item name and an incrementing number suffix. All items in a list must be the same stock type.</p>
23                             <hr>
24                             <center>
25                                 <button id="next_step_add_new_intro" class="btn btn-primary" onclick="Workflow.complete(this);">Go to Next Step</button>
26                             </center>
27                         </&>
29                         <form class="form-horizontal" role="form" name="generate_tracking_identifiers_form" id="generate_tracking_identifiers_form">
30                             <&| /util/workflow.mas:step, title=> "Generate Tracking Identifiers" &>
31                                 <& /page/page_title.mas, title=>"" &>
32                                 <br/>
33                                 <div class="form-horizontal">
34                                     <div class="form-group">
35                                         <label class="col-sm-4 control-label">Material Type: </label>
36                                         <div class="col-sm-8">
37                                             <div class="input-group">
38                                                 <select class="form-control" id="material_type">
39                                                     <option value="">Please select a material type </option>
40                                                     <option value="accessions">accession</option>
41                                                     <option value="seedlots">seedlot</option>
42                                                 </select>
43                                             </div>
44                                         </div>
45                                     </div>
46                                     <div class="form-group" id="get_list_of_items" style="display: none">
47                                         <label class="control-label col-sm-4">List of Items:</label>
48                                         <div class="col-sm-8" >
49                                             <div class="input-group">
50                                                 <select class="form-control" id="item_list_select"></select>
51                                             </div>
52                                         </div>
53                                     </div>
54                                 </div>
55                                 <br/>
56                                 <div id="form_footer"  >
57                                     <center>
58                                         <button type="button" class="btn btn-primary" onclick="Workflow.complete(this, false);" name="generate_tracking_identifiers_submit" id="generate_tracking_identifiers_submit">Submit</button>
59                                     </center>
60                                 </div>
61                             </&>
62                         </form>
64                         <&| /util/workflow.mas:complete, title=> "Complete" &>
65                             <& /page/page_title.mas, title=>"Finished! Tracking Identifiers were stored" &>
66                             <p>
67                                 <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
68                                 New tracking identifiers were generated successfully
69                             </p>
70                             <br/>
71                         </&>
72                     </&><!-- End of workflow -->
73                 </div>
74             </div>
75             <div class="modal-footer">
76                 <button id="generate_tracking_identifiers_dismiss_button_2" name="generate_tracking_identifiers_dismiss_button" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
77             </div>
78         </div>
79     </div>
80 </div>
82 <div class="modal fade" id="generate_tracking_identifiers_saved_dialog_message" name="generate_tracking_identifiers_saved_dialog_message" tabindex="-1" role="dialog" aria-labelledby="generateTrackingIdentifiersSavedDialog">
83     <div class="modal-dialog" role="document">
84         <div class="modal-content">
85             <div class="modal-header">
86                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
87                 <h4 class="modal-title" id="generateTrackingIdentifiersSavedDialog">Success</h4>
88             </div>
89             <div class="modal-body">
90                 <div class="container-fluid">
91                     <p>
92                         <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
93                         The tracking identifier for you materials were generated successfully.
94                     </p>
95                 </div>
96             </div>
97             <div class="modal-footer">
98                 <button id="dismiss_generate_tracking_identifiers_saved_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
99             </div>
100         </div>
101     </div>
102 </div>
104 <div class="modal fade" id="tracking_identifiers_saved_dialog_message" name="tracking_identifiers_saved_dialog_message" tabindex="-1" role="dialog" aria-labelledby="trackingIdentifiersSavedDialog">
105     <div class="modal-dialog" role="document">
106         <div class="modal-content">
107             <div class="modal-header">
108                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
109                 <h4 class="modal-title" id="trackingIdentifiersSavedDialog">Success</h4>
110             </div>
111             <div class="modal-body">
112                 <div class="container-fluid">
113                     <p>
114                         <span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>
115                         New tracking identifiers were saved.
116                     </p>
117                 </div>
118             </div>
119             <div class="modal-footer">
120                 <button id="dismiss_tracking_identifiers_saved_dialog" type="button" class="btn btn-default" data-dismiss="modal">Close & Reload</button>
121             </div>
122         </div>
123     </div>
124 </div>
126 <script>
128 jQuery(document).ready(function(){
130     var lo = new CXGN.List();
131     var project_name = "<%$trial_name%>";
132     var program_name = "<%$breeding_program_name%>";
134     jQuery("#generate_identifiers_link").click(function(){
135         jQuery("#generate_tracking_identifiers_dialog").modal("show");
136     });
138     jQuery("#material_type").change(function() {
139         var selected_material_type = jQuery('#material_type').val();
140         jQuery('#item_list_select').html(lo.listSelect('item_list_select', [selected_material_type], 'Select a list of materials', undefined, undefined));
141         jQuery("#get_list_of_items").modal("show");
142     })
144     jQuery("#generate_tracking_identifiers_submit").click(function(){
145         var selected_material_type = jQuery('#material_type').val();
146         var item_list_id = jQuery('#item_list_select').val();
148         if (!selected_material_type) {
149             alert("Material type is required");
150             return;
151         }
153         if (!item_list_id) {
154             alert("Please select a list");
155             return;
156         }
158         var item_validation = 1;
159         item_validation = lo.legacy_validate(item_list_id, selected_material_type, true);
160         if (item_validation != 1) {
161             alert("This list did not pass validation. Names in the list must exist in the database and are the selected material type.");
162             return;
163         }
165         jQuery.ajax({
166             url: '/ajax/tracking_activity/generate_tracking_identifiers',
167             dataType: "json",
168             type: 'POST',
169             data : {
170                 'list_id' : item_list_id,
171                 'project_name': project_name,
172                 'program_name': program_name,
173             },
174             beforeSend: function(response){
175                 jQuery('#working_modal').modal('show');
176             },
177             success: function(response) {
178                 jQuery('#working_modal').modal('hide');
179                 if (response.success == 1) {
180                     jQuery("#generate_tracking_identifiers_dialog").modal("hide");
181                     jQuery("#tracking_identifiers_saved_dialog_message").modal("show");
182                 }
183                 if (response.error) {
184                     alert(response.error);
185                 }
186             },
187             error: function(response){
188                 jQuery('#working_modal').modal('hide');
189                 alert('An error occurred generating identifiers');
190             }
191         });
193     });
195     jQuery("#dismiss_tracking_identifiers_saved_dialog").click(function(){
196         jQuery("#tracking_identifiers_saved_dialog_message").modal("hide");
197         jQuery('#material_type').val('');
198         jQuery('#item_list_select').val('');
199         location.reload();
200     });
202     jQuery("[name = 'generate_tracking_identifiers_dismiss_button']").click(function() {
203         jQuery("#generate_tracking_identifiers_dialog").modal("hide");
204         jQuery("#material_type").val('');
205         jQuery('#item_list_select').val('');
206         location.reload();
207     });
213 </script>