templus_models 2.0.16 → 3.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a87c047b42820aa87baba1d59157623e25602827
4
- data.tar.gz: d0a10386ada91e1281c4577d9c75a556b17b6b4d
3
+ metadata.gz: b2a32e3baae3e617d1b3d1ba52b72275de3e69f7
4
+ data.tar.gz: 94f286c2f34c143da3381f2eb9cb1169b826cc51
5
5
  SHA512:
6
- metadata.gz: ad3263d6b8082eeb382a3cbf0c89f32348ec09cfa86338dd33883849dedf943d92f08ff10f7fb2f0e78b8bc5b98b253ff120db81215704575d49ae2d717c2bc9
7
- data.tar.gz: b8621fe894e86228491e7f00b402d2e63677027dad24ae1b10a5bb11e51d252bcf5c40cee31062d80a9a6561ffec4e5f00f26aa6590fd9a0da20228d4bfc710f
6
+ metadata.gz: 73c6ef467a04541e8df8888172fda866744c1f3381e0aaeb7991e2ce483366bf4f96e57483bf7af8884af14dbcce528ca2cd297434321d2337910b68ac02ddcf
7
+ data.tar.gz: 37bca7a88955f38e9364c06c68a40d52a8bd1d07898f70eb429586f1206599164ef288a2716790913bf0b598872234f54438e9465c188ddaa08895a1ec354c64
@@ -1,26 +1,46 @@
1
1
  class CrudController < ApplicationController
2
2
  before_filter :setup, except: :autocomplete
3
3
 
4
+ private
5
+ def setup
6
+ if params[:associacao]
7
+ @crud_associacao = Module.const_get("#{params[:model].to_s.singularize}_crud".camelize)
8
+ @model = Module.const_get(params[:model].camelize).find(params[:id]).send(params[:associacao])
9
+ c_helper = Module.const_get(params[:model].camelize).reflect_on_association(params[:associacao]).class_name
10
+ @crud_helper = Module.const_get("#{c_helper}Crud") unless params[:render] == "modal" and params[:action] == "new"
11
+ @url = crud_associacao_models_path(model: params[:model], id: params[:id], associacao: params[:associacao], page: params[:page], q: params[:q])
12
+ @clean_url = crud_associacao_models_path(model: params[:model], id: params[:id], associacao: params[:associacao])
13
+ @model_permission = c_helper.constantize
14
+ @id = params[:associacao_id] if params[:associacao_id]
15
+ else
16
+ @model = Module.const_get(params[:model].camelize)
17
+ @model_permission = @model
18
+ @crud_helper = Module.const_get("#{params[:model]}_crud".camelize) unless params[:render] == "modal" and params[:action] == "new"
19
+ @url = crud_models_path(model: params[:model], page: params[:page], q: params[:q])
20
+ @clean_url = crud_models_path(model: params[:model])
21
+ @id = params[:id] if params[:id]
22
+ end
23
+ end
24
+
25
+ public
4
26
  def index
5
27
  authorize! :read, @model_permission if respond_to?(:current_usuario)
6
- if params[:scope].present? && valid_method?(params[:scope])
28
+ if params[:scope].present?
7
29
  @q = @model.send(params[:scope]).search(params[:q])
8
30
  else
9
31
  @q = @model.search(params[:q])
10
32
  end
11
-
12
33
  if @q.sorts.empty?
13
- if @crud_helper.order_field.to_s.include?("desc") || @crud_helper.order_field.to_s.include?("asc")
14
- @q.sorts = @crud_helper.order_field.to_s
34
+ if "#{@crud_helper.order_field}".include?("desc") or "#{@crud_helper.order_field}".include?("asc")
35
+ @q.sorts = "#{@crud_helper.order_field}"
15
36
  else
16
37
  @q.sorts = "#{@crud_helper.order_field} asc"
17
38
  end
18
39
  end
19
-
20
40
  if respond_to?(:current_usuario)
