From 25b0db5778a811c323e07958e03f33847eb7748d Mon Sep 17 00:00:00 2001 From: Enzo Candotti Date: Mon, 2 Jan 2023 13:24:07 -0300 Subject: [PATCH] Fix incomplete pop-up message on delete Action When an Action table is created with a 'danger' action_type and a single handler method for a single object, the 'selection' and 'help' parameters are empty. This causes the pop-up message to be incomplete. This patch fixes this behavior by displaying the message with the selected objects only when one or more objects are selected. Otherwise, it only asks for confirmation. Signed-off-by: Enzo Candotti --- horizon/static/horizon/js/horizon.tables.js | 21 +++++++++++++------ .../horizon/client_side/_confirm.html | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/horizon/static/horizon/js/horizon.tables.js b/horizon/static/horizon/js/horizon.tables.js index 5f42784..b416f19 100644 --- a/horizon/static/horizon/js/horizon.tables.js +++ b/horizon/static/horizon/js/horizon.tables.js @@ -309,13 +309,22 @@ horizon.datatables.confirm = function(action) { var title = interpolate(gettext("Confirm %s"), [action_string]); // compose the action string using a template that can be overridden - var template = horizon.templates.compiled_templates["#confirm_modal"], - params = { - selection: name_string, - selection_list: name_array, - help: help_text - }; + var template = horizon.templates.compiled_templates["#confirm_modal"] + if (name_string == "") { + params = { + selection_list: name_array, + help: 'This action cannot be undone.' + }; + + } + else { + params = { + selection: 'You have selected: ' + name_string + '.', + selection_list: name_array, + help: help_text + }; + } var body; try { body = $(template.render(params)).html(); diff --git a/horizon/templates/horizon/client_side/_confirm.html b/horizon/templates/horizon/client_side/_confirm.html index f6642dd..31451f0 100644 --- a/horizon/templates/horizon/client_side/_confirm.html +++ b/horizon/templates/horizon/client_side/_confirm.html @@ -6,7 +6,7 @@ {% block template %}{% spaceless %}{% jstemplate %}
- {% blocktrans %}You have selected: [[selection]]. {% endblocktrans %} + {% blocktrans %} [[selection]] {% endblocktrans %} {% trans 'Please confirm your selection.'%} [[help]] -- 2.25.1