beautiful_scaffold 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ == 0.2.7
2
+
3
+ * enhancement
4
+ * Info class for input with content in search form
5
+ * Add current locale for price in number_to_currency
6
+
7
+ * Bugfix
8
+ * Add type decimal for align
9
+ * Bug css rules ignored for alignment in table (td, th)
10
+
1
11
  == 0.2.6
2
12
 
3
13
  * Bugfix
data/README.rdoc CHANGED
@@ -8,7 +8,7 @@ Demo : http://demo.beautiful-scaffold.com/
8
8
  == Install
9
9
 
10
10
  Add this in your Gemfile :
11
- gem 'beautiful_scaffold', '0.2.5'
11
+ gem 'beautiful_scaffold', '0.2.7'
12
12
  And run
13
13
  bundle install
14
14
 
@@ -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"
6
+ s.version = "0.2.7"
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"
@@ -1,10 +1,10 @@
1
- .ar{
1
+ .ar, table td.ar, table th.ar{
2
2
  text-align:right;
3
3
  }
4
- .al{
4
+ .al, table td.al, table th.al{
5
5
  text-align:left;
6
6
  }
7
- .ac{
7
+ .ac, table td.ac, table th.ac{
8
8
  text-align:center;
9
9
  }
10
10
 
@@ -85,7 +85,8 @@ module BeautifulHelper
85
85
  cap = label_field
86
86
  cap = "number-attr" if label_field == "number"
87
87
 
88
- response = '<div class="control-group">'
88
+ infostr = ''
89
+ response = '' # See at end
89
90
  response += f.label name_field, t(cap, :default => default_caption).capitalize, :class => "control-label"
90
91
  response += '<div class="controls">'
91
92
 
@@ -153,19 +154,29 @@ module BeautifulHelper
153
154
  :value => (begin params[:q][(name_field + "_lteq(#{i}i)").to_sym] rescue '' end),
154
155
  :id => ('q_' + name_field + "_lteq_#{i}i"))
155
156
  end
157
+
158
+ infostr = info_input(model_name, [(name_field + "_dp_lt").to_sym, (name_field + "_tp_lt").to_sym, (name_field + "_dp_gt").to_sym, (name_field + "_tp_gt").to_sym])
156
159
  when :boolean then
157
160
  # Specify a default value (false) in rails migration
158
161
  response += f.label name_field + "_eq_true", raw(f.radio_button((name_field + "_eq").to_sym, true)) + " " + h(t(:yes, :default => "Yes")), :class => "checkbox inline"
159
162
  response += f.label name_field + "_eq_false", raw(f.radio_button((name_field + "_eq").to_sym, false)) + " " + h(t(:no, :default => "No")), :class => "checkbox inline"
160
163
  response += f.label name_field + "_eq", raw(f.radio_button((name_field + "_eq").to_sym, nil)) + " " + h(t(:all, :default => "All")), :class => "checkbox inline"
164
+
165
+ infostr = (begin session[:search][model_name.to_sym][(name_field + "_eq").to_sym] == "on" ? "" : "info" rescue "" end)
161
166
  when :string then
162
167
  response += f.text_field((name_field + "_cont").to_sym, :class => "filter span12")
168
+
169
+ infostr = info_input(model_name, (name_field + "_cont").to_sym)
163
170
  when :integer, :float, :decimal then
164
171
  if is_belongs_to_column?(name_field_bk) then
165
172
  btmodel = get_belongs_to_model(name_field_bk).camelize.constantize
166
173
  response += f.collection_select((name_field + "_eq").to_sym, btmodel.all, :id, :caption, { :include_blank => t(:all, :default => "All") }, { :class => "span12" })
174
+
175
+ infostr = info_input(model_name, (name_field + "_eq").to_sym)
167
176
  elsif name_field == "id" then
168
177
  response += f.text_field((name_field + "_eq").to_sym, :class => "filter span12")
178
+
179
+ infostr = info_input(model_name, (name_field + "_eq").to_sym)
169
180
  else
170
181
  response += '<div class="input-prepend">'
171
182
  response += '<span class="add-on" rel="tooltip" title="' + t(:greater_than, :default => "Greater than") + '"><i class="icon-chevron-right"></i></span>'
@@ -175,22 +186,41 @@ module BeautifulHelper
175
186
  response += '<span class="add-on" rel="tooltip" title="' + t(:smaller_than, :default => "Smaller than") + '"><i class="icon-chevron-left"></i></span>'
176
187
  response += f.text_field((name_field + "_lteq").to_sym, :class => "#{align_attribute("integer")} filter-max span10")
177
188
  response += '</div>'
189
+
190
+ infostr = info_input(model_name, [(name_field + "_lteq").to_sym, (name_field + "_gteq").to_sym])
178
191
  end
179
192
  else
180
193
  response += f.text_field((name_field + "_cont").to_sym, :class => "filter span12")
194
+ infostr = info_input(model_name, (name_field + "_cont").to_sym)
181
195
  end
182
196
 
183
- response += "</div>"
184
- response += "</div>"
197
+ response += '</div>'
198
+ response += '</div>'
199
+
200
+ # Add info class
201
+ response = '<div class="control-group ' + infostr + '">' + response
185
202
 
186
203
  return response.html_safe
187
204
  end
188
205
 
206
+ def info_input(modname, attr)
207
+ model_name = modname.to_sym
208
+ rep = false
209
+ if not session[:search].blank? and not session[:search][model_name].blank? then
210
+ if attr.kind_of?(Array) then
211
+ rep = (attr.any? { |elt| (not session[:search][model_name][elt].blank?) })
212
+ else
213
+ rep = (not session[:search][model_name][attr].blank?)
214
+ end
215
+ end
216
+ return (rep ? "info" : "")
217
+ end
218
+
189
219
  def align_attribute(attribute_type)
190
220
  return case attribute_type
191
221
  when "string" then
192
222
  "al"
193
- when "integer", "float", "numeric" then
223
+ when "integer", "float", "numeric", "decimal" then
194
224
  "ar"
195
225
  when "boolean" then
196
226
  "ac"
@@ -1,7 +1,7 @@
1
1
  <%- attributes.each do |attribute| -%>
2
2
  <td <%%= visible_column("<%= singular_table_name %>", "<%= attribute.name %>") %> class="col-<%= attribute.name %> <%%= align_attribute("<%= attribute.type %>") %>">
3
3
  <%- if @beautiful_attributes.include?(attribute.name + ':price') then -%>
4
- <%%= number_to_currency(<%= singular_table_name %>.<%= attribute.name %>) %>
4
+ <%%= number_to_currency(<%= singular_table_name %>.<%= attribute.name %>, :locale => I18n.locale) %>
5
5
  <%- elsif @beautiful_attributes.include?(attribute.name + ':richtext') then -%>
6
6
  <%%= truncate(<%= singular_table_name %>.<%= attribute.name + "_fulltext" %>, :length => 30) %>
7
7
  <%- elsif @beautiful_attributes.include?(attribute.name + ':boolean') then -%>
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.6
4
+ version: 0.2.7
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: 2013-01-28 00:00:00.000000000 Z
12
+ date: 2013-04-05 00:00:00.000000000 Z
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
@@ -254,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
254
  version: '0'
255
255
  requirements: []
256
256
  rubyforge_project: beautiful_scaffold
257
- rubygems_version: 1.8.24
257
+ rubygems_version: 1.8.25
258
258
  signing_key:
259
259
  specification_version: 3
260
260
  summary: Beautiful Scaffold generate fully customizable scaffold