21
- @records = @q.result.accessible_by(current_ability, :read).uniq.page(params[:page]).per(@crud_helper.per_page)
41
+ @records = @q.result.accessible_by(current_ability, :read).page(params[:page]).per(@crud_helper.per_page)
22
42
  else
23
- @records = @q.result.uniq.page(params[:page]).per(@crud_helper.per_page)
43
+ @records = @q.result.page(params[:page]).per(@crud_helper.per_page)
24
44
  end
25
45
  @titulo = @model.name.pluralize
26
46
  render partial: 'records' if request.respond_to?(:wiselinks_partial?) && request.wiselinks_partial?
@@ -55,13 +75,13 @@ class CrudController < ApplicationController
55
75
  def action
56
76
  @record = @model.find(@id)
57
77
  authorize! :create_or_update, @record if respond_to?(:current_usuario)
58
- if valid_instance_method?(params[:acao])
78
+ if @model.method_defined?(params[:acao])
59
79
  if @record.send(params[:acao])
60
80
  flash.now[:success] = I18n.t("mensagem_action", acao: params[:acao])
61
81
  else
62
82
  flash.now[:error] = I18n.t("mensagem_erro_action", acao: params[:acao])
63
83
  end
64
- redirect_to @url
84
+ redirect_to "#{@url}?page=#{params[:page]}"
65
85
  else
66
86
  @titulo = @record.to_s
67
87
  @texto = params[:acao]
@@ -84,7 +104,7 @@ class CrudController < ApplicationController
84
104
  respond_to do |format|
85
105
  if @saved
86
106
  flash[:success] = params[:id].present? ? I18n.t("updated", model: I18n.t("model.#{@model.name.underscore}")) : I18n.t("created", model: I18n.t("model.#{@model.name.underscore}"))
87
- format.html { redirect_to @url }
107
+ format.html { redirect_to "#{@url}?page=#{params[:page]}" }
88
108
  unless params[:render] == 'modal'
89
109
  format.js { render action: :index}
90
110
  else
@@ -119,19 +139,13 @@ class CrudController < ApplicationController
119
139
  def query
120
140
  authorize! :read, @model_permission if respond_to?(:current_usuario)
121
141
  @resource = @model
122
- if params[:scope].present? && valid_method?(params[:scope])
123
- @q = @model.send(params[:scope]).search(params[:q])
124
- else
125
- @q = @model.search(params[:q])
126
- end
142
+ @q = @resource.search(params[:q])
127
143
  @q.sorts = 'updated_at desc' if @q.sorts.empty?
128
-
129
144
  if respond_to?(:current_usuario)
130
- results = @q.result.accessible_by(current_ability).uniq.page(params[:page])
145
+ results = @q.result.accessible_by(current_ability).page(params[:page])
131
146
  else
132
- results = @q.result.uniq.page(params[:page])
147
+ results = @q.result.page(params[:page])
133
148
  end
134
-
135
149
  instance_variable_set("@#{params[:var]}", results)
136
150
  if request.respond_to?(:wiselinks_partial?) && request.wiselinks_partial?
137
151
  render :partial => params[:partial]
@@ -148,46 +162,36 @@ class CrudController < ApplicationController
148
162
  @q = @model.search(parametros)
149
163
  @q.sorts = 'updated_at desc' if @q.sorts.empty?
150
164
  if respond_to?(:current_usuario)
151
- results = @q.result.accessible_by(current_ability).uniq.page(params[:page])
165
+ results = @q.result.accessible_by(current_ability).page(params[:page])
152
166
  else
153
- results = @q.result.uniq.page(params[:page])
154
- end
155
- if valid_instance_method?(params[:label])
156
- method_label = params[:label]
157
- else
158
- raise "Ação inválida"
167
+ results = @q.result.page(params[:page])
159
168
  end
169
+ method_label = params[:label]
160
170
  render json: results.map {|result| {id: result.id, label: result.send(method_label), value: result.send(method_label)} }
161
171
  end
162
172
 
163
173
  def listing
164
174
  authorize! :read, @model_permission if respond_to?(:current_usuario)
