Updated search page to consolidate results into one list
This commit is contained in:
parent
421539f38c
commit
5139d8b492
@ -2,6 +2,10 @@ class Item < Sequel::Model
|
||||
|
||||
one_to_many :item_comments
|
||||
|
||||
def getLink()
|
||||
return "/item/#{self.id}"
|
||||
end
|
||||
|
||||
def type_selected?(option)
|
||||
if self.type == option
|
||||
return 'selected'
|
||||
|
@ -2,4 +2,8 @@ class License < Sequel::Model
|
||||
|
||||
one_to_many :license_comments
|
||||
|
||||
def getLink()
|
||||
return "/license/#{self.id}"
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -4,10 +4,11 @@ namespace '/search' do
|
||||
items = Item.where(Sequel.ilike(:name, "%#{search_parameter}%")).all()
|
||||
licenses = License.where(Sequel.ilike(:name, "%#{search_parameter}%")).all()
|
||||
|
||||
results = items.concat(licenses)
|
||||
|
||||
erb :'search/list', :locals => {
|
||||
:title => 'Search Results',
|
||||
:items => items,
|
||||
:licenses => licenses,
|
||||
:results => results,
|
||||
:query => search_parameter
|
||||
}
|
||||
end
|
||||
|
@ -1,25 +1,14 @@
|
||||
<div class="row">
|
||||
<div class="twelve columns">
|
||||
<h4>Matching hardware:</h4>
|
||||
<% if items.length > 0 %>
|
||||
<h4>Matching inventory:</h4>
|
||||
<% if results.length > 0 %>
|
||||
<ul class="u-full-width">
|
||||
<% items.each do |r| %>
|
||||
<li><a href="/item/<%= r.id %>"><%= r.name %></a></li>
|
||||
<% results.each do |r| %>
|
||||
<li><a href="<%= r.getLink() %>"><%= r.name %></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<p>Sorry, nothing in your hardware inventory matches that search term.</p>
|
||||
<% end %>
|
||||
|
||||
<h4>Matching licenses:</h4>
|
||||
<% if licenses.length > 0 %>
|
||||
<ul class="u-full-width">
|
||||
<% licenses.each do |r| %>
|
||||
<li><a href="/item/<%= r.id %>"><%= r.name %></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<p>Sorry, nothing in your license inventory matches that search term.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user