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 +4 -4
- data/app/controllers/crud_controller.rb +9 -6
- data/app/helpers/search_helper.rb +3 -1
- data/app/raro_crud/raro_crud.rb +0 -5
- data/app/views/crud/_search.html.erb +5 -5
- data/lib/templus_models/version.rb +1 -1
- metadata +614 -614
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa21c229faa68ac0391b4c89acadf0052db3abbb
|
4
|
+
data.tar.gz: 1088f6449ad2850d571b9a32a5dd8fd53776e1a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
14
|
-
@q.sorts =
|
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
|
-
|
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
|
data/app/raro_crud/raro_crud.rb
CHANGED
@@ -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
|
-
|
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>
|