6 <div class="modal fade" id="add_person_role_dialog" name="add_person_role_dialog" tabindex="-1" role="dialog" aria-labelledby="addPersonRoleDialog">
7 <div class="modal-dialog" role="document">
8 <div class="modal-content">
9 <div class="modal-header">
10 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
11 <h4 class="modal-title" id="addPersonRoleDialog">Give Role to User</h4>
13 <div class="modal-body">
14 <div class="container-fluid">
16 <form class="form-horizontal" >
17 <div class="form-group">
18 <label class="col-sm-3 control-label">Username: </label>
19 <div class="col-sm-9" >
20 <div id="add_person_role_person_select_div">
25 <div class="form-group">
26 <label class="col-sm-3 control-label">Role: </label>
27 <div class="col-sm-9" >
28 <div id="add_person_role_role_select_div">
37 <div class="modal-footer">
38 <button type="button" class="btn btn-default" name="add_person_role_cancel_button" id="add_person_role_cancel_button" data-dismiss="modal">Close</button>
39 <button type="button" class="btn btn-primary" name="add_person_role_submit_button" id="add_person_role_submit_button" title="Submit">Submit</button>
47 jQuery(document).ready(function() {
49 jQuery('#add_person_role_button').click( function () {
52 url : '/ajax/people/people_and_roles',
53 beforeSend: function() {
54 jQuery("#working_modal").modal("show");
56 success: function(response){
57 //console.log(response);
58 jQuery("#working_modal").modal("hide");
60 var sp_person_html = '<select class="form-control" id="add_person_role_person_select">';
61 for (var i=0; i<response.sp_persons.length; i++) {
62 sp_person_html = sp_person_html + '<option value="'+response.sp_persons[i][1]+'">'+response.sp_persons[i][0]+'</option>';
64 jQuery('#add_person_role_person_select_div').empty().html(sp_person_html);
66 var sp_role_html = '<select class="form-control" id="add_person_role_role_select">';
67 for (var i=0; i<response.sp_roles.length; i++) {
68 sp_role_html = sp_role_html + '<option value="'+response.sp_roles[i][1]+'">'+response.sp_roles[i][0]+'</option>';
70 jQuery('#add_person_role_role_select_div').empty().html(sp_role_html);
72 error: function(response) {
73 jQuery("#working_modal").modal("hide");
74 alert('An error occured: '+response);
78 jQuery('#add_person_role_dialog').modal("show");
82 jQuery('#add_person_role_submit_button').click( function () {
84 url : '/ajax/people/add_person_role?sp_person_id='+jQuery("#add_person_role_person_select").val()+'&sp_role_id='+jQuery("#add_person_role_role_select").val(),
85 beforeSend: function() {
86 jQuery("#working_modal").modal("show");
88 success: function(response){
89 //console.log(response);
90 jQuery("#working_modal").modal("hide");
92 alert('Error: '+response.error);
94 alert('Role Added for User!');
97 error: function(response) {
98 jQuery("#working_modal").modal("hide");
99 alert('An error occured: '+response);