templus_models 2.0.12 → 2.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcb8ba9975ee1f08a9420de3a78243cca0097454
4
- data.tar.gz: 151bbdc9cfc59ec043a6ad40b8fc2457f9d44069
3
+ metadata.gz: fa21c229faa68ac0391b4c89acadf0052db3abbb
4
+ data.tar.gz: 1088f6449ad2850d571b9a32a5dd8fd53776e1a4
5
5
  SHA512:
6
- metadata.gz: d76767de31c0b0f791087682d8427fab4fa40ce179d6a49a948f6bfe23dfcfa3e4268439afe302e255f3b4e7ffadf7fff91e52c8bb1785ac1ab89c8123e8d98c
7
- data.tar.gz: 82731b159abfaa488b55dffeca1db13b17836f121b35868c95065945c6457777e86f01be557c03a783ffd7fbf29cb45e382c81b68983a85d6f70c301a56d64d7
6
+ metadata.gz: f11e309a014478406d44236ac2fc3b31ebbf2a20c04ee37b90054f7e562bdda6dbe2c716c71134a295b52ad8a9501780fd11e87197a95a81af330d1a6ee7927e
7
+ data.tar.gz: 760c77819cf75d0caf4b40143dd2649844674e2ff9e11d7ac070e5a75f4692a65e5ddece225dd56d9e0bd5a5c63393d6425fcd7be7b2574e147c7962dfe5277f
@@ -1,7 +1,6 @@
1
1
  class CrudController < ApplicationController
2
2
  before_filter :setup, except: :autocomplete
3
3
 
4
-
5
4
  def index
6
5
  authorize! :read, @model_permission if respond_to?(:current_usuario)
7
6
  if params[:scope].present? && valid_method?(params[:scope])
@@ -10,8 +9,8 @@ class CrudController < ApplicationController
10
9
  @q = @model.search(params[:q])
11
10
  end
12
11
  if @q.sorts.empty?
13
- if "#{@crud_helper.order_field}".include?("desc") or "#{@crud_helper.order_field}".include?("asc")
14
- @q.sorts = "#{@crud_helper.order_field}"
12
+ if @crud_helper.order_field.to_s.include?("desc") || @crud_helper.order_field.to_s.include?("asc")
13
+ @q.sorts = @crud_helper.order_field.to_s
15
14
  else
16
15
  @q.sorts = "#{@crud_helper.order_field} asc"
17
16
  end
@@ -164,7 +163,13 @@ class CrudController < ApplicationController
164
163
  else
165
164
  @q = @model.search(params[:q])
166
165
  end
167
-
166
+ if @q.sorts.empty?
167
+ if @crud_helper.order_field.to_s.include?("desc") || @crud_helper.order_field.to_s.include?("asc")
168
+ @q.sorts = @crud_helper.order_field.to_s
169
+ else
170
+ @q.sorts = "#{@crud_helper.order_field} asc"
171
+ end
172
+ end
168
173
  if respond_to?(:current_usuario)
169
174
  @records = @q.result.accessible_by(current_ability)
170
175
  else
@@ -193,9 +198,7 @@ class CrudController < ApplicationController
193
198
  end
194
199
  end
195
200
 
196
-
197
201
  private
198
-
199
202
  def generate_pdf_report(opts, layout)
200
203
  html = render_to_string(layout)
201
204
  options = {
@@ -134,7 +134,9 @@ module SearchHelper
134
134
  else
135
135
  buf << "<select name=#{name} class='form-control'>"
136
136
  end
137
- buf << "<option value ='' selected>#{I18n.t('search')}</option>"
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
138
140
  collection.each do |e|
139
141
  buf << "<option value=#{e[0]}>#{e[1]}</option>"
140
142
  end
@@ -209,9 +209,6 @@ class RaroCrud
209
209
  @@menus
210
210
  end
211
211
 
212
-
213
-
214
-
215
212
  def self.campo_visualizacao(nome, opts = {})
216
213
  @@view_fields[self.to_s.to_sym] ||= []
217
214
  opts = set_default_label nome, opts
@@ -382,8 +379,6 @@ class RaroCrud
382
379
  @@form_scripts[self.to_s.to_sym] << script.to_s
383
380
  end
384
381
 
385
-
386
-
387
382
  private
388
383
 
389
384
  def self.modelo
@@ -13,16 +13,16 @@
13
13
  <% else %>
14
14
  <% url = query_crud_path(model: @model.name.underscore) %>
15
15
  <% end %>
16
- <%=raro_search_form(@model, 'records','records', url, params[:scope]) do%>
17
- <%raro_group "#{@crud_helper.title}"%>
18
- <%@crud_helper.search_fields.each do |att| %>
16
+ <%= raro_search_form(@model, 'records','records', url, params[:scope]) do %>
17
+ <% raro_group "#{@crud_helper.title}" %>
18
+ <% @crud_helper.search_fields.each do |att| %>
19
19
  <% if att[:sf].present? && !att[:sf][:visible_if].nil?%>
20
20
  <% if ((att[:sf][:visible_if].class == Proc && !att[:sf][:visible_if].call(att)) || (att[:sf][:visible_if].class != Proc && !att[:sf][:visible_if])) %>
21
21
  <% next %>
22
22
  <% end %>
23
23
  <% end %>
24
- <%raro_field att[:attribute], att[:sf]%>
25
- <%end%>
24
+ <% raro_field att[:attribute], att[:sf] %>
25
+ <% end %>
26
26
  <%end%>
27
27
  </div>
28
28
  </div>
@@ -1,3 +1,3 @@
1
1
  module TemplusModels
2
- VERSION = "2.0.12"
2
+ VERSION = "2.0.14"
3
3
  end