diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-05-26 00:38:47 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-05-26 00:38:47 -0400 |
commit | a5757765b0f5f17d7ab9916b6fe9c3127b41790b (patch) | |
tree | 3745f2982f710d5195b3f75d4b02df4b0fdc77c7 /data/assets/js/admin | |
parent | 377ffbe0f9e3749bcebd3e61ef9623cc45485dd8 (diff) | |
download | guff-a5757765b0f5f17d7ab9916b6fe9c3127b41790b.tar.bz2 guff-a5757765b0f5f17d7ab9916b6fe9c3127b41790b.zip |
populate user-add dialog
Diffstat (limited to 'data/assets/js/admin')
-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'); }); |