typus 0.9.28 → 0.9.29
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +25 -14
- data/VERSION +1 -1
- data/app/helpers/admin/form_helper.rb +16 -146
- data/app/helpers/admin/master_helper.rb +1 -1
- data/app/helpers/admin/table_helper.rb +3 -3
- data/app/helpers/typus_helper.rb +1 -9
- data/app/views/admin/resources/show.html.erb +5 -2
- data/app/views/admin/templates/_boolean.html.erb +8 -0
- data/app/views/admin/templates/_date.html.erb +2 -0
- data/app/views/admin/templates/_datetime.html.erb +2 -0
- data/app/views/admin/templates/_file.html.erb +44 -0
- data/app/views/admin/templates/_password.html.erb +2 -0
- data/app/views/admin/templates/_selector.html.erb +21 -0
- data/app/views/admin/templates/_string.html.erb +21 -0
- data/app/views/admin/templates/_text.html.erb +2 -0
- data/app/views/admin/templates/_time.html.erb +2 -0
- data/app/views/admin/templates/_tiny_mce.html.erb +2 -0
- data/app/views/layouts/admin.html.erb +1 -1
- data/config/locales/ru.yml +2 -2
- data/generators/typus/templates/config/initializers/typus.rb +2 -1
- data/generators/typus/templates/public/images/admin/{fancyzoom/closebox.png → fancybox/fancy_closebox.png} +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_left.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_progress.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_right.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_e.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_n.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_ne.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_nw.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_s.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_se.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_sw.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_shadow_w.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_title_left.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_title_main.png +0 -0
- data/generators/typus/templates/public/images/admin/fancybox/fancy_title_right.png +0 -0
- data/generators/typus/templates/public/javascripts/admin/jquery-1.3.2.min.js +19 -0
- data/generators/typus/templates/public/javascripts/admin/jquery.fancybox-1.2.1.min.js +9 -0
- data/generators/typus/templates/public/stylesheets/admin/jquery.fancybox.css +315 -0
- data/generators/typus/templates/public/stylesheets/admin/screen.css +75 -89
- data/generators/typus/typus_generator.rb +6 -5
- data/lib/typus.rb +0 -15
- data/lib/typus/active_record.rb +8 -14
- data/lib/typus/configuration.rb +2 -2
- data/lib/typus/preview.rb +2 -1
- data/lib/typus/reloader.rb +0 -1
- data/tasks/typus_tasks.rake +2 -0
- data/test/helpers/typus_helper_test.rb +0 -10
- data/test/lib/active_record_test.rb +0 -10
- data/test/lib/configuration_test.rb +2 -1
- data/typus.gemspec +30 -30
- metadata +30 -30
- data/generators/typus/templates/public/images/admin/fancyzoom/bl.gif +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/bl.png +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/bm.gif +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/bm.png +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/br.gif +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/br.png +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/closebox.gif +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/ml.gif +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/ml.png +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/mr.gif +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/mr.png +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/tl.gif +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/tl.png +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/tm.gif +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/tm.png +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/tr.gif +0 -0
- data/generators/typus/templates/public/images/admin/fancyzoom/tr.png +0 -0
- data/generators/typus/templates/public/javascripts/admin/builder.js +0 -136
- data/generators/typus/templates/public/javascripts/admin/controls.js +0 -963
- data/generators/typus/templates/public/javascripts/admin/dragdrop.js +0 -973
- data/generators/typus/templates/public/javascripts/admin/effects.js +0 -1128
- data/generators/typus/templates/public/javascripts/admin/fancyzoom.js +0 -221
- data/generators/typus/templates/public/javascripts/admin/prototype.js +0 -4320
- data/generators/typus/templates/public/javascripts/admin/scriptaculous.js +0 -58
- data/generators/typus/templates/public/javascripts/admin/slider.js +0 -275
- data/generators/typus/templates/public/javascripts/admin/sound.js +0 -55
- data/lib/typus/locale.rb +0 -0
data/README.rdoc
CHANGED
@@ -47,7 +47,7 @@ Notes on the application demo:
|
|
47
47
|
|
48
48
|
== Installing
|
49
49
|
|
50
|
-
Install from GitHub the latest version which it's compatible with Rails 2.3.
|
50
|
+
Install from GitHub the latest version which it's compatible with Rails 2.3.4.
|
51
51
|
|
52
52
|
$ script/plugin install git://github.com/fesplugas/typus.git
|
53
53
|
|
@@ -72,12 +72,12 @@ Hire us to work on your next project. We build large and small websites.
|
|
72
72
|
Contribute your patches to the community & support people on the
|
73
73
|
mailing list.
|
74
74
|
|
75
|
-
Tell everybody about Typus
|
76
|
-
Typus and blog about Typus
|
75
|
+
Tell everybody about *Typus*, tell your friends and colleagues about
|
76
|
+
*Typus* and blog about *Typus*.
|
77
77
|
|
78
|
-
==
|
78
|
+
== Fancybox for assets
|
79
79
|
|
80
|
-
|
80
|
+
You can preview assets using Fancybox[http://fancybox.net/example].
|
81
81
|
|
82
82
|
# db/migrate/create_photos.rb
|
83
83
|
|
@@ -100,23 +100,32 @@ This feature is a work in progress. Only previews images.
|
|
100
100
|
|
101
101
|
# app/models/photo.rb
|
102
102
|
|
103
|
+
##
|
104
|
+
# Styles are predefined but you can use your own by defining them
|
105
|
+
# on `config/initializers/typus.rb`.
|
106
|
+
#
|
107
|
+
# Typus::Configuration.options[:file_preview] = :my_preview
|
108
|
+
# Typus::Configuration.options[:file_thumbnail] = :my_thumbnail
|
109
|
+
##
|
103
110
|
class Photo < ActiveRecord::Base
|
104
|
-
has_attached_file :asset, :styles => { :
|
111
|
+
has_attached_file :asset, :styles => { :typus_preview => "692x461", :typus_thumbnail => "100x100" }
|
105
112
|
end
|
106
113
|
|
107
114
|
# app/views/admin/photos/_index.html.erb
|
108
115
|
|
116
|
+
<%- content_for :stylesheets do -%>
|
117
|
+
<%= stylesheet_link_tag 'admin/jquery.fancybox', :media => 'screen' %>
|
118
|
+
<%- end -%>
|
119
|
+
|
109
120
|
<%- content_for :javascripts do -%>
|
110
121
|
|
111
|
-
<%= javascript_include_tag 'admin/
|
112
|
-
<%= javascript_include_tag 'admin/
|
113
|
-
<%= javascript_include_tag 'admin/fancyzoom' %>
|
122
|
+
<%= javascript_include_tag 'admin/jquery-1.3.2.min' %>
|
123
|
+
<%= javascript_include_tag 'admin/jquery.fancybox-1.2.1.min' %>
|
114
124
|
|
115
|
-
<script type="text/javascript">
|
116
|
-
|
117
|
-
$(document).observe('dom:loaded', function() {
|
125
|
+
<script type="text/javascript" charset="utf-8">
|
126
|
+
$(document).ready(function() {
|
118
127
|
<%- @items.each do |item| -%>
|
119
|
-
|
128
|
+
$("#<%= item.to_dom %>").fancybox();
|
120
129
|
<%- end -%>
|
121
130
|
});
|
122
131
|
</script>
|
@@ -147,7 +156,9 @@ This feature is a work in progress. Only previews images.
|
|
147
156
|
== Acknowledgments
|
148
157
|
|
149
158
|
- *Typus* uses "Paginator" by Bruce Williams http://codefluency.com.
|
150
|
-
- *Typus* has been inspired by "Django Admin" http://
|
159
|
+
- *Typus* has been inspired by "Django Admin" http://djangoproject.com.
|
160
|
+
- *Typus* uses http://fancybox.net.
|
161
|
+
- *Typus* uses UI icons from http://jqueryui.com.
|
151
162
|
|
152
163
|
Copyright (c) 2007-2009 Francesc Esplugas Marti, released under the
|
153
164
|
MIT license
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.29
|
@@ -7,32 +7,26 @@ module Admin::FormHelper
|
|
7
7
|
:minute_step => @resource[:class].typus_options_for(:minute_step) }
|
8
8
|
|
9
9
|
returning(String.new) do |html|
|
10
|
+
|
10
11
|
html << (error_messages_for :item, :header_tag => 'h3')
|
11
12
|
html << '<ul>'
|
12
13
|
|
13
14
|
fields.each do |key, value|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
when :file then html << typus_file_field(key)
|
24
|
-
when :password then html << typus_password_field(key)
|
25
|
-
when :selector then html << typus_selector_field(key)
|
26
|
-
when :text then html << typus_text_field(key)
|
27
|
-
when :tiny_mce then html << typus_tiny_mce_field(key)
|
28
|
-
when :time then html << typus_time_field(key, options)
|
29
|
-
when :tree then html << typus_tree_field(key)
|
30
|
-
else
|
31
|
-
html << typus_string_field(key)
|
32
|
-
end
|
15
|
+
|
16
|
+
html << case value
|
17
|
+
when :belongs_to then typus_belongs_to_field(key)
|
18
|
+
when :tree then typus_tree_field(key)
|
19
|
+
when :boolean, :date, :datetime, :file, :password, :selector, :string, :text, :time, :tiny_mce
|
20
|
+
typus_template_field(key, value.to_s, options)
|
21
|
+
else
|
22
|
+
typus_template_field(key, 'string', options)
|
23
|
+
end
|
33
24
|
end
|
25
|
+
|
34
26
|
html << '</ul>'
|
27
|
+
|
35
28
|
end
|
29
|
+
|
36
30
|
end
|
37
31
|
|
38
32
|
def typus_belongs_to_field(attribute)
|
@@ -69,104 +63,6 @@ module Admin::FormHelper
|
|
69
63
|
|
70
64
|
end
|
71
65
|
|
72
|
-
def typus_boolean_field(attribute)
|
73
|
-
attribute_name = attribute.gsub(/\?$/,'')
|
74
|
-
custom_true = @resource[:class].typus_boolean(attribute)[:true]
|
75
|
-
custom_true = custom_true != 'True' ? custom_true : "Checked if active"
|
76
|
-
<<-HTML
|
77
|
-
<li><label>#{@resource[:class].human_attribute_name(attribute)}</label>
|
78
|
-
#{check_box :item, attribute_name} <label class="inline_label" for="item_#{attribute_name}">#{_(custom_true)}</label></li>
|
79
|
-
HTML
|
80
|
-
end
|
81
|
-
|
82
|
-
def typus_date_field(attribute, options)
|
83
|
-
<<-HTML
|
84
|
-
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
85
|
-
#{date_select :item, attribute, options, { :disabled => attribute_disabled?(attribute)} }</li>
|
86
|
-
HTML
|
87
|
-
end
|
88
|
-
|
89
|
-
def typus_datetime_field(attribute, options)
|
90
|
-
<<-HTML
|
91
|
-
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
92
|
-
#{datetime_select :item, attribute, options, {:disabled => attribute_disabled?(attribute)}}</li>
|
93
|
-
HTML
|
94
|
-
end
|
95
|
-
|
96
|
-
# Optimize
|
97
|
-
def typus_file_field(attribute)
|
98
|
-
|
99
|
-
attachment = attribute.split('_file_name').first
|
100
|
-
|
101
|
-
unless @item.send(attribute).blank?
|
102
|
-
item = @item.send(attachment)
|
103
|
-
preview = if @item.send("#{attachment}_content_type") =~ /^image\/.+/ && item.styles.member?(:typus_thumbnail)
|
104
|
-
image_tag item.url(:typus_thumbnail)
|
105
|
-
else
|
106
|
-
link_to @item.send(attribute), item.url
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
<<-HTML
|
111
|
-
<li><label for="item_#{attribute}">#{_(attachment.humanize)}</label>
|
112
|
-
#{file_field :item, attachment, :disabled => attribute_disabled?(attribute)}
|
113
|
-
#{preview}
|
114
|
-
</li>
|
115
|
-
HTML
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
def typus_password_field(attribute)
|
120
|
-
<<-HTML
|
121
|
-
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
122
|
-
#{password_field :item, attribute, :class => 'text', :disabled => attribute_disabled?(attribute)}</li>
|
123
|
-
HTML
|
124
|
-
end
|
125
|
-
|
126
|
-
def typus_selector_field(attribute)
|
127
|
-
returning(String.new) do |html|
|
128
|
-
options = []
|
129
|
-
@resource[:class].send(attribute).each do |option|
|
130
|
-
case option.kind_of?(Array)
|
131
|
-
when true
|
132
|
-
selected = (@item.send(attribute).to_s == option.last.to_s) ? 'selected' : ''
|
133
|
-
options << "<option #{selected} value=\"#{option.last}\">#{option.first}</option>"
|
134
|
-
else
|
135
|
-
selected = (@item.send(attribute).to_s == option.to_s) ? 'selected' : ''
|
136
|
-
options << "<option #{selected} value=\"#{option}\">#{option}</option>"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
html << <<-HTML
|
140
|
-
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
141
|
-
<select id="item_#{attribute}" #{attribute_disabled?(attribute) ? 'disabled="disabled"' : ''} name="item[#{attribute}]">
|
142
|
-
<option value=""></option>
|
143
|
-
#{options.join("\n")}
|
144
|
-
</select></li>
|
145
|
-
HTML
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def typus_text_field(attribute)
|
150
|
-
<<-HTML
|
151
|
-
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
152
|
-
#{text_area :item, attribute, :class => 'text', :rows => @resource[:class].typus_options_for(:form_rows), :disabled => attribute_disabled?(attribute)}</li>
|
153
|
-
HTML
|
154
|
-
end
|
155
|
-
|
156
|
-
def typus_tiny_mce_field(attribute)
|
157
|
-
<<-HTML
|
158
|
-
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
159
|
-
#{text_area :item, attribute, :class => 'mceEditor', :disabled => attribute_disabled?(attribute)}</li>
|
160
|
-
HTML
|
161
|
-
end
|
162
|
-
|
163
|
-
def typus_time_field(attribute, options)
|
164
|
-
<<-HTML
|
165
|
-
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
166
|
-
#{time_select :item, attribute, options, {:disabled => attribute_disabled?(attribute)}}</li>
|
167
|
-
HTML
|
168
|
-
end
|
169
|
-
|
170
66
|
def typus_tree_field(attribute, items = @resource[:class].roots, attribute_virtual = 'parent_id')
|
171
67
|
<<-HTML
|
172
68
|
<li><label for="item_#{attribute}">#{@resource[:class].human_attribute_name(attribute)}</label>
|
@@ -177,30 +73,6 @@ module Admin::FormHelper
|
|
177
73
|
HTML
|
178
74
|
end
|
179
75
|
|
180
|
-
def typus_string_field(attribute)
|
181
|
-
|
182
|
-
# Read only fields.
|
183
|
-
if @resource[:class].typus_field_options_for(:read_only).include?(attribute)
|
184
|
-
value = 'read_only' if %w( edit ).include?(params[:action])
|
185
|
-
end
|
186
|
-
|
187
|
-
# Auto generated fields.
|
188
|
-
if @resource[:class].typus_field_options_for(:auto_generated).include?(attribute)
|
189
|
-
value = 'auto_generated' if %w( new edit ).include?(params[:action])
|
190
|
-
end
|
191
|
-
|
192
|
-
comment = %w( read_only auto_generated ).include?(value) ? "<small>#{value} field</small>".humanize : ''
|
193
|
-
|
194
|
-
attribute_humanized = @resource[:class].human_attribute_name(attribute)
|
195
|
-
attribute_humanized += " (#{attribute})" if attribute.include?('_id')
|
196
|
-
|
197
|
-
<<-HTML
|
198
|
-
<li><label for="item_#{attribute}">#{attribute_humanized}#{comment}</label>
|
199
|
-
#{text_field :item, attribute, :class => 'text', :disabled => attribute_disabled?(attribute) }</li>
|
200
|
-
HTML
|
201
|
-
|
202
|
-
end
|
203
|
-
|
204
76
|
def typus_relationships
|
205
77
|
|
206
78
|
@back_to = '/' + [ params[:controller], params[:action], params[:id] ].compact.join('/')
|
@@ -378,11 +250,9 @@ module Admin::FormHelper
|
|
378
250
|
end
|
379
251
|
|
380
252
|
def typus_template_field(attribute, template, options = {})
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
output = render(:partial => template_name, :locals => { :resource => @resource, :attribute => attribute, :options => options } )
|
385
|
-
output || "#{attribute}: Can not find the template '#{template}'"
|
253
|
+
template_name = File.join('admin', 'templates', template)
|
254
|
+
render :partial => template_name,
|
255
|
+
:locals => { :resource => @resource, :attribute => attribute, :options => options }
|
386
256
|
end
|
387
257
|
|
388
258
|
def attribute_disabled?(attribute)
|
@@ -169,11 +169,11 @@ module Admin::TableHelper
|
|
169
169
|
def typus_table_file_field(attribute, item, link_options = {})
|
170
170
|
|
171
171
|
attachment = attribute.split('_file_name').first
|
172
|
+
file_preview = Typus::Configuration.options[:file_preview]
|
172
173
|
|
173
|
-
if item.send(attachment).styles.member?(
|
174
|
+
if item.send(attachment).styles.member?(file_preview) && item.send("#{attachment}_content_type") =~ /^image\/.+/
|
174
175
|
<<-HTML
|
175
|
-
<td><a
|
176
|
-
<div id=\"#{item.to_dom(:suffix => 'zoom')}\">#{item.typus_preview(attachment)}</div>
|
176
|
+
<td><a id="#{item.to_dom}" href="#{item.send(attachment).url(file_preview)}" title="#{item.typus_name}">#{item.send(attribute)}</a></td>
|
177
177
|
HTML
|
178
178
|
else
|
179
179
|
<<-HTML
|
data/app/helpers/typus_helper.rb
CHANGED
@@ -75,7 +75,7 @@ module TypusHelper
|
|
75
75
|
|
76
76
|
html << <<-HTML
|
77
77
|
<tr class="#{cycle('even', 'odd')}">
|
78
|
-
<td>#{link_to _(resource.humanize), resource_path}</td>
|
78
|
+
<td>#{link_to _(resource.tableize.humanize), resource_path}</td>
|
79
79
|
<td align="right" style="vertical-align: bottom;"></td>
|
80
80
|
</tr>
|
81
81
|
HTML
|
@@ -177,12 +177,4 @@ module TypusHelper
|
|
177
177
|
|
178
178
|
end
|
179
179
|
|
180
|
-
def typus_message(message, html_class = 'notice')
|
181
|
-
<<-HTML
|
182
|
-
<div id="flash" class="#{html_class}">
|
183
|
-
<p>#{message}</p>
|
184
|
-
</div>
|
185
|
-
HTML
|
186
|
-
end
|
187
|
-
|
188
180
|
end
|
@@ -20,13 +20,16 @@
|
|
20
20
|
!raw_data.nil? ? boolean_hash["#{raw_data}".to_sym] : @resource[:class].typus_options_for(:nil)
|
21
21
|
when :belongs_to
|
22
22
|
raw_data.typus_name
|
23
|
+
when :file
|
24
|
+
attachment = field.first.split('_file_name').first
|
25
|
+
@item.typus_preview(attachment)
|
23
26
|
when :text
|
24
27
|
defined?(RDiscount) ? markdown(raw_data) : raw_data
|
25
28
|
else
|
26
|
-
raw_data
|
29
|
+
h(raw_data)
|
27
30
|
end
|
28
31
|
-%>
|
29
|
-
<dd><%= !data.blank? ?
|
32
|
+
<dd><%= !data.blank? ? data : '—' %></dd>
|
30
33
|
<%- end -%>
|
31
34
|
</dl>
|
32
35
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%
|
2
|
+
attribute_name = attribute.gsub(/\?$/,'')
|
3
|
+
custom_true = @resource[:class].typus_boolean(attribute)[:true]
|
4
|
+
custom_true = custom_true != 'True' ? custom_true : "Checked if active"
|
5
|
+
%>
|
6
|
+
|
7
|
+
<li><label><%= @resource[:class].human_attribute_name(attribute) %></label>
|
8
|
+
<%= check_box :item, attribute_name %> <label class="inline_label" for="item_<%= attribute_name %>"><%= _(custom_true) %></label></li>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<%- content_for :stylesheets do -%>
|
2
|
+
<%= stylesheet_link_tag 'admin/jquery.fancybox', :media => 'screen' %>
|
3
|
+
<%- end -%>
|
4
|
+
|
5
|
+
<%- content_for :javascripts do -%>
|
6
|
+
|
7
|
+
<%= javascript_include_tag 'admin/jquery-1.3.2.min' %>
|
8
|
+
<%= javascript_include_tag 'admin/jquery.fancybox-1.2.1.min' %>
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
$(document).ready(function() {
|
12
|
+
$("#<%= @item.to_dom %>").fancybox();
|
13
|
+
});
|
14
|
+
</script>
|
15
|
+
|
16
|
+
<%- end -%>
|
17
|
+
|
18
|
+
<%
|
19
|
+
|
20
|
+
attachment = attribute.split('_file_name').first
|
21
|
+
file_preview = Typus::Configuration.options[:file_preview]
|
22
|
+
file_thumbnail = Typus::Configuration.options[:file_thumbnail]
|
23
|
+
|
24
|
+
unless @item.send(attribute).blank?
|
25
|
+
item = @item.send(attachment)
|
26
|
+
preview = if @item.send("#{attachment}_content_type") =~ /^image\/.+/ && item.styles.member?(file_thumbnail)
|
27
|
+
<<-HTML
|
28
|
+
<a id="#{@item.to_dom}" href="#{@item.send(attachment).url(file_preview)}" title="#{@item.typus_name}">
|
29
|
+
#{image_tag item.url(file_thumbnail)}
|
30
|
+
</a>
|
31
|
+
HTML
|
32
|
+
else
|
33
|
+
<<-HTML
|
34
|
+
#{link_to @item.send(attribute), item.url}
|
35
|
+
HTML
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
%>
|
40
|
+
|
41
|
+
<li><label for="item_<%= attribute %>"><%= _(attachment.humanize) %></label>
|
42
|
+
<%= file_field :item, attachment, :disabled => attribute_disabled?(attribute) %>
|
43
|
+
<%= preview %>
|
44
|
+
</li>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
options = []
|
4
|
+
@resource[:class].send(attribute).each do |option|
|
5
|
+
case option.kind_of?(Array)
|
6
|
+
when true
|
7
|
+
selected = (@item.send(attribute).to_s == option.last.to_s) ? 'selected' : ''
|
8
|
+
options << "<option #{selected} value=\"#{option.last}\">#{option.first}</option>"
|
9
|
+
else
|
10
|
+
selected = (@item.send(attribute).to_s == option.to_s) ? 'selected' : ''
|
11
|
+
options << "<option #{selected} value=\"#{option}\">#{option}</option>"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
%>
|
16
|
+
|
17
|
+
<li><label for="item_<%= attribute %>"><%= @resource[:class].human_attribute_name(attribute) %></label>
|
18
|
+
<select id="item_<%= attribute %>" <%= attribute_disabled?(attribute) ? 'disabled="disabled"' : '' %> name="item[<%= attribute %>]">
|
19
|
+
<option value=""></option>
|
20
|
+
<%= options.join("\n") %>
|
21
|
+
</select></li>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
# Read only fields.
|
4
|
+
if @resource[:class].typus_field_options_for(:read_only).include?(attribute)
|
5
|
+
value = 'read_only' if %w( edit ).include?(params[:action])
|
6
|
+
end
|
7
|
+
|
8
|
+
# Auto generated fields.
|
9
|
+
if @resource[:class].typus_field_options_for(:auto_generated).include?(attribute)
|
10
|
+
value = 'auto_generated' if %w( new edit ).include?(params[:action])
|
11
|
+
end
|
12
|
+
|
13
|
+
comment = %w( read_only auto_generated ).include?(value) ? "<small>#{value} field</small>".humanize : ''
|
14
|
+
|
15
|
+
attribute_humanized = @resource[:class].human_attribute_name(attribute)
|
16
|
+
attribute_humanized += " (#{attribute})" if attribute.include?('_id')
|
17
|
+
|
18
|
+
%>
|
19
|
+
|
20
|
+
<li><label for="item_<%= attribute %>"><%= attribute_humanized %> <%= comment %></label>
|
21
|
+
<%= text_field :item, attribute, :class => 'text', :disabled => attribute_disabled?(attribute) %></li>
|