ransack_memory 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/ransack_memory/concern.rb +32 -40
- data/lib/ransack_memory/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53163621f241e9f3a29c0a8bffe48e32c5f3e60b
|
4
|
+
data.tar.gz: '0960d53e98ecbb53b8dd62589e4d277531d03978'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6844bd183a86491ab2f8f24538585ab557e1a00b9801ef03962342424e2df72e8077359a9e2a326c74e8aae60d37ca94b618a1eb5637aca2787d238a92bdb93
|
7
|
+
data.tar.gz: f4de744aac0b48d88d3e30f39d872d1854a1917677df5b5667d33bd168b06c250f96a8742cfdd73eadff3b500ce2880b2580b0ec52ea857cca8f75ae988519b2
|
@@ -3,54 +3,46 @@ module RansackMemory
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
def save_and_load_filters
|
6
|
+
|
7
|
+
session_key_base = "#{controller_name}_#{action_name}_#{request.xhr?}"
|
8
|
+
|
9
|
+
# permit search params
|
10
|
+
params[::RansackMemory::Core.config[:param]].permit! if params[::RansackMemory::Core.config[:param]].present? && params[::RansackMemory::Core.config[:param]].respond_to?(:permit)
|
6
11
|
|
7
12
|
# cancel filter if button pressed
|
8
|
-
if params[:cancel_filter]
|
9
|
-
|
10
|
-
session["#{
|
11
|
-
session["#{
|
13
|
+
if params[:cancel_filter] == "true"
|
14
|
+
session["#{session_key_base}"] = nil
|
15
|
+
session["#{session_key_base}_page"] = nil
|
16
|
+
session["#{session_key_base}_per_page"] = nil
|
12
17
|
end
|
13
18
|
|
14
|
-
|
15
|
-
|
16
|
-
session["#{controller_name}_#{action_name}_#{request.xhr?}"] = params[::RansackMemory::Core.config[:param]] if params[::RansackMemory::Core.config[:param]].present?
|
19
|
+
# search term saving
|
20
|
+
session["#{session_key_base}"] = params[::RansackMemory::Core.config[:param]] if params[::RansackMemory::Core.config[:param]].present?
|
17
21
|
|
18
|
-
|
19
|
-
|
22
|
+
# page number saving
|
23
|
+
session["#{session_key_base}_page"] = params[:page] if params[:page].present?
|
20
24
|
|
21
|
-
|
22
|
-
|
23
|
-
|
25
|
+
# per page saving
|
26
|
+
session["#{session_key_base}_per_page"] = params[:per_page] if params[:per_page].present?
|
27
|
+
|
28
|
+
# search term load
|
29
|
+
params[::RansackMemory::Core.config[:param]] = session["#{session_key_base}"].presence
|
30
|
+
|
31
|
+
# page number load
|
32
|
+
params[:page] = session["#{session_key_base}_page"].presence
|
24
33
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
# page number load
|
34
|
-
if session["#{controller_name}_#{action_name}_#{request.xhr?}_page"]
|
35
|
-
params[:page] = session["#{controller_name}_#{action_name}_#{request.xhr?}_page"]
|
36
|
-
else
|
37
|
-
params[:page] = nil
|
38
|
-
end
|
39
|
-
|
40
|
-
# set page number to 1 if filter has changed
|
41
|
-
if (params[::RansackMemory::Core.config[:param]] && session[:last_q_params] != params[::RansackMemory::Core.config[:param]]) || (params[:cancel_filter].present? && session["#{controller_name}_#{action_name}_#{request.xhr?}_page"] != params[:page])
|
42
|
-
params[:page] = nil
|
43
|
-
session["#{controller_name}_#{action_name}_#{request.xhr?}_page"] = nil
|
44
|
-
end
|
45
|
-
session[:last_q_params] = params[::RansackMemory::Core.config[:param]]
|
46
|
-
|
47
|
-
# per page load
|
48
|
-
if session["#{controller_name}_#{action_name}_#{request.xhr?}_per_page"]
|
49
|
-
params[:per_page] = session["#{controller_name}_#{action_name}_#{request.xhr?}_per_page"]
|
50
|
-
else
|
51
|
-
params[:per_page] = nil
|
52
|
-
end
|
34
|
+
# per page load
|
35
|
+
params[:per_page] = session["#{session_key_base}_per_page"].presence
|
36
|
+
|
37
|
+
# set page number to 1 if filter has changed
|
38
|
+
if (params[::RansackMemory::Core.config[:param]].present? && session[:last_q_params] != params[::RansackMemory::Core.config[:param]]) || (params[:cancel_filter].present? && session["#{session_key_base}_page"] != params[:page])
|
39
|
+
params[:page] = nil
|
40
|
+
session["#{session_key_base}_page"] = nil
|
53
41
|
end
|
42
|
+
|
43
|
+
session[:last_q_params] = params[::RansackMemory::Core.config[:param]]
|
44
|
+
|
45
|
+
# session[:last_page] = params[:page]
|
54
46
|
end
|
55
47
|
end
|
56
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ransack_memory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Lapiš
|
@@ -36,17 +36,17 @@ require_paths:
|
|
36
36
|
- lib
|
37
37
|
required_ruby_version: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 1.9.3
|
42
42
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
48
|
rubyforge_project:
|
49
|
-
rubygems_version: 2.
|
49
|
+
rubygems_version: 2.6.13
|
50
50
|
signing_key:
|
51
51
|
specification_version: 3
|
52
52
|
summary: Automatically save and load ransack's filtered params into session
|