From 0fdd15460290da4dd276838f16ffd75567bce3b0 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 3 Mar 2021 00:29:26 +0000 Subject: [PATCH 01/25] set title tag to something helpful --- app/controllers/creators_controller.rb | 3 +++ app/controllers/libraries_controller.rb | 4 +++- app/controllers/models_controller.rb | 1 + app/controllers/parts_controller.rb | 1 + app/views/layouts/application.html.erb | 2 +- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/creators_controller.rb b/app/controllers/creators_controller.rb index ab113ff04..d0f405a78 100644 --- a/app/controllers/creators_controller.rb +++ b/app/controllers/creators_controller.rb @@ -3,6 +3,7 @@ class CreatorsController < ApplicationController def index @creators = Creator.all + @title = "Creators" end def show @@ -19,6 +20,7 @@ def update def new @creator = Creator.new + @title = "New Creator" end def create @@ -35,6 +37,7 @@ def destroy def get_creator @creator = Creator.find(params[:id]) + @title = @creator.name end def creator_params diff --git a/app/controllers/libraries_controller.rb b/app/controllers/libraries_controller.rb index 7808dbae8..bf5f36443 100644 --- a/app/controllers/libraries_controller.rb +++ b/app/controllers/libraries_controller.rb @@ -15,12 +15,13 @@ def show # Filter by tag? if params[:tag] @tag = ActsAsTaggableOn::Tag.find_by_name(params[:tag]) - @models = @models.tagged_with(@tag) if @tag + @models = @models.tagged_withc(@tag) if @tag end end def new @library = Library.new + @title = "New Library" end def create @@ -42,5 +43,6 @@ def library_params def get_library @library = Library.find(params[:id]) + @title = @library.name end end diff --git a/app/controllers/models_controller.rb b/app/controllers/models_controller.rb index fff0a93a5..274446adf 100644 --- a/app/controllers/models_controller.rb +++ b/app/controllers/models_controller.rb @@ -32,5 +32,6 @@ def get_library def get_model @model = @library.models.find(params[:id]) + @title = @model.name end end diff --git a/app/controllers/parts_controller.rb b/app/controllers/parts_controller.rb index 11ad2c20d..d5c5637db 100644 --- a/app/controllers/parts_controller.rb +++ b/app/controllers/parts_controller.rb @@ -36,5 +36,6 @@ def get_model def get_part @part = @model.parts.find(params[:id]) + @title = @part.name end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1c5c6b949..e6fe3ea9f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,7 +1,7 @@ - VanDAM + VanDAM<%= " : #{@title}" if @title %> <%= csrf_meta_tags %> <%= csp_meta_tag %> From bb6272f162ee4ffbb5f87fc415e4f750c2a4df11 Mon Sep 17 00:00:00 2001 From: James Smith Date: Thu, 4 Mar 2021 11:01:37 +0000 Subject: [PATCH 02/25] Move rescan button into actions block --- app/views/libraries/show.html.erb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/views/libraries/show.html.erb b/app/views/libraries/show.html.erb index 68c7cbfa2..685a5163d 100644 --- a/app/views/libraries/show.html.erb +++ b/app/views/libraries/show.html.erb @@ -1,4 +1,3 @@ -<%= link_to "Rescan", library_path(@library), method: :patch, class: 'float-end btn btn-warning' %>

<%= @library.name %>

@@ -21,5 +20,13 @@
+
+
Actions
+
+
+ <%= link_to "Rescan", library_path(@library), method: :patch, class: 'btn btn-warning' %> +
+
+
From f01e623cf7d34a463f908926226a9358c9df68de Mon Sep 17 00:00:00 2001 From: James Smith Date: Thu, 4 Mar 2021 11:02:10 +0000 Subject: [PATCH 03/25] reorganise part view --- app/views/parts/show.html.erb | 47 ++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/app/views/parts/show.html.erb b/app/views/parts/show.html.erb index 0e29d3187..fa77fa7a5 100644 --- a/app/views/parts/show.html.erb +++ b/app/views/parts/show.html.erb @@ -1,19 +1,36 @@ -
-
- -

