spotlight_search 0.3.1 → 0.3.2

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
  SHA256:
3
- metadata.gz: 576ead7e9ed602d984a2b141bbd9744df9f8ed760c32a72486f052af271aa6c9
4
- data.tar.gz: 18c0360d8fd6fba83ee3bf84ff30f2e6e0eddcd1543a4c6056d1f904d564fefd
3
+ metadata.gz: '099ecfc87e93555a16a5e494f3b88f69cbe8688c967444b5fac831dc62b5b650'
4
+ data.tar.gz: 5d3853b623df2045aadb98b70f69dfd9faf9b8d0878a4cb080bdeccaf6f5f396
5
5
  SHA512:
6
- metadata.gz: 17743dcac8dc528fd9f5cfa0713f51e109be3703f6d8ba3f380028b9ad65abd508acba501a7ee844e4e16cba8ba6d0ba4f00f9bac3d9fa8767f3c0bdf66a7772
7
- data.tar.gz: 4aba022bdfff558c868077abf3f200e02e540e7392c0953dc71a984f605f22921efff26059408c2b13ec284a818926bb930abdc44c46541b8ffd44deec040383
6
+ metadata.gz: 651ec6f74e9c8d4bae5678be1636a157e13fa2420446ce50e4f0f7d68a438c0247d3f682f1759aedeed5d99095e5bd4a39957e99cad62ea38d747ad17dd8a068
7
+ data.tar.gz: 909f5d9e9a2472bd63d4d7db9ecd77e9c0007f4b10072eb1106ff7f411b45bf103c47de44dd9e03c1c64d8099bf85aa5cd21780287881036a5c4880ce03a7ab4
@@ -26,6 +26,11 @@ module SpotlightSearch
26
26
  records = records.send(scope, scope_args)
27
27
  end
28
28
  end
29
+ if klass.default_filters.present?
30
+ klass.default_filters.each do |scope|
31
+ records = records.send(scope)
32
+ end
33
+ end
29
34
  if sort.present?
30
35
  records = records.order("#{sort['sort_column']} #{sort['sort_direction']}")
31
36
  end
@@ -32,6 +32,10 @@ module SpotlightSearch
32
32
  self.enabled_columns = [*record_fields, **associated_fields]
33
33
  end
34
34
 
35
+ def default_scopes_for_export(*filter_scopes)
36
+ self.default_filters = filter_scopes
37
+ end
38
+
35
39
  def _model_exportable_columns(klass, *record_fields, **associated_fields)
36
40
  # Gets all the valid columns of a model
37
41
  # If any column is invalid, it also returns it
@@ -85,6 +89,7 @@ module SpotlightSearch
85
89
 
86
90
  included do
87
91
  class_attribute :enabled_columns, instance_accessor: false, default: nil
92
+ class_attribute :default_filters, instance_accessor: false, default: nil
88
93
  end
89
94
  end
90
95
  end
@@ -18,20 +18,20 @@ module SpotlightSearch
18
18
  end
19
19
  end
20
20
 
21
- def column_pop_up(email, klass)
21
+ def column_pop_up(email, klass, required_filters = nil)
22
22
  tag.div class: "modal fade", id: "exportmodal", tabindex: "-1", role: "dialog", aria: {labelledby: "exportModal"} do
23
23
  tag.div class: "modal-dialog modal-lg", role: "document" do
24
24
  tag.div class: "modal-content" do
25
- concat pop_ups(email, klass)
25
+ concat pop_ups(email, klass, required_filters)
26
26
  end
27
27
  end
28
28
  end
29
29
  end
30
30
 
31
- def pop_ups(email, klass)
31
+ def pop_ups(email, klass, required_filters)
32
32
  tag.div do
33
33
  concat pop_up_header
34
- concat pop_up_body(email, klass)
34
+ concat pop_up_body(email, klass, required_filters)
35
35
  end
36
36
  end
37
37
 
@@ -44,11 +44,12 @@ module SpotlightSearch
44
44
  end
45
45
  end
46
46
 
47
- def pop_up_body(email, klass)
47
+ def pop_up_body(email, klass, required_filters)
48
48
  tag.div class: "modal-body" do
49
49
  form_tag '/spotlight_search/export_to_file', id: 'export-to-file-form', style: "width: 100%;", class:"spotlight-csv-export-form" do
50
50
  concat hidden_field_tag 'email', email, id: 'export-to-file-email'
51
51
  concat hidden_field_tag 'class_name', klass.to_s, id: 'export-to-file-klass'
52
+ filters_to_post_helper(required_filters) if required_filters
52
53
  params_to_post_helper(filters: controller.filter_params) if controller.filter_params
53
54
  params_to_post_helper(sort: controller.sort_params) if controller.sort_params
54
55
  case SpotlightSearch.exportable_columns_version
@@ -63,6 +64,12 @@ module SpotlightSearch
63
64
  end
64
65
  end
65
66
 
67
+ def filters_to_post_helper(required_filters)
68
+ URI.decode_www_form(required_filters.to_param).each do |param|
69
+ concat hidden_field_tag "filters[#{param[0]}]", param[1]
70
+ end
71
+ end
72
+
66
73
  def params_to_post_helper(params)
67
74
  URI.decode_www_form(params.to_param).each do |param|
68
75
  concat hidden_field_tag param[0], param[1]
@@ -1,3 +1,3 @@
1
1
  module SpotlightSearch
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  # s.require_paths = ["lib"]
25
25
 
26
26
  s.add_development_dependency "bundler", "~> 2.0"
27
- s.add_development_dependency "rake", ">= 12.3.3"
27
+ s.add_development_dependency "rake", "~> 13.0.1"
28
28
  s.add_development_dependency "rails", "~> 5.2.4.2"
29
29
  s.add_development_dependency "rspec", "~> 3.0"
30
30
  s.add_runtime_dependency 'caxlsx', "~> 3.0.1"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotlight_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anbazhagan Palani
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 12.3.3
33
+ version: 13.0.1
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 12.3.3
40
+ version: 13.0.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rails
43
43
  requirement: !ruby/object:Gem::Requirement