diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-07-29 17:10:50 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-07-29 17:10:50 -0400 |
commit | 0c2d54c6159cf4b9e4c93e43c18ad4d08bf54faf (patch) | |
tree | 743a1f36336db69c2e95fc9d02e7a5e26fe2f963 /data/assets/js/admin/dialogs | |
parent | 80c76ca5320ca3b45ed6bf4a2d4530c6dad59c3c (diff) | |
download | guff-0c2d54c6159cf4b9e4c93e43c18ad4d08bf54faf.tar.bz2 guff-0c2d54c6159cf4b9e4c93e43c18ad4d08bf54faf.zip |
enable generate secret button and add gripe()
Diffstat (limited to 'data/assets/js/admin/dialogs')
-rw-r--r-- | data/assets/js/admin/dialogs/post-edit.js | 10 | ||||
-rw-r--r-- | data/assets/js/admin/dialogs/project-edit.js | 16 | ||||
-rw-r--r-- | data/assets/js/admin/dialogs/user-add.js | 11 | ||||
-rw-r--r-- | data/assets/js/admin/dialogs/user-edit.js | 11 |
4 files changed, 19 insertions, 29 deletions
diff --git a/data/assets/js/admin/dialogs/post-edit.js b/data/assets/js/admin/dialogs/post-edit.js index 3b20c7a..9d90b99 100644 --- a/data/assets/js/admin/dialogs/post-edit.js +++ b/data/assets/js/admin/dialogs/post-edit.js @@ -109,15 +109,7 @@ jQuery(function($) { $(p + 'confirm').removeClass('disabled') .find('.loading').toggleClass('hidden'); }).fail(function(r) { - var error = r.responseText; - - try { - var data = $.parseJSON(r.responseText); - if (data.error) - error = data.error; - } catch (e) {} - - alert('Error: ' + error); + gripe(r, 'save changes'); }).done(function(r) { // reload posts $('#posts-reload').click(); diff --git a/data/assets/js/admin/dialogs/project-edit.js b/data/assets/js/admin/dialogs/project-edit.js index 17236f6..8df9364 100644 --- a/data/assets/js/admin/dialogs/project-edit.js +++ b/data/assets/js/admin/dialogs/project-edit.js @@ -21,4 +21,20 @@ jQuery(function($) { // stop event return false; }); + + $('#project-edit-generate-secret').click(function() { + var me = $(this); + + // disable button + me.toggleClass('disabled').find('.fa').toggleClass('fa-spin'); + send('project/generate_secret').always(function() { + // enable button + me.toggleClass('disabled').find('.fa').toggleClass('fa-spin'); + }).fail(function(r) { + gripe(r, 'generate secret'); + }).done(function(r) { + // update secret + $('#project-edit-secret').val(r.secret); + }); + }); }); diff --git a/data/assets/js/admin/dialogs/user-add.js b/data/assets/js/admin/dialogs/user-add.js index 16757bb..7e78923 100644 --- a/data/assets/js/admin/dialogs/user-add.js +++ b/data/assets/js/admin/dialogs/user-add.js @@ -43,16 +43,7 @@ jQuery(function($) { // toggle loading me.toggleClass('disabled').find('.loading').toggleClass('hidden'); }).fail(function(r) { - var error = r.responseText; - - try { - var data = $.parseJSON(r.responseText); - - if (data.error) - error = data.error; - } catch (e) {} - - alert('Error: ' + error); + gripe(r, 'add user'); }).done(function(r) { $('#users-reload').click(); $('#user-add-dialog').modal('hide'); diff --git a/data/assets/js/admin/dialogs/user-edit.js b/data/assets/js/admin/dialogs/user-edit.js index 038a587..70c1dc3 100644 --- a/data/assets/js/admin/dialogs/user-edit.js +++ b/data/assets/js/admin/dialogs/user-edit.js @@ -75,16 +75,7 @@ jQuery(function($) { // toggle loading me.toggleClass('disabled').find('.loading').toggleClass('hidden'); }).fail(function(r) { - var error = r.responseText; - - try { - // try to extract error message from json response - var data = $.parseJSON(r.responseText); - if ('error' in data) - error = data.error; - } catch (e) {} - - alert('Error: ' + error); + gripe(r, 'save user'); }).done(function(r) { $('#users-reload').click(); $('#user-edit-dialog').modal('hide'); |