<%= @part.name %>

-

- Filename: <%= @part.filename %> - <%= link_to "Download", library_model_part_path(@library, @model, @part, @part.file_format.to_sym), {class: "btn btn-secondary"} %> -

- <%= render 'form' %> -
-
+ +

<%= @part.name %>

+ +
+ +
+ +
+
+
Details
+
+
+

+ Filename: <%= @part.filename %> +

+ <%= render 'form' %> +
+
+
+
+
Actions
+
+
+ <%= link_to "Download", library_model_part_path(@library, @model, @part, @part.file_format.to_sym), {class: "btn btn-secondary"} %> +
+
+
+
From 3d600e7b04516084f793258f8e95eb316d929d7e Mon Sep 17 00:00:00 2001 From: James Smith Date: Thu, 4 Mar 2021 11:02:33 +0000 Subject: [PATCH 04/25] Create actions block for model details --- app/views/models/show.html.erb | 43 ++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/app/views/models/show.html.erb b/app/views/models/show.html.erb index 26478efce..6d24bad3b 100644 --- a/app/views/models/show.html.erb +++ b/app/views/models/show.html.erb @@ -29,31 +29,40 @@
-
-
Tags
-
-
- <% @model.tags.each do |tag| %> - <%=link_to tag.name, [@library, tag: tag.name], {class: "badge rounded-pill bg-secondary"} %> - <% end %> + <% unless @model.tags.empty? %> +
+
Tags
+
+
+ <% @model.tags.each do |tag| %> + <%=link_to tag.name, [@library, tag: tag.name], {class: "badge rounded-pill bg-secondary"} %> + <% end %> +
-
+ <% end %> + <% unless @model.links.empty? %> +
+
Links
+
+
+ +
+
+
+ <% end %>
-
Links
+
Actions
- + <%= link_to "Edit Details", edit_library_model_path(@library, @model), class: "btn btn-primary" %>
-
- <%= link_to "Edit Details", edit_library_model_path(@library, @model), class: "btn btn-primary" %> -
From 96762ad5b860ea4714d52106c5ae6be78f68847b Mon Sep 17 00:00:00 2001 From: James Smith Date: Thu, 4 Mar 2021 13:50:15 +0000 Subject: [PATCH 05/25] DRY sidebar card rendering --- app/helpers/application_helper.rb | 13 ++++++ app/views/creators/show.html.erb | 28 ++++++------ app/views/libraries/show.html.erb | 37 +++++++--------- app/views/models/show.html.erb | 74 ++++++++++++------------------- app/views/parts/show.html.erb | 30 +++++-------- 5 files changed, 82 insertions(+), 100 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1d0d9227e..92cdcae58 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2,4 +2,17 @@ module ApplicationHelper def icon(id, label) tag.i class: "bi bi-#{id}", role: "img", 'aria-label': label, title: label end + + def card(style, title, &content) + tag.div class: "card mb-4" do + [ + tag.div(title, class: "card-header text-white bg-#{style}"), + tag.div(class: "card-body") do + tag.div class: "card-text" do + content.call + end + end + ].join.html_safe + end + end end diff --git a/app/views/creators/show.html.erb b/app/views/creators/show.html.erb index 631cc1dce..f135d6b5a 100644 --- a/app/views/creators/show.html.erb +++ b/app/views/creators/show.html.erb @@ -2,25 +2,25 @@
+
<%= render partial: 'model', collection: @models %>
+
-
-
Links
-
-
- -
-
-
-
+ + <%= card(:secondary, 'Links') do %> + + <% end %> + + <%= card(:secondary, 'Actions') do %> <%= link_to "Edit Details", edit_creator_path(@creator), class: "btn btn-primary" %> -
+ <% end %> +
diff --git a/app/views/libraries/show.html.erb b/app/views/libraries/show.html.erb index 685a5163d..dbbb71eaa 100644 --- a/app/views/libraries/show.html.erb +++ b/app/views/libraries/show.html.erb @@ -6,27 +6,20 @@
-
-
Tags
-
-
- <% @tags.each do |tag| %> - <% if (tag == @tag) %> - <%=link_to tag.name, @library, {class: "badge rounded-pill bg-success"} %> - <% else %> - <%=link_to tag.name, [@library, tag: tag.name], {class: "badge rounded-pill bg-secondary"} %> - <% end %> - <% end %> -
-
-
-
-
Actions
-
-
- <%= link_to "Rescan", library_path(@library), method: :patch, class: 'btn btn-warning' %> -
-
-
+ + <%= card :secondary, "Tags" do %> + <% @tags.each do |tag| %> + <% if (tag == @tag) %> + <%=link_to tag.name, @library, {class: "badge rounded-pill bg-success"} %> + <% else %> + <%=link_to tag.name, [@library, tag: tag.name], {class: "badge rounded-pill bg-secondary"} %> + <% end %> + <% end %> + <% end %> + + <%= card :secondary, "Actions" do %> + <%= link_to "Rescan", library_path(@library), method: :patch, class: 'btn btn-warning' %> + <% end %> +
diff --git a/app/views/models/show.html.erb b/app/views/models/show.html.erb index 6d24bad3b..595c2045b 100644 --- a/app/views/models/show.html.erb +++ b/app/views/models/show.html.erb @@ -14,55 +14,39 @@
-
-
Details
-
-
- <% if @model.creator %> -

