From a5757765b0f5f17d7ab9916b6fe9c3127b41790b Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 26 May 2016 00:38:47 -0400 Subject: populate user-add dialog --- data/assets/js/admin/dialogs/user-add.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'data/assets/js') 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'); }); -- cgit v1.2.3