mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-10 08:21:37 +08:00
Merge pull request #2278 from urbanrotnik/ur-sci-4161-global-search-for-new-column-types
Add search for statuses, numbers [SCI-4161]
This commit is contained in:
commit
cedaaa7ee2
4 changed files with 8 additions and 4 deletions
|
|
@ -44,7 +44,7 @@ module SearchableModel
|
|||
"CAST(#{a} AS TEXT) #{like} :t#{i} OR "
|
||||
else
|
||||
col = options[:at_search].to_s == 'true' ? "lower(#{a})": a
|
||||
"(trim_html_tags(#{col})) #{like} :t#{i} OR "
|
||||
"(trim_html_tags((#{col})::text)) #{like} :t#{i} OR "
|
||||
end
|
||||
end
|
||||
).join[0..-5]
|
||||
|
|
@ -86,7 +86,7 @@ module SearchableModel
|
|||
if a == 'repository_rows.id'
|
||||
"CAST(#{a} AS TEXT) #{like} :t#{i} OR "
|
||||
else
|
||||
"(trim_html_tags(#{a})) #{like} :t#{i} OR "
|
||||
"(trim_html_tags((#{a})::text)) #{like} :t#{i} OR "
|
||||
end
|
||||
end
|
||||
).join[0..-5]
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class RepositoryNumberValue < ApplicationRecord
|
|||
SORTABLE_VALUE_INCLUDE = :repository_number_value
|
||||
|
||||
def formatted
|
||||
data
|
||||
data.to_s
|
||||
end
|
||||
|
||||
def data_changed?(new_data)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<% repository_row.repository_cells.each do |cell| %>
|
||||
<span>
|
||||
<%=t "search.index.repositories.custom_column", column: cell.repository_column.name %>
|
||||
<%= highlight cell.value.data, search_query.strip.split(/\s+/) %>
|
||||
<%= highlight cell.value.formatted, search_query.strip.split(/\s+/) %>
|
||||
</span>
|
||||
<br>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -62,14 +62,18 @@ class Extends
|
|||
# Extra attributes used for search in repositories, text columns
|
||||
# are only supported
|
||||
REPOSITORY_EXTRA_SEARCH_ATTR = ['repository_text_values.data',
|
||||
'repository_number_values.data',
|
||||
'repository_list_items.data',
|
||||
'repository_checklist_items.data',
|
||||
'repository_status_items.status',
|
||||
'active_storage_blobs.filename']
|
||||
|
||||
# Array of includes used in search query for repository rows
|
||||
REPOSITORY_SEARCH_INCLUDES = [:repository_text_value,
|
||||
:repository_number_value,
|
||||
repository_list_value: :repository_list_item,
|
||||
repository_checklist_value: :repository_checklist_items,
|
||||
repository_status_value: :repository_status_item,
|
||||
repository_asset_value: { asset: { file_attachment: :blob } }]
|
||||
|
||||
# List of implemented core API versions
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue