typus 0.9.21 → 0.9.22
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/helpers/admin/form_helper.rb +18 -6
- data/app/helpers/typus_helper.rb +2 -2
- data/typus.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.22
|
@@ -93,15 +93,25 @@ module Admin::FormHelper
|
|
93
93
|
HTML
|
94
94
|
end
|
95
95
|
|
96
|
+
# WEI: Added image preview.
|
96
97
|
def typus_file_field(attribute)
|
97
|
-
|
98
98
|
attribute_display = attribute.split('_file_name').first
|
99
|
-
|
99
|
+
unless @item.send(attribute).blank?
|
100
|
+
if attachment = @item.send(attribute_display)
|
101
|
+
if (@item.send("#{attribute_display}_content_type") =~ /^image\/.+/) and (attachment.styles.member?(:thumbnail) or attachment.styles.member?(:edit))
|
102
|
+
style = attachment.styles.member?(:thumbnail) ? :thumbnail : :edit
|
103
|
+
preview = image_tag attachment.url(style)
|
104
|
+
else
|
105
|
+
preview = link_to @item.send(attribute), attachment.url
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
100
109
|
<<-HTML
|
101
|
-
<li><label for="item_#{attribute}">#{_(attribute_display.humanize)}</label>
|
102
|
-
#{file_field :item, attribute.split("_file_name").first, :disabled => attribute_disabled?(attribute)}
|
110
|
+
<li><label for="item_#{attribute}">#{_(attribute_display.humanize)}</label>
|
111
|
+
#{file_field :item, attribute.split("_file_name").first, :disabled => attribute_disabled?(attribute)}
|
112
|
+
#{preview}
|
113
|
+
</li>
|
103
114
|
HTML
|
104
|
-
|
105
115
|
end
|
106
116
|
|
107
117
|
def typus_password_field(attribute)
|
@@ -225,7 +235,9 @@ module Admin::FormHelper
|
|
225
235
|
association = reflection.macro
|
226
236
|
foreign_key = reflection.through_reflection ? reflection.primary_key_name.pluralize : reflection.primary_key_name
|
227
237
|
|
228
|
-
|
238
|
+
#WEI: Changed link to use type name rather than field:
|
239
|
+
#WEI: link_options = { :controller => "admin/#{field}",
|
240
|
+
link_options = { :controller => "admin/#{model_to_relate_as_resource.pluralize}",
|
229
241
|
:action => 'new',
|
230
242
|
:back_to => "#{@back_to}##{field}",
|
231
243
|
:resource => @resource[:self].singularize,
|
data/app/helpers/typus_helper.rb
CHANGED
@@ -8,7 +8,7 @@ module TypusHelper
|
|
8
8
|
returning(String.new) do |html|
|
9
9
|
|
10
10
|
Typus.applications.each do |app|
|
11
|
-
|
11
|
+
|
12
12
|
available = Typus.application(app).map do |resource|
|
13
13
|
resource if @current_user.resources.include?(resource)
|
14
14
|
end
|
@@ -21,7 +21,7 @@ module TypusHelper
|
|
21
21
|
</tr>
|
22
22
|
HTML
|
23
23
|
|
24
|
-
available.compact.each do |model|
|
24
|
+
available.compact.sort_by{|x| x.constantize.typus_human_name }.each do |model|
|
25
25
|
|
26
26
|
klass = model.constantize
|
27
27
|
klass_resource = klass.name.tableize
|
data/typus.gemspec
CHANGED