hallo_rails 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/hallo_rails/version.rb
CHANGED
data/lib/hallo_rails.rb
CHANGED
@@ -19,27 +19,27 @@ module HalloRails
|
|
19
19
|
def editable object, method, options = {}
|
20
20
|
object_name = object.class.to_s.underscore
|
21
21
|
options.reverse_merge! tag: :div,
|
22
|
-
content: object.send(method),
|
22
|
+
content: object.send(method).try(:html_safe),
|
23
23
|
update_url: "#{locale_prefix}/#{object_name.pluralize}/#{object.to_param}",
|
24
24
|
blank_text: "<i>Click to Edit</i>".html_safe
|
25
25
|
|
26
26
|
content_tag options[:tag], options[:content].present? ? options[:content] : options[:blank_text],
|
27
27
|
class: "#{'editable' if !options.has_key?(:editable) or options[:editable]}",
|
28
28
|
id: "#{object_name}_#{method.to_s}",
|
29
|
-
data: { update_url: options[:update_url], model: object_name, method: method.to_s
|
29
|
+
data: { update_url: options[:update_url], model: object_name, method: method.to_s }.merge(options[:params] || {})
|
30
30
|
end
|
31
31
|
|
32
32
|
|
33
33
|
def form_editable object, method, options = {}
|
34
34
|
object_name = object.class.to_s.underscore
|
35
35
|
options.reverse_merge! tag: :div,
|
36
|
-
content: object.send(method),
|
36
|
+
content: object.send(method).try(:html_safe),
|
37
37
|
blank_text: "<i>Click to Edit</i>".html_safe
|
38
38
|
|
39
39
|
content_tag( options[:tag], options[:content].present? ? options[:content] : options[:blank_text],
|
40
40
|
class: 'form_editable',
|
41
41
|
id: "#{object_name}_#{method.to_s}",
|
42
|
-
data: { model: object_name, method: method.to_s }) +
|
42
|
+
data: { model: object_name, method: method.to_s }.merge(options[:params] || {})) +
|
43
43
|
text_area_tag( "#{object_name}[#{method}]", options[:content], style: "display:none" )
|
44
44
|
end
|
45
45
|
|
@@ -25,6 +25,10 @@ init = ->
|
|
25
25
|
method_data = {}
|
26
26
|
method_data[$el.data('method')] = $el.html()
|
27
27
|
data[ $el.data('model') ] = method_data
|
28
|
+
for property_name of $el.data()
|
29
|
+
if typeof $el.data(property_name) == 'string' and property_name != 'method' and
|
30
|
+
property_name != 'model' and property_name != 'updateUrl'
|
31
|
+
data[property_name] = $el.data(property_name)
|
28
32
|
|
29
33
|
$.ajax
|
30
34
|
url: $el.data('update-url')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hallo_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -59,7 +59,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
59
|
version: '0'
|
60
60
|
segments:
|
61
61
|
- 0
|
62
|
-
hash:
|
62
|
+
hash: 2819323486405819656
|
63
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
version: '0'
|
69
69
|
segments:
|
70
70
|
- 0
|
71
|
-
hash:
|
71
|
+
hash: 2819323486405819656
|
72
72
|
requirements: []
|
73
73
|
rubyforge_project:
|
74
74
|
rubygems_version: 1.8.24
|