This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 0975c05 Use the shared response processing
0975c05 is described below
commit 0975c05b9f319bf801e12130e7b84d208aa12e2f
Author: Sebb <[email protected]>
AuthorDate: Sat Dec 16 18:59:31 2017 +0000
Use the shared response processing
---
www/roster/views/mixins/add.js.rb | 11 +++--------
www/roster/views/mixins/mod.js.rb | 11 +++--------
2 files changed, 6 insertions(+), 16 deletions(-)
diff --git a/www/roster/views/mixins/add.js.rb
b/www/roster/views/mixins/add.js.rb
index e01283c..3017be6 100644
--- a/www/roster/views/mixins/add.js.rb
+++ b/www/roster/views/mixins/add.js.rb
@@ -46,14 +46,9 @@ class ProjectAdd < Vue::Mixin
@disabled = true
Polyfill.require(%w(Promise fetch)) do
fetch($options.add_action, args).then {|response|
- content_type = response.headers.get('content-type') || ''
- if response.status == 200 and content_type.include? 'json'
- response.json().then do |json|
- Vue.emit :update, json
- end
- else
- alert "#{response.status} #{response.statusText}"
- end
+
+ # raises alert if the response is not successful JSON
+ Utils.handle_json(response, lambda { |json| Vue.emit :update, json;
alert 'add' } )
jQuery("##{$options.add_tag}").modal(:hide)
@disabled = false
diff --git a/www/roster/views/mixins/mod.js.rb
b/www/roster/views/mixins/mod.js.rb
index 61bed53..15faf6f 100644
--- a/www/roster/views/mixins/mod.js.rb
+++ b/www/roster/views/mixins/mod.js.rb
@@ -44,14 +44,9 @@ class ProjectMod < Vue::Mixin
@disabled = true
Polyfill.require(%w(Promise fetch)) do
fetch($options.mod_action, args).then {|response|
- content_type = response.headers.get('content-type') || ''
- if response.status == 200 and content_type.include? 'json'
- response.json().then do |json|
- Vue.emit :update, json
- end
- else
- alert "#{response.status} #{response.statusText}"
- end
+
+ # raises alert if the response is not successful JSON
+ Utils.handle_json(response, lambda { |json| Vue.emit :update, json ;
alert 'mod' } )
jQuery("##{$options.mod_tag}").modal(:hide)
@disabled = false
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].