feb152c085
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. For example: "You have selected: . Please confirm your selection. " This patch fixes this behaviour by displaying the message with the selected objects only when one or more objects are selected. Otherwise, it only asks for confirmation. Closes-Bug: 2000799 Test Plan: PASS: Build python3-django-horizon package including these changes. PASS: Test the behaviour for single delete actions. For example: Create a patch strategy and press the "Delete" action. Verify the following message is displayed in the pop-up message: "Please confirm your selection. This action cannot be undone." PASS: Test the behaviour for multiple delete actions. For example: Upload more than one patch, select them and click on the 'Delete' action. Verify the following message is displayed: You have selected: "22.12_NRR_INSVC", "22.12_RESTART_FAILURE_INSVC". Please confirm your selection. This action cannot be undone. Signed-off-by: Enzo Candotti <enzo.candotti@windriver.com> Change-Id: I85bc5c8155466e14a1a5fa84d54ed22032437f88
70 lines
2.6 KiB
Diff
70 lines
2.6 KiB
Diff
From 25b0db5778a811c323e07958e03f33847eb7748d Mon Sep 17 00:00:00 2001
|
|
From: Enzo Candotti <enzo.candotti@windriver.com>
|
|
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 <enzo.candotti@windriver.com>
|
|
---
|
|
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 %}
|
|
<div class="confirm-wrapper">
|
|
<span class="confirm-list" style="word-wrap: break-word; word-break: normal;">
|
|
- {% blocktrans %}You have selected: [[selection]]. {% endblocktrans %}
|
|
+ {% blocktrans %} [[selection]] {% endblocktrans %}
|
|
</span>
|
|
<span class="confirm-text">{% trans 'Please confirm your selection.'%} </span>
|
|
<span class="confirm-help">[[help]]</span>
|
|
--
|
|
2.25.1
|
|
|