diff options
Diffstat (limited to 'data/assets')
-rw-r--r-- | data/assets/js/admin/dialogs/user-add.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/data/assets/js/admin/dialogs/user-add.js b/data/assets/js/admin/dialogs/user-add.js index 692d8a4..16757bb 100644 --- a/data/assets/js/admin/dialogs/user-add.js +++ b/data/assets/js/admin/dialogs/user-add.js @@ -6,6 +6,7 @@ jQuery(function($) { $('#user-add-' + id).val(''); }); $('#user-add-role').val('viewer'); + $('#user-add-active').val('inactive'); }); $('#user-add-dialog').on('shown.bs.modal', function() { @@ -32,19 +33,27 @@ jQuery(function($) { // toggle loading me.toggleClass('disabled').find('.loading').toggleClass('hidden'); - send('test/add_user', { + send('user/add', { name: $('#user-add-name').val(), email: $('#user-add-email').val(), password: $('#user-add-password').val(), role: $('#user-add-role').val(), - active: 't', + active: ($('#user-add-active').val() == 'active') ? 't' : 'f', }).always(function() { // toggle loading me.toggleClass('disabled').find('.loading').toggleClass('hidden'); }).fail(function(r) { - alert('Error ' + r.responseText); + var error = r.responseText; + + try { + var data = $.parseJSON(r.responseText); + + if (data.error) + error = data.error; + } catch (e) {} + + alert('Error: ' + error); }).done(function(r) { - console.log(r); $('#users-reload').click(); $('#user-add-dialog').modal('hide'); }); |