index_for 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13d5d4c08ba3353a7bc7819f29ba79605d504e67
|
4
|
+
data.tar.gz: b734be697669314df6d431ec668b4b92d74609aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b5dd6b17a31a490ea2532cae86e1710467ae4996eefefe2a91e366c583914a1265ed9aef7a2ab39364932cbd3d765d06d06b37a770a606639094a16283c8fbc
|
7
|
+
data.tar.gz: efb127700ee84536d80c6d6390146fbfec3826cc306d175825460db60111aee086c19d3f6f7b14c083c72880de6b055e3f114237182e9684f0d30d1303eb98d2
|
@@ -7,25 +7,26 @@ module IndexFor
|
|
7
7
|
if block
|
8
8
|
@template.capture(@object, &block)
|
9
9
|
else
|
10
|
-
|
10
|
+
object = @html_options[:namespace] ? @html_options[:namespace].clone.push(@object) : @object
|
11
|
+
action_title = translate(:"actions.#{action_name}",
|
11
12
|
default: action_name.to_s.humanize).html_safe
|
12
13
|
action_html_options = apply_html_options :action_link, options[:html] || {}
|
13
14
|
append_class action_html_options, :"action_#{action_name}"
|
14
15
|
|
15
16
|
case action_name
|
16
17
|
when :show
|
17
|
-
@template.link_to action_title, @template.polymorphic_path(
|
18
|
+
@template.link_to action_title, @template.polymorphic_path(object),
|
18
19
|
action_html_options
|
19
20
|
when :destroy
|
20
|
-
@template.link_to action_title, @template.polymorphic_path(
|
21
|
+
@template.link_to action_title, @template.polymorphic_path(object),
|
21
22
|
{ data: { method: :destroy, confirm: translate(:"actions.confirmation")
|
22
23
|
}}.merge(action_html_options)
|
23
24
|
else
|
24
|
-
@template.link_to action_title, @template.polymorphic_path(
|
25
|
+
@template.link_to action_title, @template.polymorphic_path(object,
|
25
26
|
action: action_name), action_html_options
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
31
|
end
|
31
|
-
end
|
32
|
+
end
|
@@ -5,19 +5,20 @@ module IndexFor
|
|
5
5
|
|
6
6
|
def attribute attribute_name, options = {}, &block
|
7
7
|
append_html_class options, :"attr_#{attribute_name}"
|
8
|
-
wrap_content_with :table_body_cell, attribute_value(attribute_name,
|
8
|
+
wrap_content_with :table_body_cell, attribute_value(attribute_name,
|
9
9
|
options), options, &block
|
10
10
|
end
|
11
11
|
|
12
12
|
def actions *action_names, &block
|
13
13
|
options = action_names.extract_options!
|
14
14
|
options[:html] = apply_html_options :table_actions_cell, options
|
15
|
+
options[:namespace] = @html_options[:namespace]
|
15
16
|
|
16
|
-
content = @template.index_for_actions @object, *action_names,
|
17
|
+
content = @template.index_for_actions @object, *action_names,
|
17
18
|
options, &block
|
18
19
|
|
19
20
|
wrap_with :table_body_cell, content, options
|
20
21
|
end
|
21
22
|
|
22
23
|
end
|
23
|
-
end
|
24
|
+
end
|
data/lib/index_for/helper.rb
CHANGED
@@ -16,6 +16,14 @@ module IndexFor
|
|
16
16
|
|
17
17
|
tag = html_options[:table_tag] || IndexFor.table_tag
|
18
18
|
|
19
|
+
if objects.is_a?(Array) &&
|
20
|
+
objects.find do |o|
|
21
|
+
!o.is_a?(Symbol) && !o.is_a?(String) && !o.is_a?(ActiveRecord::Base)
|
22
|
+
end == objects.last
|
23
|
+
html_options[:namespace] = objects
|
24
|
+
objects = objects.pop
|
25
|
+
end
|
26
|
+
|
19
27
|
klass = html_options[:klass] || objects.try(:klass) || objects.first.class
|
20
28
|
|
21
29
|
html_options[:id] ||= index_for_id(klass)
|
@@ -44,7 +52,7 @@ module IndexFor
|
|
44
52
|
action_names = [:show, :edit, :destroy] if action_names == [:all]
|
45
53
|
|
46
54
|
builder = IndexFor::ActionBuilder.new(object, html_options, self)
|
47
|
-
|
55
|
+
|
48
56
|
content = capture(builder) do |a|
|
49
57
|
action_names.map do |action_name|
|
50
58
|
a.action_link action_name
|
@@ -137,4 +145,4 @@ module IndexFor
|
|
137
145
|
end
|
138
146
|
end
|
139
147
|
|
140
|
-
ActionView::Base.send :include, IndexFor::Helper
|
148
|
+
ActionView::Base.send :include, IndexFor::Helper
|
data/lib/index_for/version.rb
CHANGED