- Creator: <%= link_to @model.creator.name, creator_path(@model.creator) %> -

- <% end %> -

- Path: <%= @model.path %> -

-
-
-
+ + <%= card :secondary, "Details" do %> + <% if @model.creator %> +

+ Creator: <%= link_to @model.creator.name, creator_path(@model.creator) %> +

+ <% end %> +

+ Path: <%= @model.path %> +

+ <% end %> + <% unless @model.tags.empty? %> -
-
Tags
-
-
- <% @model.tags.each do |tag| %> - <%=link_to tag.name, [@library, tag: tag.name], {class: "badge rounded-pill bg-secondary"} %> - <% end %> -
-
-
+ <%= card :secondary, "Tags" do %> + <% @model.tags.each do |tag| %> + <%=link_to tag.name, [@library, tag: tag.name], {class: "badge rounded-pill bg-secondary"} %> + <% end %> + <% end %> <% end %> + <% unless @model.links.empty? %> -
-
Links
-
-
- -
-
-
+ <%= card :secondary, "Links" do %> + + <% end %> + <% end %> + + <%= card :secondary, "Actions" do %> + <%= link_to "Edit Details", edit_library_model_path(@library, @model), class: "btn btn-primary" %> <% end %> -
-
Actions
-
-
- <%= link_to "Edit Details", edit_library_model_path(@library, @model), class: "btn btn-primary" %> -
-
-
diff --git a/app/views/parts/show.html.erb b/app/views/parts/show.html.erb index fa77fa7a5..6764694ea 100644 --- a/app/views/parts/show.html.erb +++ b/app/views/parts/show.html.erb @@ -13,24 +13,16 @@
-
-
Details
-
-
-

- Filename: <%= @part.filename %> -

- <%= render 'form' %> -
-
-
-
-
Actions
-
-
- <%= link_to "Download", library_model_part_path(@library, @model, @part, @part.file_format.to_sym), {class: "btn btn-secondary"} %> -
-
-
+ <%= card :secondary, "Details" do %> +

+ Filename: <%= @part.filename %> +

+ <%= render 'form' %> + <% end %> + + <%= card :secondary, "Actions" do %> + <%= link_to "Download", library_model_part_path(@library, @model, @part, @part.file_format.to_sym), {class: "btn btn-secondary"} %> + <% end %> +
From 3ecd80db6fb00af9653131940cf8c838dadafbf5 Mon Sep 17 00:00:00 2001 From: James Smith Date: Thu, 4 Mar 2021 21:35:44 +0000 Subject: [PATCH 06/25] add footer padding --- app/views/layouts/application.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e6fe3ea9f..170ff7aa8 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -27,7 +27,7 @@ <%= yield %> -