165
- if params[:scope].present? && valid_method?(params[:scope])
166
- @q = @model.send(params[:scope]).search(params[:q])
167
- else
168
- @q = @model.search(params[:q])
169
- end
170
-
171
- if @q.sorts.empty?
172
- if @crud_helper.order_field.to_s.include?("desc") || @crud_helper.order_field.to_s.include?("asc")
173
- @q.sorts = @crud_helper.order_field.to_s
174
- else
175
- @q.sorts = "#{@crud_helper.order_field} asc"
176
- end
177
- end
178
-
175
+ @q = @model.search(params[:q])
179
176
  if respond_to?(:current_usuario)
180
- @records = @q.result.uniq.accessible_by(current_ability)
177
+ @records = @q.result.accessible_by(current_ability)
181
178
  else
182
- @records = @q.result.uniq
179
+ @records = @q.result
183
180
  end
184
181
  report_name = "#{@crud_helper.title}_#{DateTime.now.strftime('%Y%m%d')}"
185
182
  respond_to do |format|
186
- format.xls { headers["Content-Disposition"] = "attachment; filename=#{report_name}.xls" }
183
+ format.xls {headers["Content-Disposition"] = "attachment; filename=#{report_name}.xls"}
187
184
  format.pdf do
188
- pdf = generate_pdf_report(@crud_helper.setup_report_listing, 'crud/listing.pdf.erb')
185
+ pdf = WickedPdf.new.pdf_from_string(
186
+ render_to_string('crud/listing.pdf.erb'),
187
+ encoding: 'UTF-8',
188
+ page_size: 'A4',
189
+ show_as_html: params[:debug],
190
+ margin: { top: 20, bottom: 20 }
191
+ )
189
192
  send_data(pdf, filename: "#{report_name}.pdf", type: "application/pdf", disposition: "inline")
190
193
  end
194
+ format.html
191
195
  end
192
196
  end
193
197
 
@@ -197,7 +201,13 @@ class CrudController < ApplicationController
197
201
  report_name = "#{@record}_#{DateTime.now.strftime('%Y%m%d')}"
198
202
  respond_to do |format|
199
203
  format.pdf do
200
- pdf = generate_pdf_report(@crud_helper.setup_report_printing, 'crud/printing.pdf.erb')
204
+ pdf = WickedPdf.new.pdf_from_string(
205
+ render_to_string('crud/printing.pdf.erb'),
206
+ encoding: 'UTF-8',
207
+ page_size: 'A4',
208
+ show_as_html: params[:debug],
209
+ margin: { top: 20, bottom: 20 }
210
+ )
201
211
  send_data(pdf, filename: "#{report_name}.pdf", type: "application/pdf", disposition: "inline")
202
212
  end
203
213
  format.html
@@ -205,50 +215,8 @@ class CrudController < ApplicationController
205
215
  end
206
216
 
207
217
  private
208
- def generate_pdf_report(opts, layout)
209
- html = render_to_string(layout)
210
- options = {
211
- encoding: 'UTF-8',
212
- orientation: opts[:orientation],
213
- page_size: 'A4',
214
- show_as_html: params[:debug],
215
- margin: { top: opts[:top], bottom: opts[:bottom] }
216
- }
217
- if opts[:header].present?
218
- options[:header] = {content: render_to_string(template: opts[:header], locals: {title: @crud_helper.title})}
219
- end
220
- if opts[:footer].present?
221
- options[:footer] = {content: render_to_string(template: opts[:footer])}
222
- end
223
- WickedPdf.new.pdf_from_string(html, options)
224
- end
225
-
226
- def setup
227
- if params[:associacao]
228
- @crud_associacao = Module.const_get("#{params[:model].to_s.singularize}_crud".camelize)
229
- if Module.const_get(params[:model].camelize).reflect_on_association(params[:associacao])
230
- @model = Module.const_get(params[:model].camelize).find(params[:id]).send(params[:associacao])
231
- else
232
- raise "Ação inválida"
233
- end
234
- c_helper = Module.const_get(params[:model].camelize).reflect_on_association(params[:associacao]).class_name
235
- @crud_helper = Module.const_get("#{c_helper}Crud") unless params[:render] == "modal" and params[:action] == "new"
236
- @url = crud_associacao_models_path(model: params[:model], id: params[:id], associacao: params[:associacao], page: params[:page], q: params[:q])
237
- @clean_url = crud_associacao_models_path(model: params[:model], id: params[:id], associacao: params[:associacao])
238
- @model_permission = c_helper.constantize
239
- @id = params[:associacao_id] if params[:associacao_id]
240
- else
241
- @model = Module.const_get(params[:model].camelize)
242
- @model_permission = @model
243
- @crud_helper = Module.const_get("#{params[:model]}_crud".camelize) unless params[:render] == "modal" and params[:action] == "new"
244
- @url = crud_models_path(model: params[:model], page: params[:page], q: params[:q])
245
- @clean_url = crud_models_path(model: params[:model])
246
- @id = params[:id] if params[:id]
247
- end
248
- end
249
-
250
218
  def params_permitt
