From b96c8d794d9d63a710de8ae151f443a9489da985 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 31 Jan 2024 13:11:55 +0000 Subject: [PATCH] Show all problems in similar cards on models or files --- app/views/model_files/_problem.html.erb | 14 +++++++++--- app/views/model_files/show.html.erb | 19 +--------------- app/views/models/_problem.html.erb | 16 ++++++++++++++ app/views/models/show.html.erb | 17 +------------- .../problems/_model_file_missing.html.erb | 2 +- app/views/problems/_model_missing.html.erb | 2 +- app/views/problems/_model_nesting.html.erb | 2 +- config/locales/en.yml | 22 ++++++++----------- 8 files changed, 41 insertions(+), 53 deletions(-) create mode 100644 app/views/models/_problem.html.erb diff --git a/app/views/model_files/_problem.html.erb b/app/views/model_files/_problem.html.erb index e2f3aee8e..8b9f01d5c 100644 --- a/app/views/model_files/_problem.html.erb +++ b/app/views/model_files/_problem.html.erb @@ -1,3 +1,11 @@ -<%= t("problems.model_file_#{problem.category}.title") %> -<%= t("problems.model_file_#{problem.category}.description") %> -<%= problem.note %> +<%= card(problem_severity(problem), t("problems.model_file_#{problem.category}.title")) do %> + <%= t("problems.model_file_#{problem.category}.description", note: problem.note ) %> + + <% unless @duplicates.empty? %> + + <% end %> +<% end %> diff --git a/app/views/model_files/show.html.erb b/app/views/model_files/show.html.erb index 755e523f4..591fac15a 100644 --- a/app/views/model_files/show.html.erb +++ b/app/views/model_files/show.html.erb @@ -29,24 +29,7 @@ <%= render 'form' %> <% end %> - <% if @file.problems.any? %> - <%= card(:secondary, 'Problems') do %> - <% render partial: "problem", collection: @file.problems %> - <% end %> - <% end %> - - <% unless @duplicates.empty? %> - <%= card :warning, t('.duplicate_card.title') do %> -

- <%= t('.duplicate_card.message') %> -

- - <% end %> - <% end %> + <%= render partial: "problem", collection: @file.problems %> <%= card :secondary, "Actions" do %> <%= link_to "#{icon('cloud-download', 'Download')} Download".html_safe, library_model_model_file_path(@library, @model, @file, @file.extension.to_sym), {class: "btn btn-secondary"} %> diff --git a/app/views/models/_problem.html.erb b/app/views/models/_problem.html.erb new file mode 100644 index 000000000..02b306886 --- /dev/null +++ b/app/views/models/_problem.html.erb @@ -0,0 +1,16 @@ +<%= card(problem_severity(problem), t("problems.model_#{problem.category}.title")) do %> + <%= t("problems.model_#{problem.category}.description", note: problem.note ) %> + + <% if @model.contains_other_models? %> + +

+ <%= t("problems.model_nested.warning") %> +

+ <%= link_to "Merge all", merge_library_model_path(@library, @model, all: true), class: "btn btn-danger", method: :post %> + <% end %> + +<% end %> diff --git a/app/views/models/show.html.erb b/app/views/models/show.html.erb index 5cfd5962e..da0ebf451 100644 --- a/app/views/models/show.html.erb +++ b/app/views/models/show.html.erb @@ -84,22 +84,7 @@ <% end %> <% end %> - <% if @model.contains_other_models? %> - <%= card :warning, "Contained Models" do %> -

- The model folder on disk contains other models. You may wish to merge them into this one, or move them out. -

- -

- Bulk merging moves all files from the models above into this one, and removes them. File metadata is preserved, but any model metadata will be lost! -

- <%= link_to "Merge all", merge_library_model_path(@library, @model, all: true), class: "btn btn-danger", method: :post %> - <% end %> - <% end %> + <%= render partial: "problem", collection: @model.problems %> <%= card(:secondary, 'Notes') do %>

<%= sanitize @model.notes %>

diff --git a/app/views/problems/_model_file_missing.html.erb b/app/views/problems/_model_file_missing.html.erb index d3f35b8aa..847dd116d 100644 --- a/app/views/problems/_model_file_missing.html.erb +++ b/app/views/problems/_model_file_missing.html.erb @@ -1,4 +1,4 @@ <%= icon("file-x", t(".title")) %> <%= link_to problem.problematic.name, [problem.problematic.model.library, problem.problematic.model, problem.problematic] %> -<%= t ".description" %> +<%= t ".title" %> <%= link_to "Purge", [problem.problematic.model.library, problem.problematic.model, problem.problematic], method: :delete, class: "btn btn-danger" %> diff --git a/app/views/problems/_model_missing.html.erb b/app/views/problems/_model_missing.html.erb index 557977b74..2f83b5b81 100644 --- a/app/views/problems/_model_missing.html.erb +++ b/app/views/problems/_model_missing.html.erb @@ -1,4 +1,4 @@ <%= icon("folder-x", t(".title")) %> <%= link_to problem.problematic.name, [problem.problematic.library, problem.problematic] %> -<%= t ".description" %> +<%= t ".title" %> <%= link_to "Purge", [problem.problematic.library, problem.problematic], method: :delete, class: "btn btn-danger" %> diff --git a/app/views/problems/_model_nesting.html.erb b/app/views/problems/_model_nesting.html.erb index 3e7ffae95..210e34ddb 100644 --- a/app/views/problems/_model_nesting.html.erb +++ b/app/views/problems/_model_nesting.html.erb @@ -1,4 +1,4 @@ <%= icon("files-alt", t(".title")) %> <%= link_to problem.problematic.name, [problem.problematic.library, problem.problematic] %> -<%= t ".description" %> +<%= t ".title" %> <%= link_to "Open", [problem.problematic.library, problem.problematic], class: "btn btn-primary" %> diff --git a/config/locales/en.yml b/config/locales/en.yml index deda1d0e2..4d2ede8e6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -55,11 +55,6 @@ en: CC0-10: Creative Commons Zero LicenseRef-Commercial: Commercial; private use only MIT: MIT - model_files: - show: - duplicate_card: - message: This file is duplicated in other models. You may wish to remove some. - title: Duplicated files problems: categories: duplicate: Duplicate files @@ -68,26 +63,27 @@ en: missing: Missing files or folders nesting: Model contains other models library_missing: - description: Library folder not found + description: Library folder not found on disk; better go look for it! title: Folder not found model_empty: - description: Model has no files + description: This model contains no files. Either delete it, or find where its files went! title: No files model_file_duplicate: - description: Duplicated file + description: This file is duplicated in other models. You may wish to remove some. title: Duplicated file model_file_inefficient: - description: Inefficient file format - title: Inefficient file format + description: This file is in %{note}, an inefficient file format. Consider converting it to a binary format such as 3MF to save disk space. + title: Inefficient format model_file_missing: - description: File not found + description: This file is missing on disk; either delete it, or find where it went! title: File not found model_missing: - description: Model folder not found + description: The folder for this model is missing on disk; either delete it, or find where it went! title: Folder not found model_nesting: - description: Model contains other models + description: The model folder on disk contains other models. You may wish to merge them into this one, or move them out. title: Contains other models + warning: Bulk merging moves all files from the models above into this one, and removes them. File metadata is preserved, but any model metadata will be lost! severities: danger: Danger info: Info