templus_models 2.0.11 → 2.0.12

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: 0dfa4871df0259f538bedc70333fd4d51f8b997d
4
- data.tar.gz: b4745585cf0769114562a7bd6b9a0ecb070ff4e0
3
+ metadata.gz: fcb8ba9975ee1f08a9420de3a78243cca0097454
4
+ data.tar.gz: 151bbdc9cfc59ec043a6ad40b8fc2457f9d44069
5
5
  SHA512:
6
- metadata.gz: 3fb34a5a5bbc3885e10f6be6807daadbe955ec77aa61e76d70ce129d8082c035cc8065b1f5eeb9dba6829c41ab08d48ea9ab6e76aa79ffa86510adb1d1c7715e
7
- data.tar.gz: b86b4f0ec6bef0c25abb8b1f344927e3d98d56f193ad56a81c2fadfe214d58f94bba386fedde6b4677d79f158d56de57ecf73e86d1328b62cbe66b94331a2e04
6
+ metadata.gz: d76767de31c0b0f791087682d8427fab4fa40ce179d6a49a948f6bfe23dfcfa3e4268439afe302e255f3b4e7ffadf7fff91e52c8bb1785ac1ab89c8123e8d98c
7
+ data.tar.gz: 82731b159abfaa488b55dffeca1db13b17836f121b35868c95065945c6457777e86f01be557c03a783ffd7fbf29cb45e382c81b68983a85d6f70c301a56d64d7
@@ -118,7 +118,11 @@ class CrudController < ApplicationController
118
118
  def query
119
119
  authorize! :read, @model_permission if respond_to?(:current_usuario)
120
120
  @resource = @model
121
- @q = @resource.search(params[:q])
121
+ if params[:scope].present? && valid_method?(params[:scope])
122
+ @q = @model.send(params[:scope]).search(params[:q])
123
+ else
124
+ @q = @model.search(params[:q])
125
+ end
122
126
  @q.sorts = 'updated_at desc' if @q.sorts.empty?
123
127
  if respond_to?(:current_usuario)
124
128
  results = @q.result.accessible_by(current_ability).page(params[:page])
@@ -155,7 +159,12 @@ class CrudController < ApplicationController
155
159
 
156
160
  def listing
157
161
  authorize! :read, @model_permission if respond_to?(:current_usuario)
158
- @q = @model.search(params[:q])
162
+ if params[:scope].present? && valid_method?(params[:scope])
163
+ @q = @model.send(params[:scope]).search(params[:q])
164
+ else
165
+ @q = @model.search(params[:q])
166
+ end
167
+
159
168
  if respond_to?(:current_usuario)
160
169
  @records = @q.result.accessible_by(current_ability)
161
170
  else
@@ -1,7 +1,7 @@
1
1
  module SearchHelper
2
2
 
3
- def raro_search_form(model,partial,collection_name,url,sort = nil)
4
- @buffer = raro_before_form(model,partial,collection_name,url,sort)
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)
5
5
  @model = model
6
6
  yield
7
7
  @buffer << raro_submit(I18n.t('search'))
@@ -240,14 +240,13 @@ module SearchHelper
240
240
  buffer
241
241
  end
242
242
 
243
- def raro_before_form(model,partial,var,url,sort)
243
+ def raro_before_form(model, partial, var, url, scope, sort)
244
244
  buffer = "<div id='search_box'>"+
245
245
  "<form method='get' class=form-horizontal action='#{url}' data-push='partial' data-target='#form'>" +
246
246
  "<input type='hidden' name='partial' value='#{partial}'>" +
247
247
  "<input type='hidden' name='var' value='#{var}'>"
248
- if sort
249
- buffer << "<input type='hidden' name='q[s]' value='#{sort}'>"
250
- end
248
+ buffer << "<input type='hidden' name='q[s]' value='#{sort}'>" if sort.present?
249
+ buffer << "<input type='hidden' name='scope' value='#{scope}'>" if scope.present?
251
250
  buffer
252
251
  end
253
252
 
@@ -13,7 +13,7 @@
13
13
  <% else %>
14
14
  <% url = query_crud_path(model: @model.name.underscore) %>
15
15
  <% end %>
16
- <%=raro_search_form(@model, 'records','records', url) do%>
16
+ <%=raro_search_form(@model, 'records','records', url, params[:scope]) do%>
17
17
  <%raro_group "#{@crud_helper.title}"%>
18
18
  <%@crud_helper.search_fields.each do |att| %>
19
19
  <% if att[:sf].present? && !att[:sf][:visible_if].nil?%>
@@ -38,11 +38,11 @@
38
38
  <% if params[:associacao] %>
39
39
  <% if @crud_helper.listing_fields.present? && should_listing?(@crud_helper, @model_permission) %>
40
40
 
41
- <%= link_to listing_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], q: params[:q], format: :xls), class: "btn btn-success btn-rounded" do %>
41
+ <%= link_to listing_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], scope: params[:scope], q: params[:q], format: :xls), class: "btn btn-success btn-rounded" do %>
42
42
  <%= I18n.t("devise.reports.excel").html_safe %>
43
43
  <% end if should_listing_excel?(@crud_helper, @model_permission) %>
44
44
 
45
- <%= link_to listing_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], q: params[:q], format: :pdf), class: "btn btn-success btn-rounded", target: '_blank' do %>
45
+ <%= link_to listing_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], q: params[:q], scope: params[:scope], format: :pdf), class: "btn btn-success btn-rounded", target: '_blank' do %>
46
46
  <%= I18n.t("devise.reports.pdf").html_safe %>
47
47
  <% end if should_listing_pdf?(@crud_helper, @model_permission) %>
48
48
 
@@ -50,11 +50,11 @@
50
50
  <% else %>
51
51
  <% if @crud_helper.listing_fields.present? && should_listing?(@crud_helper, @model) %>
52
52
 
53
- <%= link_to listing_crud_path(model: @model.name.underscore, q: params[:q], format: :xls), class: "btn btn-success btn-rounded" do %>
53
+ <%= link_to listing_crud_path(model: @model.name.underscore, q: params[:q], scope: params[:scope], format: :xls), class: "btn btn-success btn-rounded" do %>
54
54
  <%= I18n.t("devise.reports.excel").html_safe %>
55
55
  <% end if should_listing_excel?(@crud_helper, @model) %>
56
56
 
57
- <%= link_to listing_crud_path(model: @model.name.underscore, q: params[:q], target: '_blank', format: :pdf), class: "btn btn-success btn-rounded", target: '_blank' do %>
57
+ <%= link_to listing_crud_path(model: @model.name.underscore, q: params[:q], scope: params[:scope], target: '_blank', format: :pdf), class: "btn btn-success btn-rounded", target: '_blank' do %>
58
58
  <%= I18n.t("devise.reports.pdf").html_safe %>
59
59
  <% end if should_listing_pdf?(@crud_helper, @model) %>
60
60
 
@@ -1,3 +1,3 @@
1
1
  module TemplusModels
2
- VERSION = "2.0.11"
2
+ VERSION = "2.0.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: templus_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.11
4
+ version: 2.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Sol
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-07-28 00:00:00.000000000 Z
13
+ date: 2017-10-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails