Skip to content

Commit

Permalink
Show all problems in similar cards on models or files
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Jan 31, 2024
1 parent 1ea49d7 commit b96c8d7
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 53 deletions.
14 changes: 11 additions & 3 deletions app/views/model_files/_problem.html.erb
Original file line number Diff line number Diff line change
@@ -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? %>
<ul>
<% @duplicates.each do |file| %>
<li><%= link_to "#{file.model.name}/#{file.filename}", [file.model.library, file.model, file]%></li>
<% end %>
</ul>
<% end %>
<% end %>
19 changes: 1 addition & 18 deletions app/views/model_files/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<p>
<%= t('.duplicate_card.message') %>
</p>
<ul>
<% @duplicates.each do |file| %>
<li><%= link_to "#{file.model.name}/#{file.filename}", [file.model.library, file.model, file]%></li>
<% end %>
</ul>
<% 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"} %>
Expand Down
16 changes: 16 additions & 0 deletions app/views/models/_problem.html.erb
Original file line number Diff line number Diff line change
@@ -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? %>
<ul>
<% @model.contained_models.each do |target| %>
<li><%= link_to target.name, library_model_path(@library, target)%></li>
<% end %>
</ul>
<p>
<%= t("problems.model_nested.warning") %>
</p>
<%= link_to "Merge all", merge_library_model_path(@library, @model, all: true), class: "btn btn-danger", method: :post %>
<% end %>

<% end %>
17 changes: 1 addition & 16 deletions app/views/models/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,7 @@
<% end %>
<% end %>

<% if @model.contains_other_models? %>
<%= card :warning, "Contained Models" do %>
<p>
The model folder on disk contains other models. You may wish to merge them into this one, or move them out.
</p>
<ul>
<% @model.contained_models.each do |target| %>
<li><%= link_to target.name, library_model_path(@library, target)%></li>
<% end %>
</ul>
<p>
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!
</p>
<%= 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 %>
<p class="card-text"><%= sanitize @model.notes %></p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/problems/_model_file_missing.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<td><%= icon("file-x", t(".title")) %></td>
<td><%= link_to problem.problematic.name, [problem.problematic.model.library, problem.problematic.model, problem.problematic] %></td>
<td><%= t ".description" %></td>
<td><%= t ".title" %></td>
<td><%= link_to "Purge", [problem.problematic.model.library, problem.problematic.model, problem.problematic], method: :delete, class: "btn btn-danger" %></td>
2 changes: 1 addition & 1 deletion app/views/problems/_model_missing.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<td><%= icon("folder-x", t(".title")) %></td>
<td><%= link_to problem.problematic.name, [problem.problematic.library, problem.problematic] %></td>
<td><%= t ".description" %></td>
<td><%= t ".title" %></td>
<td><%= link_to "Purge", [problem.problematic.library, problem.problematic], method: :delete, class: "btn btn-danger" %></td>
2 changes: 1 addition & 1 deletion app/views/problems/_model_nesting.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<td><%= icon("files-alt", t(".title")) %></td>
<td><%= link_to problem.problematic.name, [problem.problematic.library, problem.problematic] %></td>
<td><%= t ".description" %></td>
<td><%= t ".title" %></td>
<td><%= link_to "Open", [problem.problematic.library, problem.problematic], class: "btn btn-primary" %></td>
22 changes: 9 additions & 13 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b96c8d7

Please sign in to comment.