Added an inventory search page

This commit is contained in:
2022-12-11 22:27:45 -05:00
parent 4c9d46f875
commit 421539f38c
5 changed files with 44 additions and 3 deletions

View File

@ -11,10 +11,10 @@
</head>
<body>
<!-- Main navigation -->
<%= erb :'layout/navbar' %>
<%= erb :'layout/navbar', :locals => locals %>
<!-- Inventory search/actions bar -->
<%= erb :'layout/actions' %>
<%= erb :'layout/actions', :locals => locals %>
<div id="main-wrapper" class="container fluid card">
<%= yield %>

View File

@ -2,7 +2,7 @@
<div class="row">
<div class="six columns">
<form action="/search" class="u-full-width">
<input id="search-field" class="u-full-width" type="text" placeholder="Search your inventory..." name="Search field">
<input id="search-field" class="u-full-width" type="text" placeholder="Search your inventory..." name="query" required <%= defined?(query) ? 'value="' + query + '"' : '' %>>
</form>
</div>
</div>

25
views/search/list.erb Normal file
View File

@ -0,0 +1,25 @@
<div class="row">
<div class="twelve columns">
<h4>Matching hardware:</h4>
<% if items.length > 0 %>
<ul class="u-full-width">
<% items.each do |r| %>
<li><a href="/item/<%= r.id %>"><%= 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>