diff --git a/lib/models/item.rb b/lib/models/item.rb index 36f4450..04c217f 100644 --- a/lib/models/item.rb +++ b/lib/models/item.rb @@ -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' diff --git a/lib/models/license.rb b/lib/models/license.rb index 5f959fa..df75542 100644 --- a/lib/models/license.rb +++ b/lib/models/license.rb @@ -2,4 +2,8 @@ class License < Sequel::Model one_to_many :license_comments + def getLink() + return "/license/#{self.id}" + end + end diff --git a/lib/routes/search.rb b/lib/routes/search.rb index 9741866..141699e 100644 --- a/lib/routes/search.rb +++ b/lib/routes/search.rb @@ -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 diff --git a/views/search/list.erb b/views/search/list.erb index 0a855c1..ca34ac5 100644 --- a/views/search/list.erb +++ b/views/search/list.erb @@ -1,25 +1,14 @@
-

Matching hardware:

- <% if items.length > 0 %> +

Matching inventory:

+ <% if results.length > 0 %> <% else %>

Sorry, nothing in your hardware inventory matches that search term.

<% end %> - -

Matching licenses:

- <% if licenses.length > 0 %> - - <% else %> -

Sorry, nothing in your license inventory matches that search term.

- <% end %>