transponder 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/assets/javascripts/transponder/presenter.coffee +15 -14
- data/lib/transponder/transmission.rb +24 -10
- data/lib/transponder/version.rb +1 -1
- data/lib/transponder.rb +0 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae5313ea40c13eddf346a725c50263a3e021f940
|
4
|
+
data.tar.gz: 867c027783309a27f902b128e41eb3485f69742f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc31fd7c4e0c31d34903aafcbaa1ab99ae3f831377036c0f3ad14e770f2a2b4856894976792353c741c33cfec897b5a97fc5bf3d7e84fc2b591823725f1dfd94
|
7
|
+
data.tar.gz: 6222353d06d23fbb60cb798221be528da21891d95f139031cc30d7f9dcec7f5355ba2c8674b1793557989e68d22742acdc9bd373b590be1c7f2a6273e9cf2b89
|
@@ -22,7 +22,7 @@ class Transponder.Presenter
|
|
22
22
|
|
23
23
|
elify: (event, response) ->
|
24
24
|
if @response.errors
|
25
|
-
if @response.id then "##{@
|
25
|
+
if @response.id then "##{@response.model_name}_#{@response.id}" else "#new_#{@response.model_name}"
|
26
26
|
else
|
27
27
|
"#{event.target.localName}##{event.target.id}"
|
28
28
|
|
@@ -34,7 +34,7 @@ class Transponder.Presenter
|
|
34
34
|
runAction: (event, response) =>
|
35
35
|
@beforeFilter(event, response)
|
36
36
|
if @response.errors
|
37
|
-
@errorOut()
|
37
|
+
@errorOut(@response.action)
|
38
38
|
else
|
39
39
|
@[event.type.split(':').pop()]()
|
40
40
|
@afterFilter(event, response)
|
@@ -45,12 +45,10 @@ class Transponder.Presenter
|
|
45
45
|
triggerEmpty: (eventName) ->
|
46
46
|
console.log "#{eventName} triggered! Override this action in your own presenter"
|
47
47
|
|
48
|
-
triggerEmptyError: (eventName) ->
|
49
|
-
console.log "Error #{eventName} triggered! Override this action in your own presenter"
|
50
48
|
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
|
50
|
+
errorOut: (action) ->
|
51
|
+
@error[action](@response.errors, @element)
|
54
52
|
|
55
53
|
index: ->
|
56
54
|
@triggerEmpty('Index')
|
@@ -68,17 +66,20 @@ class Transponder.Presenter
|
|
68
66
|
@triggerEmpty('Destroy')
|
69
67
|
|
70
68
|
error:
|
71
|
-
|
69
|
+
triggerEmptyError: (eventName) ->
|
70
|
+
console.log "Error #{eventName} triggered! Override this action in your own presenter"
|
71
|
+
|
72
|
+
index: (errors, element) ->
|
72
73
|
@triggerEmptyError('Index')
|
73
|
-
show: ->
|
74
|
+
show: (errors, element) ->
|
74
75
|
@triggerEmptyError('Show')
|
75
|
-
new: ->
|
76
|
+
new: (errors, element) ->
|
76
77
|
@triggerEmptyError('New')
|
77
|
-
edit: ->
|
78
|
+
edit: (errors, element) ->
|
78
79
|
@triggerEmptyError('Edit')
|
79
|
-
update: ->
|
80
|
+
update: (errors, element) ->
|
80
81
|
@triggerEmptyError('Update')
|
81
|
-
create: ->
|
82
|
+
create: (errors, element) ->
|
82
83
|
@triggerEmptyError('Create')
|
83
|
-
destroy: ->
|
84
|
+
destroy: (errors, element) ->
|
84
85
|
@triggerEmptyError('Destroy')
|
@@ -4,18 +4,32 @@ module Transponder
|
|
4
4
|
|
5
5
|
included do
|
6
6
|
after_filter :intercept_js
|
7
|
+
helper_method :xms_module_name
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def xms_module_name
|
11
|
+
params[:controller].include?('/') ? params[:controller].split('/')[0] : 'application'
|
12
|
+
end
|
13
|
+
|
14
|
+
def xms_error_hash(object, message, action, module_name)
|
15
|
+
{
|
16
|
+
errors: (message || object.errors ),
|
17
|
+
controller: controller_name,
|
18
|
+
action: (action || action_name),
|
19
|
+
model_name: object.class.name.downcase,
|
20
|
+
id: object.id,
|
21
|
+
module: (module_name || xms_module_name)
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def xms_error object, message: nil, action: nil, module_name: nil
|
26
|
+
render json: xms_error_hash(object, message, action, module_name),
|
27
|
+
status: :unprocessable_entity
|
28
|
+
end
|
14
29
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
30
|
+
def intercept_js
|
31
|
+
if request.format == :js
|
32
|
+
response.header['Content-Type'] = "application/transmission"
|
19
33
|
end
|
20
34
|
end
|
21
35
|
end
|
data/lib/transponder/version.rb
CHANGED
data/lib/transponder.rb
CHANGED
@@ -16,10 +16,6 @@ require 'transponder/transmission'
|
|
16
16
|
|
17
17
|
module Transponder
|
18
18
|
module ViewHelpers
|
19
|
-
def xms_module_name
|
20
|
-
params[:controller].include?('/') ? params[:controller].split('/')[0] : nil
|
21
|
-
end
|
22
|
-
|
23
19
|
def xms_event(module_name: nil, action: nil)
|
24
20
|
_module = module_name || xms_module_name || 'application'
|
25
21
|
_action = action || action_name
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transponder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zack Siri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coffee-rails
|