Skip to content
This repository was archived by the owner on Jan 30, 2024. It is now read-only.

Commit 19c6a36

Browse files
committed
[*] Search - Fix the broken search if the collection contains Array fields
1 parent fbf42e5 commit 19c6a36

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Change Log
22

33
## [Unreleased]
4+
### Fixed
5+
- Search - Fix the broken search if the collection contains Array fields. [Regression introduced in 2.9.0]
6+
- Search - Highlight the records id if it matches with the search value.
47

58
## RELEASE 2.11.4 - 2018-07-31
69
### Fixed

app/helpers/forest_liana/decoration_helper.rb

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
module ForestLiana
22
module DecorationHelper
3+
def self.detect_match_and_decorate record, index, field_name, value, search_value, match_fields
4+
begin
5+
match = value.match(/#{search_value}/i)
6+
if match
7+
match_fields[index] = { id: record['id'], search: [] } if match_fields[index].nil?
8+
match_fields[index][:search] << field_name
9+
end
10+
rescue
11+
end
12+
end
13+
314
def self.decorate_for_search(records_serialized, field_names, search_value)
415
match_fields = {}
516
records_serialized['data'].each_with_index do |record, index|
617
field_names.each do |field_name|
718
value = record['attributes'][field_name]
819
if value
9-
match = value.match(/#{search_value}/i)
10-
if match
11-
match_fields[index] = { id: record['id'], search: [] } if match_fields[index].nil?
12-
match_fields[index][:search] << field_name
13-
end
20+
detect_match_and_decorate(record, index, field_name, value, search_value, match_fields)
1421
end
1522
end
23+
24+
detect_match_and_decorate(record, index, 'id', record['id'], search_value, match_fields)
1625
end
1726
match_fields.empty? ? nil : match_fields
1827
end

0 commit comments

Comments
 (0)