summaryrefslogtreecommitdiff
path: root/horizon
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2017-11-09 16:50:13 +0000
committerGerrit Code Review <review@openstack.org>2017-11-09 16:50:13 +0000
commitd6df45eeb02a153d694ff001811eb277b5befd5f (patch)
treeae33bd30ee129447bd224dcb9a7fdd3315b36ba8 /horizon
parentaf3ca2a929ff6bb21a2d7748d25d62c5a69f0889 (diff)
parent7f6e03a4dda5a502d31e3d19798b710ca9a182eb (diff)
downloadhorizon-d6df45eeb02a153d694ff001811eb277b5befd5f.tar.gz
Merge "Fix style of the submit button on confirmation modal"
Diffstat (limited to 'horizon')
-rw-r--r--horizon/static/framework/widgets/modal/simple-modal.html4
-rw-r--r--horizon/static/framework/widgets/modal/simple-modal.service.js3
-rw-r--r--horizon/static/horizon/js/horizon.modals.js8
-rw-r--r--horizon/static/horizon/js/horizon.tables.js7
-rw-r--r--horizon/templates/horizon/client_side/_modal.html2
5 files changed, 15 insertions, 9 deletions
diff --git a/horizon/static/framework/widgets/modal/simple-modal.html b/horizon/static/framework/widgets/modal/simple-modal.html
index e35b74590..3e9eed289 100644
--- a/horizon/static/framework/widgets/modal/simple-modal.html
+++ b/horizon/static/framework/widgets/modal/simple-modal.html
@@ -14,8 +14,8 @@
type="button" ng-click="modalCtrl.cancel()">
<span ng-bind="::modalCtrl.context.cancel"></span>
</button>
- <button class="btn btn-primary"
+ <button class="btn" ng-class="modalCtrl.context.confirmCssClass"
type="button" ng-click="modalCtrl.submit()">
<span ng-bind="::modalCtrl.context.submit"></span>
</button>
-</div> \ No newline at end of file
+</div>
diff --git a/horizon/static/framework/widgets/modal/simple-modal.service.js b/horizon/static/framework/widgets/modal/simple-modal.service.js
index c158f017f..b38de9400 100644
--- a/horizon/static/framework/widgets/modal/simple-modal.service.js
+++ b/horizon/static/framework/widgets/modal/simple-modal.service.js
@@ -79,7 +79,8 @@
title: params.title,
body: params.body,
submit: params.submit || gettext('Submit'),
- cancel: params.cancel || gettext('Cancel')
+ cancel: params.cancel || gettext('Cancel'),
+ confirmCssClass: params.confirmCssClass || "btn-primary"
};
}
}
diff --git a/horizon/static/horizon/js/horizon.modals.js b/horizon/static/horizon/js/horizon.modals.js
index 385080f19..0cb2b34ce 100644
--- a/horizon/static/horizon/js/horizon.modals.js
+++ b/horizon/static/horizon/js/horizon.modals.js
@@ -43,13 +43,17 @@ horizon.modals.initModal = function (modal) {
};
/* Creates a modal dialog from the client-side template. */
-horizon.modals.create = function (title, body, confirm, cancel) {
+horizon.modals.create = function (title, body, confirm, cancel, confirmCssClass) {
if (!cancel) {
cancel = gettext("Cancel");
}
var template = horizon.templates.compiled_templates["#modal_template"],
params = {
- title: title, body: body, confirm: confirm, cancel: cancel,
+ title: title,
+ body: body,
+ confirm: confirm,
+ cancel: cancel,
+ confirmCssClass: confirmCssClass || "btn-primary",
modal_backdrop: horizon.modals.MODAL_BACKDROP
};
return $(template.render(params)).appendTo("#modal_wrapper");
diff --git a/horizon/static/horizon/js/horizon.tables.js b/horizon/static/horizon/js/horizon.tables.js
index d86b3970a..6796072f2 100644
--- a/horizon/static/horizon/js/horizon.tables.js
+++ b/horizon/static/horizon/js/horizon.tables.js
@@ -318,8 +318,9 @@ horizon.datatables.confirm = function(action) {
} catch (e) {
body = name_string + gettext("Please confirm your selection. ") + help_text;
}
-
- var modal = horizon.modals.create(title, body, action_string);
+ var actionNode = action.nodeType ? action: action[0];
+ var confirmCssClass = actionNode.className.indexOf("btn-danger") >= 0 ? "btn-danger" : "btn-primary";
+ var modal = horizon.modals.create(title, body, action_string, "", confirmCssClass);
modal.modal();
if ($uibModal_parent.length) {
@@ -329,7 +330,7 @@ horizon.datatables.confirm = function(action) {
modal.css('z-index', child_backdrop.css('z-index')+10);
}
- modal.find('.btn-primary').click(function () {
+ modal.find('.' + confirmCssClass).click(function () {
var $form = $action.closest('form');
var el = document.createElement("input");
el.type = 'hidden';
diff --git a/horizon/templates/horizon/client_side/_modal.html b/horizon/templates/horizon/client_side/_modal.html
index 28e58f5e0..8560e076e 100644
--- a/horizon/templates/horizon/client_side/_modal.html
+++ b/horizon/templates/horizon/client_side/_modal.html
@@ -18,7 +18,7 @@
</div>
<div class='modal-footer'>
<a href='#' class='btn btn-default cancel' data-dismiss='modal'>[[cancel]]</a>
- <a href='#' class='btn btn-primary'>[[confirm]]</a>
+ <a href='#' class='btn [[confirmCssClass]]'>[[confirm]]</a>
</div>
</div>
</div>