251
- params.require(@model.name.underscore.gsub('/','_').to_sym).permit(fields_model)
219
+ params.require(@model.name.underscore.to_sym).permit(fields_model)
252
220
  end
253
221
 
254
222
  def fields_model
@@ -264,16 +232,12 @@ class CrudController < ApplicationController
264
232
  fields << {"#{field[:attribute].to_s.singularize}_ids".to_sym => []}
265
233
  end
266
234
  elsif @model.columns_hash[field[:attribute].to_s]
267
- if @model.columns_hash[field[:attribute].to_s].cast_type.class == ActiveRecord::Type::Serialized
268
- fields << {field[:attribute] => []}
269
- else
270
- fields << field[:attribute]
271
- end
235
+ fields << field[:attribute]
272
236
  end
273
237
  end
274
238
  end
275
239
  #TODO - Deprecated
276
- @crud_helper.form_groups.each do |key, groups|
240
+ @crud_helper.form_groups.each do |key, groups|
277
241
  fields << permitt_group(fields, key, groups[:fields],@model)
278
242
  end
279
243
  #Fim - Deprecated
@@ -300,32 +264,10 @@ class CrudController < ApplicationController
300
264
  group[chave] << {"#{field[:attribute].to_s.singularize}_ids".to_sym => []}
301
265
  end
302
266
  elsif (modelo.columns_hash[field[:attribute].to_s] || (modelo.respond_to?(:params_permitt) && modelo.params_permitt.include?(field[:attribute].to_sym)))
303
- if modelo.columns_hash[field[:attribute].to_s].cast_type.class == ActiveRecord::Type::Serialized
304
- group[chave] << {field[:attribute] => []}
305
- else
306
- group[chave] << field[:attribute]
307
- end
267
+ group[chave] << field[:attribute]
308
268
  end
309
269
  end
310
270
  end
311
271
  group
312
272
  end
313
-
314
- def valid_method?(method)
315
- list_methods = []
316
- @model.ancestors.each do |m|
317
- list_methods << m.methods(false).reject{ |m| /^_/ =~ m.to_s }
318
- break if m.superclass.to_s == "ActiveRecord::Base"
319
- end
320
- list_methods.flatten.include? method.to_sym
321
- end
322
-
323
- def valid_instance_method?(method)
324
- list_methods = []
325
- @model.ancestors.each do |m|
326
- list_methods << m.instance_methods(false).reject{ |m| /^_/ =~ m.to_s }
327
- break if m.superclass.to_s == "ActiveRecord::Base"
328
- end
329
- list_methods.flatten.include? method.to_sym
330
- end
331
273
  end
@@ -1,11 +1,11 @@
1
1
  module CrudHelper
2
2
 
3
3
  def is_active_controller(controller_name)
4
- params[:controller] == controller_name ? "active" : nil
4
+ params[:controller] == controller_name ? "active" : nil
5
5
  end
6
6
 
7
7
  def is_active_action(action_name)
8
- params[:action] == action_name ? "active" : nil
8
+ params[:action] == action_name ? "active" : nil
9
9
  end
