diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-04-02 00:25:20 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-04-02 00:25:20 -0400 |
commit | 7788012457346ae59fa58ed35fc08aa2b9e6b9ef (patch) | |
tree | b55f33ad548b7ba40ad6e037a6d1901c90e1c1b8 /data/stuff | |
parent | dc03d9202dae2a44af2410d68b2e35d500a8a5ac (diff) | |
download | old-guff-7788012457346ae59fa58ed35fc08aa2b9e6b9ef.tar.bz2 old-guff-7788012457346ae59fa58ed35fc08aa2b9e6b9ef.zip |
add add-dialog and edit-dialog
Diffstat (limited to 'data/stuff')
-rw-r--r-- | data/stuff/test/auth.js | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/data/stuff/test/auth.js b/data/stuff/test/auth.js index 6f10fbf..5876a41 100644 --- a/data/stuff/test/auth.js +++ b/data/stuff/test/auth.js @@ -60,6 +60,16 @@ jQuery(function($) { return false; } + function set_user(user_id) { + return send('test/set_user', { + user_id: user_id, + }).fail(function(r) { + alert('Error ' + r.responseText); + }).done(function(r) { + // do nothing + }); + } + $('#users').on('click', 'a.list-group-item', function() { var me = $(this); @@ -70,25 +80,27 @@ jQuery(function($) { // show spinner me.addClass('disabled').find('.loading').toggleClass('hidden'); - send('test/set_user', { - user_id: me.data('user_id'), - }).always(function() { + set_user(me.data('user_id')).always(function() { // hide spinner me.removeClass('disabled').find('.loading').toggleClass('hidden'); }).fail(function(r) { - alert('Error ' + r.responseText); // restore old highlight me.removeClass('active'); last.addClass('active'); - }).done(function(r) { - // do nothing }); // stop event return false; }); - $('#create-user').click(function() { + $('#add-dialog').on('show.bs.modal', function() { + $.each(['name', 'email', 'password'], function(i, id) { + $('#add-' + id).val(''); + }); + $('#add-role').val('guest'); + }); + + $('#add-confirm').click(function() { var me = $(this); if (me.hasClass('disabled')) @@ -98,11 +110,11 @@ jQuery(function($) { me.toggleClass('disabled').find('.loading').toggleClass('hidden'); send('test/add_user', { - name: $('#user-name').val(), + name: $('#add-name').val(), + email: $('#add-email').val(), + password: $('#add-password').val(), + role: $('#add-role').val(), active: 't', - email: $('#user-email').val(), - password: $('#user-password').val(), - role: $('#user-role').val(), }).always(function() { // toggle loading me.toggleClass('disabled').find('.loading').toggleClass('hidden'); @@ -110,6 +122,8 @@ jQuery(function($) { alert('Error ' + r.responseText); }).done(function(r) { console.log(r); + reload(); + $('#add-dialog').modal('hide'); }); // stop event |