diff --git a/app/javascript/controllers/projects/samples/multiple_delete_listing_controller.js b/app/javascript/controllers/projects/samples/multiple_delete_listing_controller.js index 723bd97603..3d8f481619 100644 --- a/app/javascript/controllers/projects/samples/multiple_delete_listing_controller.js +++ b/app/javascript/controllers/projects/samples/multiple_delete_listing_controller.js @@ -2,9 +2,23 @@ import { Controller } from "@hotwired/stimulus"; // creates a table listing all selected metadata for deletion export default class extends Controller { - static targets = ["tableBody"]; + static targets = ["tableBody", "description"]; + + static values = { + storageKey: { + type: String, + default: location.protocol + "//" + location.host + location.pathname, + }, + singular: { + type: String + }, + plural: { + type: String + } + } connect() { + console.log(this.singularValue) const body = document.getElementById("samples-table"); for (let row of body.rows) { @@ -26,5 +40,15 @@ export default class extends Controller { } } } + const storageValues = JSON.parse( + sessionStorage.getItem(this.storageKeyValue) + ) + if (storageValues) { + if (storageValues.length == 1) { + this.descriptionTarget.innerHTML = this.singularValue + } else { + this.descriptionTarget.innerHTML = this.pluralValue.replace("COUNT_PLACEHOLDER", storageValues.length) + } + } } } diff --git a/app/views/projects/samples/_delete_multiple_samples_dialog.html.erb b/app/views/projects/samples/_delete_multiple_samples_dialog.html.erb index cf816690f7..b1b727f812 100644 --- a/app/views/projects/samples/_delete_multiple_samples_dialog.html.erb +++ b/app/views/projects/samples/_delete_multiple_samples_dialog.html.erb @@ -4,8 +4,16 @@ <%= turbo_frame_tag("deletion-alert") %> -
<%= t(".description") %>
++ <%= t(".description.zero") %> +
<%= form_for(:deletion, url: destroy_multiple_namespace_project_samples_path, method: :delete) do |form| %> -<%= t(".id") %> | <%= t(".name") %> | @@ -23,13 +31,13 @@
---|