10
10
 
11
11
  def is_raro_crud(classe)
@@ -110,12 +110,12 @@ module CrudHelper
110
110
  permissions.uniq.flatten
111
111
  end
112
112
 
113
- def render_plus_button(field, f, modelo, record, options = {})
114
- field[:sf][:wrapper] = options[:wrapper] || :with_button
115
- render_field(field, f, modelo, record)
113
+ def render_plus_button(field,f,modelo,record)
114
+ field[:sf][:wrapper] = :with_button
115
+ render_field(field,f,modelo,record)
116
116
  end
117
117
 
118
- def render_field(field, f, modelo, record)
118
+ def render_field(field,f,modelo,record)
119
119
  field[:sf][:wrapper] ||= :default
120
120
  if field[:sf].present? && field[:sf][:if].present?
121
121
  return unless field[:sf][:if].call(f.object)
@@ -174,11 +174,11 @@ module CrudHelper
174
174
  end
175
175
 
176
176
  def render_field_file(field)
177
- if imagem?(field) && field.respond_to?(:thumb)
178
- if is_active_action("printing") || is_active_action("listing")
179
- pdf_image_tag(field, width: '100px')
177
+ if imagem?(field) && field.url(:thumb)
178
+ if is_active_action("printing")
179
+ wicked_pdf_image_tag(field.url(:thumb))
180
180
  else
181
- image_tag(field.url(:thumb), width: '100px')
181
+ image_tag(field.url(:thumb))
182
182
  end
183
183
  elsif video?(field)
184
184
  link_to field, field.url, target: "_blank"
@@ -196,71 +196,45 @@ module CrudHelper
196
196
  end
197
197
 
198
198
  #Permissions
199
- def should_view?(crud_helper, record)
199
+ def should_view?(crud_helper,record)
200
200
  return false unless can?(:read, record)
201
201
  return true if crud_helper.condition_view_action.nil?
202
202
  crud_helper.condition_view_action.call(record)
203
203
  end
204
204
 
205
- def should_edit?(crud_helper, record)
205
+ def should_edit?(crud_helper,record)
206
206
  return false unless can?(:update, record)
207
207
  return true if crud_helper.condition_edit_action.nil?
208
208
  crud_helper.condition_edit_action.call(record)
209
209
  end
210
210
 
211
- def should_destroy?(crud_helper, record)
211
+ def should_destroy?(crud_helper,record)
212
212
  return false unless can?(:destroy, record)
213
213
  return true if crud_helper.condition_destroy_action.nil?
214
214
  crud_helper.condition_destroy_action.call(record)
215
215
  end
216
216
 
217
- def should_listing?(crud_helper, model)
217
+ def should_listing?(crud_helper,model)
218
218
  return false unless can?(:read, model)
219
219
  return true if crud_helper.condition_listing_action.nil?
220
220
  crud_helper.condition_listing_action.call(model)
221
221
  end
222
222
 
223
- def should_listing_excel?(crud_helper, model)
223
+ def should_listing_excel?(crud_helper,model)
224
224
  return false unless can?(:read, model)
225
225
  return true if crud_helper.condition_listing_excel.nil?
226
226
  crud_helper.condition_listing_excel.call(model)
227
227
  end
228
228
 
229
- def should_listing_pdf?(crud_helper, model)
229
+ def should_listing_pdf?(crud_helper,model)
230
230
  return false unless can?(:read, model)
231
231
  return true if crud_helper.condition_listing_pdf.nil?
232
232
  crud_helper.condition_listing_pdf.call(model)
233
233
  end
234
234
 
235
- def can_print_pdf?(crud_helper, record)
235
+ def should_printing?(crud_helper,record)
236
236
  return false unless can?(:read, record)
237
237
  return true if crud_helper.condition_printing_action.nil?
238
238
  crud_helper.condition_printing_action.call(record)
239
239
  end
