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
@@ -1,56 +0,0 @@
|
|
1
|
-
|
2
|
-
.card.w-100.nodblclick
|
3
|
-
.card-body
|
4
|
-
._filter-widget
|
5
|
-
// FILTERING PROTOTYPES
|
6
|
-
._filter-input-field-prototypes.d-none
|
7
|
-
- categories.each do |key, category|
|
8
|
-
= haml_partial :filter_input, key: key, category: category
|
9
|
-
|
10
|
-
|
11
|
-
// FORM
|
12
|
-
%form._filter-form{form_args, "accept-charset": "UTF-8",
|
13
|
-
"data-remote": "true",
|
14
|
-
method: "get"}
|
15
|
-
- not_ids = params.dig :filter, :not_ids
|
16
|
-
%input{ type: :hidden,
|
17
|
-
name: "filter[not_ids]",
|
18
|
-
class: "_not-ids",
|
19
|
-
value: not_ids }
|
20
|
-
= render_quick_filters
|
21
|
-
.filter-and-sort.d-flex.flex-wrap
|
22
|
-
- if sort_input_field.present?
|
23
|
-
// SORTING
|
24
|
-
.sort-in-filter-form
|
25
|
-
%i.fa.fa-sort.filter-section-icon
|
26
|
-
.input-group.input-group-sm.flex-nowrap.sort-input-group.mb-2.mr-2
|
27
|
-
.input-group-prepend
|
28
|
-
%span.input-group-text.text-muted Sort
|
29
|
-
= sort_input_field
|
30
|
-
|
31
|
-
// FILTERING
|
32
|
-
.filter-in-filter-form
|
33
|
-
%i.fa.fa-filter.filter-section-icon
|
34
|
-
._filter-container.d-flex.flew-row.flex-wrap
|
35
|
-
// FILTERS inserted here
|
36
|
-
|
37
|
-
// ADD FILTER DROPDOWN
|
38
|
-
.dropdown._add-filter-dropdown.mr-2
|
39
|
-
%button.btn.btn-sm.btn-primary.dropdown-toggle{"aria-expanded": "false",
|
40
|
-
"aria-haspopup": "true",
|
41
|
-
"data-toggle": "dropdown",
|
42
|
-
type: "button" }
|
43
|
-
More Filters
|
44
|
-
.dropdown-menu
|
45
|
-
- categories.each do |key, category|
|
46
|
-
%a{ class: "dropdown-item _filter-category-select",
|
47
|
-
href: "#",
|
48
|
-
"data-category": key,
|
49
|
-
"data-label": category[:label],
|
50
|
-
"data-active": ("true" if category[:active])}
|
51
|
-
= category[:label]
|
52
|
-
|
53
|
-
// RESET BUTTON
|
54
|
-
._reset-filter{ "data-reset": reset_filter_data }
|
55
|
-
%button.btn.btn-sm.btn-secondary{ type: "button" }
|
56
|
-
%i.fa.fa-sync-alt
|
@@ -1,101 +0,0 @@
|
|
1
|
-
format :html do
|
2
|
-
# sort and filter ui
|
3
|
-
view :filter_form, cache: :never do
|
4
|
-
filter_fields slot_selector: "._filter-result-slot",
|
5
|
-
sort_field: _render(:sort_formgroup)
|
6
|
-
end
|
7
|
-
|
8
|
-
view :quick_filters, cache: :never do
|
9
|
-
return "" unless quick_filter_list.present?
|
10
|
-
|
11
|
-
haml :quick_filters, filter_list: normalized_quick_filter_list
|
12
|
-
end
|
13
|
-
|
14
|
-
def normalized_quick_filter_list
|
15
|
-
quick_filter_list.map do |hash|
|
16
|
-
quick_filter_item hash.clone, hash.keys.first
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def reset_filter_data
|
21
|
-
JSON default_filter_hash
|
22
|
-
end
|
23
|
-
|
24
|
-
def quick_filter_item hash, filter_key
|
25
|
-
{
|
26
|
-
text: (hash.delete(:text) || hash[filter_key]),
|
27
|
-
class: css_classes(hash.delete(:class),
|
28
|
-
"_filter-link quick-filter-by-#{filter_key}"),
|
29
|
-
filter: JSON(hash[:filter] || hash)
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
# for override
|
34
|
-
def quick_filter_list
|
35
|
-
[]
|
36
|
-
end
|
37
|
-
|
38
|
-
# for override
|
39
|
-
def custom_quick_filters
|
40
|
-
""
|
41
|
-
end
|
42
|
-
|
43
|
-
# @param data [Hash] the filter categories. The hash needs for every category
|
44
|
-
# a hash with a label and a input_field entry.
|
45
|
-
def filter_form data={}, sort_input_field=nil, form_args={}
|
46
|
-
haml :filter_form, categories: data,
|
47
|
-
sort_input_field: sort_input_field,
|
48
|
-
form_args: form_args
|
49
|
-
end
|
50
|
-
|
51
|
-
def filter_fields slot_selector: nil, sort_field: nil
|
52
|
-
form_args = { action: filter_action_path, class: "slotter" }
|
53
|
-
form_args["data-slot-selector"] = slot_selector if slot_selector
|
54
|
-
filter_form filter_form_data, sort_field, form_args
|
55
|
-
end
|
56
|
-
|
57
|
-
def filter_form_data
|
58
|
-
all_filter_keys.each_with_object({}) do |cat, h|
|
59
|
-
h[cat] = { label: filter_label(cat),
|
60
|
-
input_field: _render("filter_#{cat}_formgroup"),
|
61
|
-
active: active_filter?(cat) }
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def active_filter? field
|
66
|
-
if filter_keys_from_params.present?
|
67
|
-
filter_hash.key? field
|
68
|
-
else
|
69
|
-
default_filter? field
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def default_filter? field
|
74
|
-
default_filter_hash.key? field
|
75
|
-
end
|
76
|
-
|
77
|
-
def filter_label field
|
78
|
-
# return "Keyword" if field.to_sym == :name
|
79
|
-
#
|
80
|
-
filter_label_from_method(field) || filter_label_from_name(field)
|
81
|
-
end
|
82
|
-
|
83
|
-
def filter_label_from_method field
|
84
|
-
try "#{field}_filter_label"
|
85
|
-
end
|
86
|
-
|
87
|
-
def filter_label_from_name field
|
88
|
-
Card.fetch_name(field) { field.to_s.sub(/^\*/, "").titleize }
|
89
|
-
end
|
90
|
-
|
91
|
-
def filter_action_path
|
92
|
-
path
|
93
|
-
end
|
94
|
-
|
95
|
-
view :sort_formgroup, cache: :never do
|
96
|
-
select_tag "sort",
|
97
|
-
options_for_select(sort_options, current_sort),
|
98
|
-
class: "pointer-select _filter-sort form-control",
|
99
|
-
"data-minimum-results-for-search": "Infinity"
|
100
|
-
end
|
101
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
include_set Abstract::FilterHelper
|
2
|
-
|
3
|
-
format :html do
|
4
|
-
view :filter_name_formgroup, cache: :never do
|
5
|
-
text_filter :name
|
6
|
-
end
|
7
|
-
|
8
|
-
def select_filter field, default=nil, options=nil
|
9
|
-
options ||= filter_options field
|
10
|
-
options = [["--", ""]] + options unless default
|
11
|
-
select_filter_tag field, default, options
|
12
|
-
end
|
13
|
-
|
14
|
-
def multiselect_filter field, default=nil, options=nil
|
15
|
-
options ||= filter_options field
|
16
|
-
multiselect_filter_tag field, default, options
|
17
|
-
end
|
18
|
-
|
19
|
-
def text_filter field, default=nil, opts={}
|
20
|
-
value = filter_param(field) || default
|
21
|
-
text_filter_with_name_and_value filter_name(field), value, opts
|
22
|
-
end
|
23
|
-
|
24
|
-
def text_filter_with_name_and_value name, value, opts
|
25
|
-
opts[:class] ||= "simple-text"
|
26
|
-
add_class opts, "form-control"
|
27
|
-
text_field_tag name, value, opts
|
28
|
-
end
|
29
|
-
|
30
|
-
def range_filter field, default={}, opts={}
|
31
|
-
add_class opts, "simple-text range-filter-subfield"
|
32
|
-
default ||= {}
|
33
|
-
output [range_sign(:from),
|
34
|
-
sub_text_filter(field, :from, default, opts),
|
35
|
-
range_sign(:to),
|
36
|
-
sub_text_filter(field, :to, default, opts)]
|
37
|
-
end
|
38
|
-
|
39
|
-
def range_sign side
|
40
|
-
dir = side == :from ? "right" : "left"
|
41
|
-
wrap_with :span, class: "input-group-prepend" do
|
42
|
-
fa_icon("chevron-circle-#{dir}", class: "input-group-text")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def sub_text_filter field, subfield, default={}, opts={}
|
47
|
-
name = "filter[#{field}][#{subfield}]"
|
48
|
-
value = filter_hash.dig(field, subfield) || default[subfield]
|
49
|
-
text_filter_with_name_and_value name, value, opts
|
50
|
-
end
|
51
|
-
|
52
|
-
def autocomplete_filter type_code, options_card=nil
|
53
|
-
options_card ||= Card::Name[type_code, :type, :by_name]
|
54
|
-
text_filter type_code, "", class: "#{type_code}_autocomplete",
|
55
|
-
"data-options-card": options_card
|
56
|
-
end
|
57
|
-
|
58
|
-
def multiselect_filter_tag field, default, options, html_options={}
|
59
|
-
html_options[:multiple] = true
|
60
|
-
select_filter_tag field, default, options, html_options
|
61
|
-
end
|
62
|
-
|
63
|
-
def select_filter_tag field, default, options, html_options={}
|
64
|
-
name = filter_name field, html_options[:multiple]
|
65
|
-
options = options_for_select options, (filter_param(field) || default)
|
66
|
-
normalize_select_filter_tag_html_options field, html_options
|
67
|
-
select_tag name, options, html_options
|
68
|
-
end
|
69
|
-
|
70
|
-
# alters html_options hash
|
71
|
-
def normalize_select_filter_tag_html_options field, html_options
|
72
|
-
pointer_suffix = html_options[:multiple] ? "multiselect" : "select"
|
73
|
-
add_class html_options, "pointer-#{pointer_suffix} filter-input #{field} " \
|
74
|
-
"_filter_input_field _no-select2 form-control"
|
75
|
-
# _no-select2 because select is initiated after filter is opened.
|
76
|
-
html_options[:id] = "filter-input-#{unique_id}"
|
77
|
-
end
|
78
|
-
|
79
|
-
def filter_name field, multi=false
|
80
|
-
"filter[#{field}]#{'[]' if multi}"
|
81
|
-
end
|
82
|
-
|
83
|
-
def filter_options field
|
84
|
-
raw = send("#{field}_options")
|
85
|
-
raw.is_a?(Array) ? raw : option_hash_to_array(raw)
|
86
|
-
end
|
87
|
-
|
88
|
-
def option_hash_to_array hash
|
89
|
-
hash.each_with_object([]) do |(key, value), array|
|
90
|
-
array << [key, value.to_s]
|
91
|
-
array
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def type_options type_codename, order="asc", max_length=nil
|
96
|
-
Card.cache.fetch "#{type_codename}-TYPE-OPTIONS" do
|
97
|
-
res = Card.search type: type_codename, return: :name, sort: "name", dir: order
|
98
|
-
max_length ? (res.map { |i| [trim_option(i, max_length), i] }) : res
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def trim_option option, max_length
|
103
|
-
option.size > max_length ? "#{option[0..max_length]}..." : option
|
104
|
-
end
|
105
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
format do
|
2
|
-
# all filter keys in the order they were selected
|
3
|
-
def all_filter_keys
|
4
|
-
@all_filter_keys ||= filter_keys_from_params | filter_keys
|
5
|
-
end
|
6
|
-
|
7
|
-
def filter_and_sort_cql
|
8
|
-
filter_cql.merge sort_cql
|
9
|
-
end
|
10
|
-
|
11
|
-
def filter_cql
|
12
|
-
return {} if filter_hash.empty?
|
13
|
-
|
14
|
-
filter_cql_from_params
|
15
|
-
end
|
16
|
-
|
17
|
-
# separate method is needed for tests
|
18
|
-
def filter_cql_from_params
|
19
|
-
filter_class.new(filter_keys_with_values, blocked_id_cql).to_cql
|
20
|
-
end
|
21
|
-
|
22
|
-
def sort_cql
|
23
|
-
{ sort: current_sort }
|
24
|
-
end
|
25
|
-
|
26
|
-
def blocked_id_cql
|
27
|
-
not_ids = filter_param :not_ids
|
28
|
-
not_ids.present? ? { id: ["not in", not_ids.split(",")] } : {}
|
29
|
-
end
|
30
|
-
|
31
|
-
def current_sort
|
32
|
-
sort_param || default_sort_option
|
33
|
-
end
|
34
|
-
|
35
|
-
def default_sort_option
|
36
|
-
card.cql_content[:sort]
|
37
|
-
end
|
38
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
.quick-filter._quick-filter
|
2
|
-
%i.fa.fa-bolt.filter-section-icon
|
3
|
-
.quick-filter-links.d-flex.flex-wrap
|
4
|
-
- filter_list.each do |f|
|
5
|
-
%a{ "data-filter": f[:filter],
|
6
|
-
href: "#",
|
7
|
-
class: f[:class],
|
8
|
-
title: "Quick Filter: #{f[:text]}" }
|
9
|
-
= f[:icon]
|
10
|
-
= f[:text]
|
11
|
-
= custom_quick_filters
|
data/set/abstract/03_filter.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# include_set Abstract::Utility
|
2
|
-
|
3
|
-
format do
|
4
|
-
def filter_class
|
5
|
-
Card::FilterQuery
|
6
|
-
end
|
7
|
-
|
8
|
-
def filter_keys
|
9
|
-
[:name]
|
10
|
-
end
|
11
|
-
|
12
|
-
def filter_keys_from_params
|
13
|
-
filter_hash.keys.map(&:to_sym) - [:not_ids]
|
14
|
-
end
|
15
|
-
|
16
|
-
def sort_options
|
17
|
-
{ "Alphabetical": :name, "Recently Added": :create }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
format :html do
|
22
|
-
view :filtered_content, template: :haml, wrap: :slot
|
23
|
-
|
24
|
-
view :filtered_results do
|
25
|
-
class_up "card-slot", "_filter-result-slot"
|
26
|
-
wrap { render_core }
|
27
|
-
end
|
28
|
-
|
29
|
-
view :selectable_filtered_content, template: :haml, cache: :never
|
30
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
.filter-header.card-header
|
2
|
-
%h5
|
3
|
-
Select Item
|
4
|
-
-#.badge.badge-secondary
|
5
|
-
-# = card.count
|
6
|
-
.filter-selector.p-2
|
7
|
-
- if card.count > 0
|
8
|
-
.filter-bulk-selector.pb-3
|
9
|
-
%input#select-all._select-all{name: "", type: "checkbox", value: ""}
|
10
|
-
%label{for: "select-all"}
|
11
|
-
select
|
12
|
-
%span._unselected-items
|
13
|
-
= search_with_params.size
|
14
|
-
following
|
15
|
-
= render :checkbox_list
|
data/set/abstract/filter_list.rb
DELETED
data/set/abstract/filterable.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
format :html do
|
2
|
-
def filterable filter_hash={}, html_opts={}
|
3
|
-
add_class html_opts, "_filterable _noFilterUrlUpdates"
|
4
|
-
html_opts[:data] ||= {}
|
5
|
-
html_opts[:data][:filter] = filter_hash
|
6
|
-
wrap_with :div, yield, html_opts
|
7
|
-
end
|
8
|
-
|
9
|
-
def filtering selector=nil
|
10
|
-
selector ||= "._filter-widget:visible"
|
11
|
-
wrap_with :div, yield, class: "_filtering", "data-filter-selector": selector
|
12
|
-
end
|
13
|
-
end
|
data/set/right/follow.rb
DELETED