beautiful_scaffold 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +15 -0
- data/beautiful_scaffold.gemspec +1 -1
- data/lib/generators/USAGE +4 -0
- data/lib/generators/beautiful_scaffold_generator.rb +1 -1
- data/lib/generators/templates/app/helpers/beautiful_helper.rb +23 -10
- data/lib/generators/templates/app/views/_mass_inserting.html.erb +4 -4
- data/lib/generators/templates/app/views/_modal_columns.html.erb +1 -1
- data/lib/generators/templates/app/views/edit.html.erb +1 -1
- data/lib/generators/templates/app/views/index.html.erb +3 -3
- data/lib/generators/templates/app/views/new.html.erb +1 -1
- data/lib/generators/templates/app/views/partials/_index_column.html.erb +1 -1
- data/lib/generators/templates/app/views/show.html.erb +1 -1
- data/lib/generators/templates/app/views/treeview.html.erb +1 -1
- metadata +3 -2
data/CHANGELOG
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
== 0.2.3
|
2
|
+
|
3
|
+
* enhancement
|
4
|
+
* Add preselect collection_select in mass inserting with filter params
|
5
|
+
* Adapt ransack_field helper for nested resource
|
6
|
+
* Add custom caption for treeview element in build_treeview helper
|
7
|
+
* I18n for menu
|
8
|
+
* I18n for fields name (placeholder mass inserting and select fields)
|
9
|
+
* I18n for title h2
|
10
|
+
* I18n for button New
|
11
|
+
* Show caption in table instead of #id
|
12
|
+
|
13
|
+
== Previous versions
|
14
|
+
|
15
|
+
* See commits on github
|
data/beautiful_scaffold.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "beautiful_scaffold"
|
6
|
-
s.version = "0.2.
|
6
|
+
s.version = "0.2.3"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.summary = "Beautiful Scaffold generate fully customizable scaffold"
|
9
9
|
s.email = "claudel.sylvain@gmail.com"
|
data/lib/generators/USAGE
CHANGED
@@ -114,7 +114,7 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
|
|
114
114
|
|
115
115
|
inject_into_file("app/views/layouts/_beautiful_menu.html.erb",'
|
116
116
|
<li class="<%= "active" if params[:controller] == "' + namespace_for_url + model.pluralize + '" %>">
|
117
|
-
<%= link_to "' + model.
|
117
|
+
<%= link_to t(:' + model.pluralize + ', :default => "' + model.pluralize + '").capitalize, ' + namespace_for_route + model.pluralize + '_path %>
|
118
118
|
</li>', :after => "<!-- Beautiful Scaffold Menu Do Not Touch This -->")
|
119
119
|
end
|
120
120
|
|
@@ -41,7 +41,7 @@ module BeautifulHelper
|
|
41
41
|
default_caption = get_belongs_to_model(default_caption)
|
42
42
|
end
|
43
43
|
|
44
|
-
caption = t(attribute_name, :default => default_caption)
|
44
|
+
caption = t(attribute_name, :default => default_caption).capitalize
|
45
45
|
strpath = model_name.pluralize + "_url"
|
46
46
|
strpath = namespace + '_' + strpath if not namespace.blank?
|
47
47
|
|
@@ -52,7 +52,12 @@ module BeautifulHelper
|
|
52
52
|
).html_safe
|
53
53
|
end
|
54
54
|
|
55
|
-
def ransack_field(
|
55
|
+
def ransack_field(path_of_model, attribute_name, f, caption = nil)
|
56
|
+
model_path = path_of_model.split("/")
|
57
|
+
model_name = model_path.last
|
58
|
+
model_path.delete(model_path.first)
|
59
|
+
model_name_for_ransack = model_path.join("_")
|
60
|
+
|
56
61
|
ar_model = model_name.classify.constantize
|
57
62
|
|
58
63
|
default_caption = caption
|
@@ -63,12 +68,20 @@ module BeautifulHelper
|
|
63
68
|
end
|
64
69
|
end
|
65
70
|
|
66
|
-
name_field
|
71
|
+
name_field = attribute_name
|
72
|
+
name_field_bk = attribute_name
|
73
|
+
label_field = attribute_name
|
74
|
+
|
75
|
+
if is_belongs_to_column?(name_field_bk) then
|
76
|
+
label_field = get_belongs_to_model(attribute_name)
|
77
|
+
end
|
78
|
+
|
79
|
+
name_field = model_name_for_ransack + "_" + name_field unless model_name_for_ransack.blank?
|
80
|
+
|
67
81
|
response = '<div class="control-group">'
|
68
|
-
response += f.label name_field, t(
|
82
|
+
response += f.label name_field, t(label_field, :default => default_caption).capitalize, :class => "control-label"
|
69
83
|
response += '<div class="controls">'
|
70
84
|
|
71
|
-
|
72
85
|
type_of_column = ar_model.columns_hash[attribute_name].type unless ar_model.columns_hash[attribute_name].nil?
|
73
86
|
type_of_column ||= :other
|
74
87
|
case type_of_column
|
@@ -141,8 +154,8 @@ module BeautifulHelper
|
|
141
154
|
when :string then
|
142
155
|
response += f.text_field((name_field + "_cont").to_sym, :class => "filter span12")
|
143
156
|
when :integer, :float, :decimal then
|
144
|
-
if is_belongs_to_column?(
|
145
|
-
btmodel = get_belongs_to_model(
|
157
|
+
if is_belongs_to_column?(name_field_bk) then
|
158
|
+
btmodel = get_belongs_to_model(name_field_bk).classify.constantize
|
146
159
|
response += f.collection_select((name_field + "_eq").to_sym, btmodel.all, :id, :caption, { :include_blank => t(:all, :default => "All") }, { :class => "span12" })
|
147
160
|
elsif name_field == "id" then
|
148
161
|
response += f.text_field((name_field + "_eq").to_sym, :class => "filter span12")
|
@@ -199,15 +212,15 @@ module BeautifulHelper
|
|
199
212
|
return column[0..-4]
|
200
213
|
end
|
201
214
|
|
202
|
-
def build_treeview(obj, child_relation)
|
215
|
+
def build_treeview(obj, child_relation, caption_method = "caption")
|
203
216
|
out = '
|
204
217
|
<li id="treeelt_' + obj.id.to_s + '" data-id="' + obj.id.to_s + '">
|
205
|
-
<a href="#" class="nopjax">' + obj.
|
218
|
+
<a href="#" class="nopjax">' + obj.send(caption_method).to_s + '</a>
|
206
219
|
<ul>'
|
207
220
|
ar = obj.send(child_relation.to_sym)
|
208
221
|
ar = ar.order('position') if obj.class.column_names.include?("position")
|
209
222
|
for o in ar.all
|
210
|
-
out += build_treeview(o, child_relation)
|
223
|
+
out += build_treeview(o, child_relation, caption_method)
|
211
224
|
end
|
212
225
|
out += '
|
213
226
|
</ul>
|
@@ -8,9 +8,9 @@
|
|
8
8
|
case ar.type
|
9
9
|
when 'integer' then
|
10
10
|
if col =~ /.*_id/ then
|
11
|
-
f.collection_select((col).to_sym, col.classify.constantize.all, :id, :caption, { :include_blank => true }, { :class => "input-small"
|
11
|
+
f.collection_select((col).to_sym, col.classify.constantize.all, :id, :caption, { :include_blank => true, :selected => (begin params[:q][col + "_eq"].to_i rescue '' end) }, { :class => "input-small" })
|
12
12
|
else
|
13
|
-
f.text_field(col.to_sym, :class => "input-small", :placeholder => col.capitalize)
|
13
|
+
f.text_field(col.to_sym, :class => "input-small", :placeholder => t(col.to_sym, :default => col.capitalize))
|
14
14
|
end
|
15
15
|
when 'boolean' then
|
16
16
|
(
|
@@ -20,10 +20,10 @@
|
|
20
20
|
f.label((col + "_false").to_sym, t(:no))
|
21
21
|
)
|
22
22
|
else
|
23
|
-
f.text_field(col.to_sym, :class => "input-small", :placeholder => col.capitalize)
|
23
|
+
f.text_field(col.to_sym, :class => "input-small", :placeholder => t(col.to_sym, :default => col.capitalize))
|
24
24
|
end
|
25
25
|
else
|
26
|
-
f.collection_select((col + '_id').to_sym, col.classify.constantize.all, :id, :caption, { :include_blank => true }, { :class => "input-small"
|
26
|
+
f.collection_select((col + '_id').to_sym, col.classify.constantize.all, :id, :caption, { :include_blank => true, :selected => (begin params[:q][col + "_id_eq"].to_i rescue '' end) }, { :class => "input-small" })
|
27
27
|
end
|
28
28
|
%>
|
29
29
|
</div>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<div class="modal-body">
|
7
7
|
<% for field in model_columns %>
|
8
8
|
<label class="checkbox">
|
9
|
-
<input type="checkbox" name="field[]" value="<%= field %>" <%= "checked" if session[:fields][model_name.to_sym].include?(field) %>> <%= field %>
|
9
|
+
<input type="checkbox" name="field[]" value="<%= field %>" <%= "checked" if session[:fields][model_name.to_sym].include?(field) %>> <%= t(field, :default => field.capitalize) %>
|
10
10
|
</label><br />
|
11
11
|
<% end %>
|
12
12
|
</div>
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<h2><%%= t(:listing, :default => "Listing") %> <%= plural_table_name %></h2>
|
1
|
+
<h2><%%= t(:listing, :default => "Listing") %> <%%= t(:<%= plural_table_name %>, :default => "<%= plural_table_name %>") %></h2>
|
2
2
|
|
3
3
|
<p>
|
4
|
-
<%%= link_to '<i class="icon-plus"></i>'.html_safe + t(:new, :default => "New") + ' <%= model %>
|
4
|
+
<%%= link_to '<i class="icon-plus"></i>'.html_safe + t(:new, :default => "New") + ' ' + t(:<%= model %>, :default => "<%= model %>"), new_<%= namespace_for_route %><%= singular_table_name %>_path, :class => "btn" %>
|
5
5
|
<%% if <%= model_camelize %>.columns.map(&:name).include?("<%= model %>_id") then %>
|
6
|
-
<%%= link_to '<i class="icon-folder-close"></i>'.html_safe + t(:treeview, :default => "Treeview") + ' <%= model %>
|
6
|
+
<%%= link_to '<i class="icon-folder-close"></i>'.html_safe + t(:treeview, :default => "Treeview") + ' ' + t(:<%= model %>, :default => "<%= model %>"), treeview_<%= namespace_for_route %><%= model_pluralize %>_path, :class => "btn" %>
|
7
7
|
<%% end %>
|
8
8
|
</p>
|
9
9
|
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<%%= t((<%= singular_table_name %>.<%= attribute.name %> ? "yes" : "no").to_sym) %>
|
9
9
|
<%- elsif @beautiful_attributes.include?(attribute.name + ':references') then -%>
|
10
10
|
<%% if not <%= singular_table_name %>.<%= attribute.name %>_id.nil? then %>
|
11
|
-
<%%= link_to
|
11
|
+
<%%= link_to <%= singular_table_name %>.<%= attribute.name %>.caption, <%= namespace_for_route %><%= attribute.name %>_path(<%= singular_table_name %>.<%= attribute.name %>_id) %>
|
12
12
|
<%% else %>
|
13
13
|
<%%= t(:any, :default => "Any") %>
|
14
14
|
<%% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<h2><%%= t(:show, :default => "Show") %> <%= singular_table_name %></h2>
|
1
|
+
<h2><%%= t(:show, :default => "Show") %> <%%= t(:<%= singular_table_name %>, :default => "<%= singular_table_name %>") %></h2>
|
2
2
|
|
3
3
|
<%= render_partial 'app/views/partials/_show_field.html.erb' %>
|
4
4
|
<!-- Beautiful_scaffold - AddField - Field - Do not remove -->
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beautiful_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.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-
|
12
|
+
date: 2012-09-06 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Beautiful Scaffold generate a complete scaffold (sort, export, paginate
|
15
15
|
and filter data) http://www.beautiful-scaffold.com
|
@@ -18,6 +18,7 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
+
- CHANGELOG
|
21
22
|
- Gemfile
|
22
23
|
- MIT-LICENSE
|
23
24
|
- README.rdoc
|