From 7788012457346ae59fa58ed35fc08aa2b9e6b9ef Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sat, 2 Apr 2016 00:25:20 -0400 Subject: add add-dialog and edit-dialog --- data/stuff/test/auth.js | 36 +++-- src/guff/views/ecrs/test/auth.ecr | 297 +++++++++++++++++++++++++++----------- 2 files changed, 239 insertions(+), 94 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 diff --git a/src/guff/views/ecrs/test/auth.ecr b/src/guff/views/ecrs/test/auth.ecr index ec6e9a8..b683c5c 100644 --- a/src/guff/views/ecrs/test/auth.ecr +++ b/src/guff/views/ecrs/test/auth.ecr @@ -7,15 +7,16 @@ <%= - h(TITLE) - %> + > + + <%= h(TITLE) %> +
-
+
@@ -23,20 +24,35 @@ Users - - - - + + +
@@ -46,26 +62,95 @@
-
-
- - Create User + + Login
-
+ +
+ + + +
+ +
+ +
+
+
+
+
+ + -
+ +
+ + +
+ + -- cgit v1.2.3