240
-
241
-
242
- private
243
-
244
- def pdf_image_tag(field, options = {})
245
- if Rails.env.development? || Rails.env.test?
246
- # Unless running a web server that can process 2 requests at the same
247
- # time, trying to insert an image in a PDF creates a deadlock: the server
248
- # can't finish processing the PDF request until it gets the image, but it
249
- # can't start processing the image request until it has finished
250
- # processing the PDF request.
251
- # This will not be a problem in production, but in dev, a workaround is
252
- # to base64 the image and insert its contents into the HTML
253
- if field.respond_to?(:thumb)
254
- image_data = File.read(field.thumb.path)
255
- else
256
- image_data = Rails.application.assets[field].to_s
257
- end
258
- image_tag("data:image/png;base64,#{::Base64.encode64(image_data)}", options)
259
- else
260
- if field.respond_to?(:thumb)
261
- field = field.thumb.url
262
- end
263
- wicked_pdf_image_tag(field, options)
264
- end
265
- end
266
240
  end
@@ -1,7 +1,7 @@
1
1
  module SearchHelper
2
2
 
3
- def raro_search_form(model, partial, collection_name, url, scope = nil, sort = nil)
4
- @buffer = raro_before_form(model, partial, collection_name, url, scope, sort)
3
+ def raro_search_form(model,partial,collection_name,url,sort = nil)
4
+ @buffer = raro_before_form(model,partial,collection_name,url,sort)
5
5
  @model = model
6
6
  yield
7
7
  @buffer << raro_submit(I18n.t('search'))
@@ -16,7 +16,7 @@ module SearchHelper
16
16
  "<div><input type='submit' class='btn btn-primary pull-right' value='#{name}' id='submit_raro_search'></div><br><br>"
17
17
  end
18
18
 
19
- def raro_field(name, opts = {})
19
+ def raro_field (name, opts = {})
20
20
  modelo = opts[:model] || @model
21
21
  unless opts[:model]
22
22
  prototype = @model.columns_hash[name.to_s]
@@ -26,7 +26,7 @@ module SearchHelper
26
26
  modelo = Module.const_get(opts[:model])
27
27
  name = opts[:full_name]
28
28
  end
29
- label = "simple_form.labels.#{modelo.name.underscore}.#{name}"
29
+ label = I18n.t("simple_form.labels.#{modelo.name.underscore}.#{name}")
30
30
  label = opts[:label] if opts[:label]
31
31
 
32
32
  @buffer << "<div class=\"form-group\">"
@@ -78,22 +78,20 @@ module SearchHelper
78
78
  end
79
79
 
80
80
  def raro_input_as(name,type,opts)
81
- if opts[:collection_if] and opts[:collection_if].class == Proc
82
- opts[:collection] = ActionView::Helpers::FormBuilder.instance_eval(&opts[:collection_if])
83
- end
84
81
  case opts[:as]
85
82
  when :select
83
+ if opts[:collection_if] and opts[:collection_if].class == Proc
84
+ opts[:collection] = ActionView::Helpers::FormBuilder.instance_eval &opts[:collection_if]
85
+ end
86
86
  raro_select(name,opts,opts[:collection])
87
87
  when :hidden
88
88
  return raro_hidden_field(name,opts[:value],opts)
89
89
  when :string
90
90
  raro_text_field(name, opts)
91
91
  when :range
92
- raro_range(name, opts)
92
+ raro_range(name)
93
93
  when :monthyear
94
94
  raro_monthyear(name, opts)
95
- when :check_boxes
96
- raro_check_boxes(name, opts, opts[:collection])
97
95
  end
98
96
  end
99
97
 
@@ -107,23 +105,6 @@ module SearchHelper
107
105
  return raro_select("q[#{model_name}_id_eq]",opts,collection)
108
106
  end
109
107
 
