summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAna Krivokapic <akrivoka@redhat.com>2013-06-13 16:10:33 +0200
committerPetr Vobornik <pvoborni@redhat.com>2013-06-13 17:42:46 +0200
commit851b09183208ac90fc242dfcebff033de2757d5d (patch)
tree508344f1569185050e737204c7a32455f6c91e58
parentdaa9b4e348bcf95b989f5ef7fb40b120a8ced580 (diff)
downloadfreeipa-851b09183208ac90fc242dfcebff033de2757d5d.zip
freeipa-851b09183208ac90fc242dfcebff033de2757d5d.tar.gz
freeipa-851b09183208ac90fc242dfcebff033de2757d5d.tar.xz
Fix displaying of success message
Make sure that the success message is properly populated with actual number of items that were successfully added/removed. https://fedorahosted.org/freeipa/ticket/3708
-rw-r--r--install/ui/src/freeipa/association.js42
-rw-r--r--install/ui/src/freeipa/ipa.js15
2 files changed, 31 insertions, 26 deletions
diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js
index 15e1649..c60c7b8 100644
--- a/install/ui/src/freeipa/association.js
+++ b/install/ui/src/freeipa/association.js
@@ -609,10 +609,13 @@ IPA.association_table_widget = function (spec) {
dialog.execute = function() {
that.add(
dialog.get_selected_values(),
- function() {
+ function(data) {
that.refresh();
dialog.close();
- IPA.notify_success('@i18n:association.added');
+
+ var succeeded = IPA.get_succeeded(data);
+ var msg = text.get('@i18n:association.added').replace('${count}', succeeded);
+ IPA.notify_success(msg);
},
function() {
that.refresh();
@@ -671,9 +674,12 @@ IPA.association_table_widget = function (spec) {
dialog.execute = function() {
that.remove(
selected_values,
- function() {
+ function(data) {
that.refresh();
- IPA.notify_success('@i18n:association.removed');
+
+ var succeeded = IPA.get_succeeded(data);
+ var msg = text.get('@i18n:association.removed').replace('${count}', succeeded);
+ IPA.notify_success(msg);
},
function() {
that.refresh();
@@ -1084,17 +1090,8 @@ exp.association_facet = IPA.association_facet = function (spec, no_init) {
on_success: function(data) {
that.refresh();
dialog.close();
- var succeeded = data.result.completed;
-
- if (!succeeded) {
- succeeded = 0;
- for (var i = 0; i< data.result.results.length; i++) {
- if (data.result.results[i].completed === 1) {
- succeeded++;
- }
- }
- }
+ var succeeded = IPA.get_succeeded(data);
var msg = text.get('@i18n:association.added').replace('${count}', succeeded);
IPA.notify_success(msg);
},
@@ -1148,17 +1145,7 @@ exp.association_facet = IPA.association_facet = function (spec, no_init) {
on_success: function(data) {
that.refresh();
- var succeeded = data.result.completed;
-
- if (!succeeded) {
- succeeded = 0;
- for (var i = 0; i< data.result.results.length; i++) {
- if (data.result.results[i].completed === 1) {
- succeeded++;
- }
- }
- }
-
+ var succeeded = IPA.get_succeeded(data);
var msg = text.get('@i18n:association.removed').replace('${count}', succeeded);
IPA.notify_success(msg);
},
@@ -1417,7 +1404,10 @@ exp.attribute_facet = IPA.attribute_facet = function(spec, no_init) {
function(data) {
that.load(data);
that.show_content();
- IPA.notify_success('@i18n:association.removed');
+
+ var succeeded = IPA.get_succeeded(data);
+ var msg = text.get('@i18n:association.removed').replace('${count}', succeeded);
+ IPA.notify_success(msg);
},
function() {
that.refresh();
diff --git a/install/ui/src/freeipa/ipa.js b/install/ui/src/freeipa/ipa.js
index 441a905..24f450e 100644
--- a/install/ui/src/freeipa/ipa.js
+++ b/install/ui/src/freeipa/ipa.js
@@ -1949,6 +1949,21 @@ IPA.notify_success = function(message, timeout) {
}, timeout || IPA.config.message_timeout);
};
+IPA.get_succeeded = function(data) {
+ var succeeded = data.result.completed;
+
+ if (typeof succeeded !== 'number') {
+ succeeded = 0;
+ for (var i = 0; i< data.result.results.length; i++) {
+ if (data.result.results[i].completed === 1) {
+ succeeded++;
+ }
+ }
+ }
+
+ return succeeded;
+};
+
IPA.config = {
default_priority: 500,
message_timeout: 3000, // [ms]