From 400a03df5eaef99209ebb0e2b66f94b442144c68 Mon Sep 17 00:00:00 2001 From: James Smith Date: Fri, 12 Feb 2021 16:31:54 +0000 Subject: [PATCH] display tags at the side of libraries and add simple filtering --- app/controllers/libraries_controller.rb | 2 ++ app/views/libraries/show.html.erb | 28 +++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/controllers/libraries_controller.rb b/app/controllers/libraries_controller.rb index 9519ee3c9..b3475107b 100644 --- a/app/controllers/libraries_controller.rb +++ b/app/controllers/libraries_controller.rb @@ -9,6 +9,8 @@ class LibrariesController < ApplicationController def show @library = Library.find(params[:id]) + @models = @library.models + @models = @models.tagged_with(params[:tag]) if params[:tag] end def new diff --git a/app/views/libraries/show.html.erb b/app/views/libraries/show.html.erb index 63c84a333..aa4802a7c 100644 --- a/app/views/libraries/show.html.erb +++ b/app/views/libraries/show.html.erb @@ -1,14 +1,24 @@ <%= link_to "Rescan", library_path(@library), method: :patch, class: 'float-end btn btn-warning' %>

<%= @library.name %>

-
- <% @library.models.each do |model| %> -
-
-
-
<%= model.name %>
- <%= link_to "Open", [@library, model], {class: "btn btn-primary"} %> +
+
+
+ <% @models.each do |model| %> +
+
+
+
<%= model.name %>
+ <%= link_to "Open", [@library, model], {class: "btn btn-primary"} %> +
+
-
+ <% end %>
- <% end %> +
+
+
Tags
+ <% ActsAsTaggableOn::Tag.all.each do |tag| %> + <%=link_to tag.name, [@library, tag: tag.name], {class: "badge rounded-pill bg-info text-dark"} %> + <% end %> +