query_report 1.1.6 → 1.2.0

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: c7c4f93c3d1db2c3020ccb05da0a7df39bbaa51b
4
- data.tar.gz: 158c20b9597d04794338c6e1a08ddef00b18cb88
3
+ metadata.gz: 5ce02cd7debc185a658c3dbfb5e94dbdfc2e9d4c
4
+ data.tar.gz: 517bdde0743ffa34f3c5d72301f5e4b002c677d7
5
5
  SHA512:
6
- metadata.gz: 1f1ce0811decdced72db58b0350a0000c3a0e824faab110637da3914fe740ddd1e5a72838c6445ee21c68676873075dd6a6c14d76b16eb14c49d6835a13e40a7
7
- data.tar.gz: b64fa7daecfdee2dd08844cde10fc0795b45adcf801b70d11de5411172da41039013aa5c7ac06ce6523f46c2f2828eb55abc0de3a556f566902fb6b2016ee174
6
+ metadata.gz: e0980f847f2aed410c2e2224f1de2429c95fcacb3eb57ac6b32f75c0651e0bf45a5efe2841d2a4b2dc4631fde9988f3a551dc2403f67925e1301b9a29806a996
7
+ data.tar.gz: 3f22e626b4e4f3ae13f2c6d6b9be0b44c06f39093790d7170fb71c8195677c1b738ce1d3ce69073d2890448afb1d7bdb3022f1b3e031480b3b379d236b6c5c17
@@ -46,4 +46,12 @@ module QueryReportEngineHelper
46
46
 
47
47
  tags.join("\n").html_safe
48
48
  end
49
+
50
+ def query_report_search_form(report, &block)
51
+ if report.array_record?
52
+ form_tag(url_for({}), (QueryReport.config.search_form_options || {}).merge({method: :get, remote: @remote}), &block)
53
+ else
54
+ search_form_for(report.search, url: url_for({}), remote: @remote, html: (QueryReport.config.search_form_options || {}).merge(method: :get), &block)
55
+ end
56
+ end
49
57
  end
@@ -2,8 +2,7 @@
2
2
  params_for_url.delete(:q)
3
3
  params_for_url.delete(:custom_search) %>
4
4
 
5
- <%= search_form_for report.search, url: url_for({}), remote: @remote,
6
- html: (QueryReport.config.search_form_options || {}).merge(method: :get) do |f| %>
5
+ <%= query_report_search_form(report) do |f| %>
7
6
  <%= hash_to_hidden_fields params_for_url %>
8
7
  <% report.filters.each do |filter| %>
9
8
  <% filter.comparators.each do |comparator| %>
@@ -15,5 +14,5 @@
15
14
  <%= hidden_field_tag :subject %>
16
15
  <%= hidden_field_tag :message %>
17
16
  <%= hidden_field_tag :target_dom_id, @target_dom_id %>
18
- <%= f.submit t('query_report.labels.search'), :class => QueryReport.config.search_button_class, :onclick => "$('#{@target_dom_id} #send_as_email').val(0);" %>
17
+ <%= submit_tag t('query_report.labels.search'), :class => QueryReport.config.search_button_class, :onclick => "$('#{@target_dom_id} #send_as_email').val(0);" %>
19
18
  <% end %>
@@ -134,7 +134,7 @@ module QueryReport
134
134
  end
135
135
 
136
136
  def humanize
137
- @humanize ||= options[:as] || @report.model_class.human_attribute_name(name)
137
+ @humanize ||= options[:as] || (@report.model_class.human_attribute_name(name) unless @report.array_record?)
138
138
  end
139
139
 
140
140
  def value(record)
@@ -6,6 +6,10 @@ module QueryReport
6
6
  query.klass
7
7
  end
8
8
 
9
+ def array_record?
10
+ query.kind_of?(Array)
11
+ end
12
+
9
13
  def filtered_query
10
14
  apply
11
15
  @filtered_query
@@ -22,16 +26,18 @@ module QueryReport
22
26
  end
23
27
 
24
28
  def apply
25
- @filtered_query ||= apply_filters(query.clone, @params)
26
- @paginated_query ||= apply_pagination(@filtered_query, @params)
29
+ @filtered_query ||= array_record? ? query : apply_filters(query.clone, @params)
30
+ @paginated_query ||= array_record? ? query : apply_pagination(@filtered_query, @params)
27
31
  end
28
32
 
29
33
  def records
30
- @records ||= map_record(paginated_query, true)
34
+ record_to_map = array_record? ? query : paginated_query
35
+ @records ||= map_record(record_to_map, true)
31
36
  end
32
37
 
33
38
  def all_records
34
- @all_records ||= map_record(filtered_query, false)
39
+ record_to_map = array_record? ? query : filtered_query
40
+ @all_records ||= map_record(record_to_map, false)
35
41
  end
36
42
 
37
43
  def map_record(query, render_from_view)
@@ -41,6 +41,7 @@ module QueryReport
41
41
  end
42
42
 
43
43
  def paginate?
44
+ return false if array_record? #do not paginate on the array records
44
45
  return true if @options[:paginate].nil?
45
46
  @options[:paginate]
46
47
  end
@@ -1,3 +1,3 @@
1
1
  module QueryReport
2
- VERSION = "1.1.6"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: query_report
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - A.K.M. Ashrafuzzaman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-12 00:00:00.000000000 Z
11
+ date: 2014-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '1.0'
39
+ version: '1.2'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '1.0'
46
+ version: '1.2'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: google_visualr
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -198,6 +198,20 @@ dependencies:
198
198
  - - "~>"
199
199
  - !ruby/object:Gem::Version
200
200
  version: '3'
201
+ - !ruby/object:Gem::Dependency
202
+ name: rspec-rails
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - "~>"
206
+ - !ruby/object:Gem::Version
207
+ version: '3'
208
+ type: :development
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - "~>"
213
+ - !ruby/object:Gem::Version
214
+ version: '3'
201
215
  - !ruby/object:Gem::Dependency
202
216
  name: rspec-mocks
203
217
  requirement: !ruby/object:Gem::Requirement