typus 0.9.20 → 0.9.21
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/VERSION +1 -1
- data/app/helpers/admin/table_helper.rb +9 -16
- data/test/helpers/admin/table_helper_test.rb +1 -1
- data/typus.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.21
|
@@ -19,17 +19,17 @@ module Admin::TableHelper
|
|
19
19
|
fields.each do |key, value|
|
20
20
|
case value
|
21
21
|
when :boolean then html << typus_table_boolean_field(key, item)
|
22
|
-
when :datetime then html << typus_table_datetime_field(key, item,
|
23
|
-
when :date then html << typus_table_datetime_field(key, item,
|
24
|
-
when :file then html << typus_table_file_field(key, item,
|
25
|
-
when :time then html << typus_table_datetime_field(key, item,
|
22
|
+
when :datetime then html << typus_table_datetime_field(key, item, link_options)
|
23
|
+
when :date then html << typus_table_datetime_field(key, item, link_options)
|
24
|
+
when :file then html << typus_table_file_field(key, item, link_options)
|
25
|
+
when :time then html << typus_table_datetime_field(key, item, link_options)
|
26
26
|
when :belongs_to then html << typus_table_belongs_to_field(key, item)
|
27
27
|
when :tree then html << typus_table_tree_field(key, item)
|
28
28
|
when :position then html << typus_table_position_field(key, item)
|
29
29
|
when :has_and_belongs_to_many then
|
30
30
|
html << typus_table_has_and_belongs_to_many_field(key, item)
|
31
31
|
else
|
32
|
-
html << typus_table_string_field(key, item,
|
32
|
+
html << typus_table_string_field(key, item, link_options)
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
@@ -142,13 +142,13 @@ module Admin::TableHelper
|
|
142
142
|
HTML
|
143
143
|
end
|
144
144
|
|
145
|
-
def typus_table_string_field(attribute, item,
|
145
|
+
def typus_table_string_field(attribute, item, link_options = {})
|
146
146
|
<<-HTML
|
147
147
|
<td>#{item.send(attribute)}</td>
|
148
148
|
HTML
|
149
149
|
end
|
150
150
|
|
151
|
-
def typus_table_file_field(attribute, item,
|
151
|
+
def typus_table_file_field(attribute, item, link_options = {})
|
152
152
|
<<-HTML
|
153
153
|
<td><a href="##{item.to_dom(:suffix => 'zoom')}" id="#{item.to_dom}" title="Click to preview">#{item.send(attribute)}</a></td>
|
154
154
|
<div id="#{item.to_dom(:suffix => 'zoom')}">#{item.typus_preview}</div>
|
@@ -184,17 +184,10 @@ module Admin::TableHelper
|
|
184
184
|
|
185
185
|
end
|
186
186
|
|
187
|
-
def typus_table_datetime_field(attribute, item,
|
188
|
-
|
189
|
-
action = item.class.typus_options_for(:default_action_on_item)
|
187
|
+
def typus_table_datetime_field(attribute, item, link_options = {} )
|
190
188
|
|
191
189
|
date_format = item.class.typus_date_format(attribute)
|
192
|
-
|
193
|
-
content = if first_field == attribute
|
194
|
-
link_to value, link_options.merge(:controller => "admin/#{item.class.name.tableize}", :action => action, :id => item.id )
|
195
|
-
else
|
196
|
-
value
|
197
|
-
end
|
190
|
+
content = !item.send(attribute).nil? ? item.send(attribute).to_s(date_format) : item.class.typus_options_for(:nil)
|
198
191
|
|
199
192
|
<<-HTML
|
200
193
|
<td>#{content}</td>
|
@@ -206,7 +206,7 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
|
|
206
206
|
|
207
207
|
output = typus_table_datetime_field(:created_at, post, :created_at)
|
208
208
|
expected = <<-HTML
|
209
|
-
<td
|
209
|
+
<td>#{post.created_at.strftime('%m/%y')}</td>
|
210
210
|
HTML
|
211
211
|
|
212
212
|
assert_equal expected, output
|
data/typus.gemspec
CHANGED