card-mod-search 0.14.2 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -0
- data/assets/script/autocomplete.js.coffee +36 -0
- data/assets/script/search_box.js.coffee +24 -0
- data/assets/style/search.scss +69 -0
- data/data/files/mod_search_script_asset_output/file.js +4 -0
- data/data/real.yml +112 -0
- data/data/test.yml +18 -0
- data/lib/card/mod/search.rb +4 -0
- data/locales/en.yml +4 -0
- data/set/abstract/0_search/checkbox_item.haml +6 -0
- data/set/abstract/{02_search_params.rb → 0_search/search_params.rb} +2 -4
- data/set/abstract/{05_search → 0_search}/views.rb +32 -46
- data/set/abstract/{05_search.rb → 0_search.rb} +3 -9
- data/set/abstract/{06_cql_search.rb → cql_search.rb} +3 -6
- data/set/abstract/search_views.rb +1 -2
- data/set/abstract/virtual_search.rb +3 -0
- data/set/all/autocomplete/autocomplete_input.haml +3 -0
- data/set/all/autocomplete/autocomplete_item.haml +5 -0
- data/set/all/autocomplete.rb +48 -0
- data/set/right/by_create.rb +7 -0
- data/set/right/by_name.rb +7 -0
- data/set/right/by_update.rb +7 -0
- data/set/right/children.rb +8 -0
- data/set/right/count.rb +9 -0
- data/set/right/created.rb +8 -0
- data/set/right/creator.rb +7 -0
- data/set/right/edited.rb +8 -0
- data/set/right/editors.rb +8 -0
- data/set/right/last_edited.rb +7 -0
- data/set/right/linked_to_by.rb +8 -0
- data/set/right/links_to.rb +7 -1
- data/set/right/mates.rb +9 -1
- data/set/right/nested_by.rb +9 -1
- data/set/right/nests.rb +8 -0
- data/set/right/referred_to_by.rb +8 -0
- data/set/right/refers_to.rb +8 -0
- data/set/self/recent.rb +38 -4
- data/set/self/search/results_for_keyword.haml +5 -0
- data/set/self/search/search_box.haml +2 -0
- data/set/self/search.rb +88 -40
- data/set/type/cardtype.rb +11 -1
- metadata +62 -28
- data/lib/card/filter_query.rb +0 -78
- data/set/abstract/00_filter_helper.rb +0 -46
- data/set/abstract/03_filter/_filter_input.haml +0 -8
- data/set/abstract/03_filter/filter_form.haml +0 -56
- data/set/abstract/03_filter/filter_form.rb +0 -101
- data/set/abstract/03_filter/filtered_content.haml +0 -5
- data/set/abstract/03_filter/form_helper.rb +0 -105
- data/set/abstract/03_filter/query_construction.rb +0 -38
- data/set/abstract/03_filter/quick_filters.haml +0 -11
- data/set/abstract/03_filter/selectable_filtered_content.haml +0 -2
- data/set/abstract/03_filter.rb +0 -30
- data/set/abstract/05_search/checkbox_item.haml +0 -5
- data/set/abstract/05_search/select_item.haml +0 -15
- data/set/abstract/filter_list.rb +0 -11
- data/set/abstract/filterable.rb +0 -13
- data/set/abstract/filterable_bar.rb +0 -11
- data/set/right/follow.rb +0 -3
data/set/right/edited.rb
CHANGED
data/set/right/editors.rb
CHANGED
data/set/right/linked_to_by.rb
CHANGED
data/set/right/links_to.rb
CHANGED
data/set/right/mates.rb
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
-
|
1
|
+
include_set Abstract::VirtualSearch
|
2
|
+
|
3
|
+
assign_type :search_type
|
4
|
+
|
5
|
+
def cql_content
|
6
|
+
{ plus: "_left", sort_by: "name" }
|
7
|
+
end
|
8
|
+
|
9
|
+
def raw_help_text
|
2
10
|
"If there is a card named \"X+{{_left|name}}\", then X is a mate of {{_left|name}}."
|
3
11
|
end
|
data/set/right/nested_by.rb
CHANGED
data/set/right/nests.rb
CHANGED
data/set/right/referred_to_by.rb
CHANGED
data/set/right/refers_to.rb
CHANGED
data/set/self/recent.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
ACTS_PER_PAGE = 25
|
2
|
+
MAX_ACTS_TO_SCAN = 10_000
|
2
3
|
|
3
4
|
view :title do
|
4
5
|
voo.title ||= "Recent Changes"
|
@@ -6,12 +7,17 @@ view :title do
|
|
6
7
|
end
|
7
8
|
|
8
9
|
def recent_acts
|
9
|
-
|
10
|
-
|
10
|
+
limiting_scan do
|
11
|
+
Act.joins(ar_actions: :ar_card).distinct
|
12
|
+
.where(Query::CardQuery.viewable_sql)
|
13
|
+
.where("draft is not true")
|
14
|
+
.order id: :desc
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
13
|
-
def
|
14
|
-
|
18
|
+
def limiting_scan
|
19
|
+
min_id = Card::Act.maximum(:id) - MAX_ACTS_TO_SCAN
|
20
|
+
min_id.positive? ? yield.where("card_acts.id > #{min_id}") : yield
|
15
21
|
end
|
16
22
|
|
17
23
|
format :html do
|
@@ -27,3 +33,31 @@ format :rss do
|
|
27
33
|
render_blank
|
28
34
|
end
|
29
35
|
end
|
36
|
+
|
37
|
+
# *Strat 1: WHERE EXISTS*
|
38
|
+
# ~~~~~~~~~~~~~~~~~~~~~~~
|
39
|
+
# SELECT `card_acts`.* FROM `card_acts` WHERE EXISTS (
|
40
|
+
# SELECT `card_actions`.*
|
41
|
+
# FROM `card_actions`
|
42
|
+
# INNER JOIN `cards` ON `cards`.`id` = `card_actions`.`card_id`
|
43
|
+
# WHERE (draft is not true)
|
44
|
+
# AND (card_acts.id = card_act_id)
|
45
|
+
# ) ORDER BY `card_acts`.`id` DESC LIMIT 20;
|
46
|
+
#
|
47
|
+
#
|
48
|
+
# *Strat 2: INNER JOIN*
|
49
|
+
# ~~~~~~~~~~~~~~~~~~~~~
|
50
|
+
# SELECT DISTINCT `card_acts`.* FROM `card_acts`
|
51
|
+
# JOIN `card_actions` ON card_acts.id = card_act_id
|
52
|
+
# JOIN `cards` ON `cards`.`id` = `card_actions`.`card_id`
|
53
|
+
# WHERE (draft is not true)
|
54
|
+
# ORDER BY `card_acts`.`id` DESC LIMIT 20;
|
55
|
+
|
56
|
+
# 11:33
|
57
|
+
# first run times:
|
58
|
+
# mysql 5.7:
|
59
|
+
# - strat 1: 0.22 sec (possibly in cache already?)
|
60
|
+
# - strat 2: 3min 17 sec
|
61
|
+
# mysql 8.0
|
62
|
+
# - strat 1: 2min 1 sec
|
63
|
+
# - strat 2: 0.01 sec
|
data/set/self/search.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
+
def match_start_only?
|
2
|
+
Card.config.search_box_match_start_only
|
3
|
+
end
|
4
|
+
|
1
5
|
format do
|
2
|
-
|
3
|
-
sr_class = search_with_params.class.to_s
|
6
|
+
delegate :match_start_only?, to: :card
|
4
7
|
|
8
|
+
view :search_error, cache: :never do
|
5
9
|
# don't show card content; not very helpful in this case
|
6
|
-
%(#{
|
10
|
+
%(#{search_with_params.class} :: #{search_with_params.message})
|
7
11
|
end
|
8
12
|
|
9
13
|
def search_with_params
|
@@ -12,13 +16,11 @@ format do
|
|
12
16
|
|
13
17
|
def cql_search
|
14
18
|
query = card.parse_json_cql search_keyword
|
15
|
-
rescuing_bad_query query
|
16
|
-
Card.search query
|
17
|
-
end
|
19
|
+
rescuing_bad_query(query) { Card.search query }
|
18
20
|
end
|
19
21
|
|
20
22
|
def search_keyword
|
21
|
-
@search_keyword ||= search_vars&.dig
|
23
|
+
@search_keyword ||= term_param || search_vars&.dig(:keyword)
|
22
24
|
end
|
23
25
|
|
24
26
|
def search_vars
|
@@ -28,65 +30,111 @@ format do
|
|
28
30
|
def cql_keyword?
|
29
31
|
search_keyword&.match?(/^\{.+\}$/)
|
30
32
|
end
|
33
|
+
|
34
|
+
def complete_path
|
35
|
+
path mark: :search, view: :search_box_complete, format: :json
|
36
|
+
# path mark: :search, view: :test, format: :json
|
37
|
+
end
|
38
|
+
|
39
|
+
def results_path keyword
|
40
|
+
path mark: :search, query: { keyword: keyword }
|
41
|
+
end
|
31
42
|
end
|
32
43
|
|
33
44
|
format :html do
|
34
|
-
view :
|
35
|
-
|
45
|
+
view :search_box, template: :haml, cache: :never
|
46
|
+
|
47
|
+
view :title do
|
48
|
+
voo.title ||= t(:search_results_title)
|
49
|
+
super()
|
50
|
+
end
|
36
51
|
|
37
|
-
|
52
|
+
view :core, cache: :never do
|
53
|
+
[render_results_for_keyword, super()]
|
38
54
|
end
|
39
55
|
|
40
|
-
|
41
|
-
|
42
|
-
|
56
|
+
view :results_for_keyword, cache: :never, template: :haml
|
57
|
+
|
58
|
+
def search_item term
|
59
|
+
autocomplete_item :search, icon_tag(:search), term
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def search_form &block
|
65
|
+
form_tag path, method: "get", role: "search", class: classy("search-box-form"), &block
|
66
|
+
end
|
67
|
+
|
68
|
+
def search_box_contents
|
69
|
+
text_field_tag "query[keyword]", search_keyword,
|
70
|
+
class: "_search-box #{classy 'search-box'} form-control w-100",
|
71
|
+
autocomplete: :off,
|
72
|
+
data: { completepath: complete_path },
|
73
|
+
placeholder: t(:search_search_box_placeholder)
|
43
74
|
end
|
44
75
|
end
|
45
76
|
|
46
77
|
format :json do
|
78
|
+
view :search_box_complete, cache: :never do
|
79
|
+
search_box_items :search_item, :add_item, :goto_items
|
80
|
+
end
|
81
|
+
|
47
82
|
view :complete, cache: :never do
|
48
|
-
|
49
|
-
|
83
|
+
complete_or_match_search(start_only: match_start_only?).map do |name|
|
84
|
+
goto_item_label name
|
85
|
+
end
|
86
|
+
end
|
50
87
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
88
|
+
private
|
89
|
+
|
90
|
+
def search_box_items *methods
|
91
|
+
[].tap do |items|
|
92
|
+
each_search_box_item methods do |action, value, label, data|
|
93
|
+
items << data.merge(action: action, value: value, label: label)
|
94
|
+
end
|
95
|
+
end
|
58
96
|
end
|
59
97
|
|
60
|
-
def
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
98
|
+
def each_search_box_item methods, &block
|
99
|
+
term = search_keyword
|
100
|
+
exact = Card.fetch term, new: {}
|
101
|
+
methods.map { |method| send method, term, exact, &block }
|
102
|
+
end
|
65
103
|
|
66
|
-
|
104
|
+
def search_item term, _exact
|
105
|
+
yield :search, term, card.format.search_item(term), url: card_url(results_path(term))
|
67
106
|
end
|
68
107
|
|
69
|
-
def
|
70
|
-
return unless
|
71
|
-
Card.new(type_id: exact.id).ok?(:create)
|
108
|
+
def add_item term, exact
|
109
|
+
return unless exact.add_autocomplete_ok?
|
72
110
|
|
73
|
-
|
111
|
+
fmt = exact.format
|
112
|
+
yield :add, term, fmt.render_add_autocomplete_item,
|
113
|
+
url: card_url(fmt.add_autocomplete_item_path)
|
74
114
|
end
|
75
115
|
|
76
|
-
def goto_items
|
77
|
-
|
78
|
-
|
79
|
-
goto_names.map do |name|
|
80
|
-
[name, name.to_name.url_key, h(highlight(name, term, sanitize: false))]
|
116
|
+
def goto_items _term, exact
|
117
|
+
map_goto_items exact do |item|
|
118
|
+
yield :goto, item, goto_item_label(item), url: path(mark: item)
|
81
119
|
end
|
82
120
|
end
|
83
121
|
|
84
|
-
def
|
85
|
-
|
122
|
+
def goto_item_label item
|
123
|
+
item.card.format.render_goto_autocomplete_item
|
124
|
+
end
|
125
|
+
|
126
|
+
def map_goto_items exact, &block
|
127
|
+
goto_names = complete_or_match_search start_only: match_start_only?
|
128
|
+
goto_names.unshift exact.name if exact.known?
|
129
|
+
goto_names.uniq.map(&block)
|
86
130
|
end
|
87
131
|
|
88
132
|
def term_param
|
89
|
-
|
133
|
+
# return nil unless query_params.present?
|
134
|
+
#
|
135
|
+
# term = query_params[:keyword]
|
136
|
+
return unless (term = super)&.present?
|
137
|
+
|
90
138
|
if (term =~ /^\+/) && (main = params["main"])
|
91
139
|
term = main + term
|
92
140
|
end
|
data/set/type/cardtype.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
include_set Abstract::CqlSearch
|
2
2
|
|
3
3
|
def cql_content
|
4
|
-
{ type_id: id,
|
4
|
+
{ type_id: id, sort_by: :name }
|
5
|
+
end
|
6
|
+
|
7
|
+
def add_autocomplete_ok?
|
8
|
+
card.create_ok?
|
9
|
+
end
|
10
|
+
|
11
|
+
format :html do
|
12
|
+
def add_autocomplete_item_path
|
13
|
+
path action: :new
|
14
|
+
end
|
5
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card-mod-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-01-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: card
|
@@ -18,28 +18,56 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.105.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.
|
28
|
+
version: 1.105.0
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: card-mod-collection
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.
|
35
|
+
version: 0.15.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.
|
42
|
+
version: 0.15.0
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: card-mod-format
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.15.0
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - '='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.15.0
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: card-mod-help
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - '='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.15.0
|
64
|
+
type: :runtime
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 0.15.0
|
43
71
|
description: ''
|
44
72
|
email:
|
45
73
|
- info@decko.org
|
@@ -47,32 +75,35 @@ executables: []
|
|
47
75
|
extensions: []
|
48
76
|
extra_rdoc_files: []
|
49
77
|
files:
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
- set/abstract/
|
60
|
-
- set/abstract/
|
61
|
-
- set/abstract/
|
62
|
-
- set/abstract/
|
63
|
-
- set/abstract/
|
64
|
-
- set/abstract/05_search/select_item.haml
|
65
|
-
- set/abstract/05_search/views.rb
|
66
|
-
- set/abstract/06_cql_search.rb
|
67
|
-
- set/abstract/filter_list.rb
|
68
|
-
- set/abstract/filterable.rb
|
69
|
-
- set/abstract/filterable_bar.rb
|
78
|
+
- README.md
|
79
|
+
- assets/script/autocomplete.js.coffee
|
80
|
+
- assets/script/search_box.js.coffee
|
81
|
+
- assets/style/search.scss
|
82
|
+
- data/files/mod_search_script_asset_output/file.js
|
83
|
+
- data/real.yml
|
84
|
+
- data/test.yml
|
85
|
+
- lib/card/mod/search.rb
|
86
|
+
- locales/en.yml
|
87
|
+
- set/abstract/0_search.rb
|
88
|
+
- set/abstract/0_search/checkbox_item.haml
|
89
|
+
- set/abstract/0_search/search_params.rb
|
90
|
+
- set/abstract/0_search/views.rb
|
91
|
+
- set/abstract/cql_search.rb
|
70
92
|
- set/abstract/search_views.rb
|
93
|
+
- set/abstract/virtual_search.rb
|
94
|
+
- set/all/autocomplete.rb
|
95
|
+
- set/all/autocomplete/autocomplete_input.haml
|
96
|
+
- set/all/autocomplete/autocomplete_item.haml
|
97
|
+
- set/right/by_create.rb
|
98
|
+
- set/right/by_name.rb
|
99
|
+
- set/right/by_update.rb
|
71
100
|
- set/right/children.rb
|
101
|
+
- set/right/count.rb
|
72
102
|
- set/right/created.rb
|
103
|
+
- set/right/creator.rb
|
73
104
|
- set/right/edited.rb
|
74
105
|
- set/right/editors.rb
|
75
|
-
- set/right/
|
106
|
+
- set/right/last_edited.rb
|
76
107
|
- set/right/linked_to_by.rb
|
77
108
|
- set/right/links_to.rb
|
78
109
|
- set/right/mates.rb
|
@@ -82,6 +113,8 @@ files:
|
|
82
113
|
- set/right/refers_to.rb
|
83
114
|
- set/self/recent.rb
|
84
115
|
- set/self/search.rb
|
116
|
+
- set/self/search/results_for_keyword.haml
|
117
|
+
- set/self/search/search_box.haml
|
85
118
|
- set/type/cardtype.rb
|
86
119
|
- set/type/search_type.rb
|
87
120
|
homepage: https://decko.org
|
@@ -94,6 +127,7 @@ metadata:
|
|
94
127
|
wiki_uri: https://decko.org
|
95
128
|
documentation_url: http://docs.decko.org/
|
96
129
|
card-mod: search
|
130
|
+
card-mod-group: gem-defaults
|
97
131
|
post_install_message:
|
98
132
|
rdoc_options: []
|
99
133
|
require_paths:
|
@@ -109,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
143
|
- !ruby/object:Gem::Version
|
110
144
|
version: '0'
|
111
145
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
146
|
+
rubygems_version: 3.3.11
|
113
147
|
signing_key:
|
114
148
|
specification_version: 4
|
115
149
|
summary: search
|
data/lib/card/filter_query.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
class Card
|
2
|
-
# Class for generating CQL based on filter params
|
3
|
-
class FilterQuery
|
4
|
-
def initialize filter_keys_with_values, extra_cql={}
|
5
|
-
@filter_cql = Hash.new { |h, k| h[k] = [] }
|
6
|
-
@rules = yield if block_given?
|
7
|
-
@rules ||= {}
|
8
|
-
@filter_keys_with_values = filter_keys_with_values
|
9
|
-
@extra_cql = extra_cql
|
10
|
-
prepare_filter_cql
|
11
|
-
end
|
12
|
-
|
13
|
-
def add_to_cql key, value
|
14
|
-
@filter_cql[key] << value
|
15
|
-
end
|
16
|
-
|
17
|
-
def add_rule key, value
|
18
|
-
return unless value.present?
|
19
|
-
|
20
|
-
case @rules[key]
|
21
|
-
when Symbol
|
22
|
-
send("#{@rules[key]}_rule", key, value)
|
23
|
-
when Proc
|
24
|
-
@rules[key].call(key, value).each do |cql_key, val|
|
25
|
-
@filter_cql[cql_key] << val
|
26
|
-
end
|
27
|
-
else
|
28
|
-
send "#{key}_cql", value
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_cql
|
33
|
-
@cql = {}
|
34
|
-
@filter_cql.each do |cql_key, values|
|
35
|
-
next if values.empty?
|
36
|
-
|
37
|
-
case cql_key
|
38
|
-
when :right_plus, :left_plus, :type
|
39
|
-
merge_using_and cql_key, values
|
40
|
-
else
|
41
|
-
merge_using_array cql_key, values
|
42
|
-
end
|
43
|
-
end
|
44
|
-
@cql.merge @extra_cql
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def prepare_filter_cql
|
50
|
-
@filter_keys_with_values.each do |key, values|
|
51
|
-
add_rule key, values
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def merge_using_array cql_key, values
|
56
|
-
@cql[cql_key] = values.one? ? values.first : values
|
57
|
-
end
|
58
|
-
|
59
|
-
def merge_using_and cql_key, values
|
60
|
-
hash = build_nested_hash cql_key, values
|
61
|
-
@cql.deep_merge! hash
|
62
|
-
end
|
63
|
-
|
64
|
-
# nest values with the same key using :and
|
65
|
-
def build_nested_hash key, values
|
66
|
-
return { key => values[0] } if values.one?
|
67
|
-
|
68
|
-
val = values.pop
|
69
|
-
{ key => val, and: build_nested_hash(key, values) }
|
70
|
-
end
|
71
|
-
|
72
|
-
def name_cql name
|
73
|
-
return unless name.present?
|
74
|
-
|
75
|
-
@filter_cql[:name] = ["match", name]
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
format do
|
2
|
-
def filter_param field
|
3
|
-
filter_hash[field.to_sym]
|
4
|
-
end
|
5
|
-
|
6
|
-
def filter_hash
|
7
|
-
@filter_hash ||= filter_hash_from_params || default_filter_hash
|
8
|
-
end
|
9
|
-
|
10
|
-
def filter_hash_from_params
|
11
|
-
return unless Env.params[:filter].present?
|
12
|
-
|
13
|
-
Env.hash(Env.params[:filter]).deep_symbolize_keys
|
14
|
-
end
|
15
|
-
|
16
|
-
def sort_param
|
17
|
-
@sort_param ||= safe_sql_param :sort
|
18
|
-
end
|
19
|
-
|
20
|
-
def safe_sql_param key
|
21
|
-
param = Env.params[key]
|
22
|
-
param.blank? ? nil : Card::Query.safe_sql(param)
|
23
|
-
end
|
24
|
-
|
25
|
-
def filter_keys_with_values
|
26
|
-
filter_keys.map do |key|
|
27
|
-
values = filter_param(key)
|
28
|
-
values.present? ? [key, values] : next
|
29
|
-
end.compact
|
30
|
-
end
|
31
|
-
|
32
|
-
# initial values for filtered search
|
33
|
-
def default_filter_hash
|
34
|
-
{}
|
35
|
-
end
|
36
|
-
|
37
|
-
def extra_paging_path_args
|
38
|
-
super.merge filter_and_sort_hash
|
39
|
-
end
|
40
|
-
|
41
|
-
def filter_and_sort_hash
|
42
|
-
{ filter: filter_hash }.tap do |hash|
|
43
|
-
hash[:sort] = sort_param if sort_param
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
._filter-input.filter-input-group.input-group.input-group-sm{"data-category": key, "class": "_filter-input-#{key}" }
|
2
|
-
.input-group-prepend.filter-input-prepend
|
3
|
-
%button.btn.btn-secondary.input-group-text.p-1._delete-filter-input{:type => "button"}
|
4
|
-
%small.text-muted
|
5
|
-
= fa_icon :times
|
6
|
-
%span.input-group-text._selected-category.text-muted
|
7
|
-
= category[:label]
|
8
|
-
= category[:input_field]
|