110
- def raro_check_boxes(name, opts, collection)
111
- unless opts[:model]
112
- name = "q[#{name}_eq]"
113
- end
114
- buf = "<div class='col-sm-12'>"
115
- input_class = opts[:input_html].try(:[], :class)
116
- collection.each do |e|
117
- buf << "<span class='checkbox' style='display: inline;'>"
118
- buf << "<label class='control-label'>"
119
- buf << "<input class='form-control check_boxes optional #{input_class}' type='checkbox' value='#{e[0]}' name='#{name}' style=''> #{e[1]}"
120
- buf << '</label>'
121
- buf << '</span>'
122
- end
123
- buf << '</div>'
124
- return buf
125
- end
126
-
127
108
  def raro_select(name,opts,collection)
128
109
  unless opts[:model]
129
110
  name = "q[#{name}_eq]"
@@ -134,9 +115,7 @@ module SearchHelper
134
115
  else
135
116
  buf << "<select name=#{name} class='form-control'>"
136
117
  end
137
- if opts[:include_blank].nil? || (!opts[:include_blank].nil? && ActiveRecord::Type::Boolean.new.type_cast_from_user(opts[:include_blank]))
138
- buf << "<option value='' selected>#{I18n.t('search')}</option>"
139
- end
118
+ buf <<"<option value ='' selected>#{I18n.t('search')}</option>"
140
119
  collection.each do |e|
141
120
  buf << "<option value=#{e[0]}>#{e[1]}</option>"
142
121
  end
@@ -149,7 +128,7 @@ module SearchHelper
149
128
  if opts[:as] and opts[:as] == :hidden
150
129
  ""
151
130
  else
152
- "<label class='col-sm-2 control-label'>#{I18n.t(name)}</label>"
131
+ "<label class='col-sm-2 control-label'>#{name}</label>"
153
132
  end
154
133
  end
155
134
 
@@ -231,33 +210,26 @@ module SearchHelper
231
210
  </div></div>"
232
211
  end
233
212
 
234
- def raro_range(name, opts={})
235
- attrs_gteq, attrs_lteq = "", ""
236
-
237
- if opts[:placeholders]
238
- placeholders = opts[:placeholders]
239
- attrs_gteq << "placeholder='#{placeholders.first}' "
240
- attrs_lteq << "placeholder='#{placeholders.last}' "
241
- end
242
-
213
+ def raro_range(name)
243
214
  buffer = ""
244
215
  buffer += "<div class='col-sm-4'>"
245
- buffer += "<input type='text' name='q[#{name}_gteq]' class='form-control' #{attrs_gteq}/>"
216
+ buffer += "<input type='text' name='q[#{name}_gteq]' class='form-control'/>"
246
217
  buffer += "</div>"
247
218
  buffer += "<div class='col-sm-4 range-separator'>"
248
- buffer += "<input type='text' name='q[#{name}_lteq]' class='form-control' #{attrs_lteq}/>"
219
+ buffer += "<input type='text' name='q[#{name}_lteq]' class='form-control'/>"
249
220
  buffer += "</div>"
250
221
  buffer
251
222
  end
252
223
 
253
- def raro_before_form(model, partial, var, url, scope, sort)
224
+ def raro_before_form(model,partial,var,url,sort)
254
225
  buffer = "<div id='search_box'>"+
255
226
  "<form method='get' class=form-horizontal action='#{url}' data-push='partial' data-target='#form'>" +
256
227
  "<input type='hidden' name='partial' value='#{partial}'>" +
257
228
  "<input type='hidden' name='var' value='#{var}'>"
258
- buffer << "<input type='hidden' name='q[s]' value='#{sort}'>" if sort.present?
259
- buffer << "<input type='hidden' name='scope' value='#{scope}'>" if scope.present?
260
- buffer
229
+ if sort
230
+ buffer << "<input type='hidden' name='q[s]' value='#{sort}'>"
231
+ end
232
+ buffer
261
233
  end
262
234
 
263
235
  def raro_after_form
@@ -289,7 +261,6 @@ module SearchHelper
289
261
  <option value=not_cont>#{I18n.t('not_contains')}</option>
290
262
  <option value=start>#{I18n.t('begins')}</option>
291
263
  <option value=end>#{I18n.t('ends')}</option>
292
- <option value=has_any_term>#{I18n.t('word')}</option>
293
264
  </select>"
294
265
  end
295
266