Skip to content
Extraits de code Groupes Projets
Valider 342db0d2 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

refs #2589 display a done message after super user access change while redirect is loading

parent c8f7b10d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -111,7 +111,21 @@ function updateSuperUserAccess(login, hasSuperUserAccess) ...@@ -111,7 +111,21 @@ function updateSuperUserAccess(login, hasSuperUserAccess)
method: 'UsersManager.setSuperUserAccess' method: 'UsersManager.setSuperUserAccess'
}, 'GET'); }, 'GET');
ajaxHandler.addParams(parameters, 'POST'); ajaxHandler.addParams(parameters, 'POST');
ajaxHandler.redirectOnSuccess(); ajaxHandler.setCallback(function () {
var UI = require('piwik/UI');
var notification = new UI.Notification();
notification.show(_pk_translate('General_Done'), {
placeat: '#superUserAccessUpdated',
context: 'success',
noclear: true,
type: 'toast',
style: {display: 'inline-block', marginTop: '10px', marginBottom: '30px'},
id: 'usersManagerSuperUserAccessUpdated'
});
notification.scrollToNotification();
ajaxHandler.redirect();
});
ajaxHandler.setLoadingElement('#ajaxErrorSuperUsersManagement'); ajaxHandler.setLoadingElement('#ajaxErrorSuperUsersManagement');
ajaxHandler.setErrorElement('#ajaxErrorSuperUsersManagement'); ajaxHandler.setErrorElement('#ajaxErrorSuperUsersManagement');
ajaxHandler.send(true); ajaxHandler.send(true);
......
...@@ -207,28 +207,32 @@ function ajaxHelper() { ...@@ -207,28 +207,32 @@ function ajaxHelper() {
* @return {void} * @return {void}
*/ */
this.redirectOnSuccess = function (params) { this.redirectOnSuccess = function (params) {
this.setCallback(function(response) { var self = this;
// add updated=X to the URL so that a "Your changes have been saved" message is displayed this.setCallback(function() {
if (typeof params == 'object') { self.redirect(params);
params = piwikHelper.getQueryStringFromParameters(params);
}
var urlToRedirect = piwikHelper.getCurrentQueryStringWithParametersModified(params);
var updatedUrl = new RegExp('&updated=([0-9]+)');
var updatedCounter = updatedUrl.exec(urlToRedirect);
if (!updatedCounter) {
urlToRedirect += '&updated=1';
} else {
updatedCounter = 1 + parseInt(updatedCounter[1]);
urlToRedirect = urlToRedirect.replace(new RegExp('(&updated=[0-9]+)'), '&updated=' + updatedCounter);
}
var currentHashStr = window.location.hash;
if(currentHashStr.length > 0) {
urlToRedirect += currentHashStr;
}
piwikHelper.redirectToUrl(urlToRedirect);
}); });
}; };
this.redirect = function (params) {
// add updated=X to the URL so that a "Your changes have been saved" message is displayed
if (typeof params == 'object') {
params = piwikHelper.getQueryStringFromParameters(params);
}
var urlToRedirect = piwikHelper.getCurrentQueryStringWithParametersModified(params);
var updatedUrl = new RegExp('&updated=([0-9]+)');
var updatedCounter = updatedUrl.exec(urlToRedirect);
if (!updatedCounter) {
urlToRedirect += '&updated=1';
} else {
updatedCounter = 1 + parseInt(updatedCounter[1]);
urlToRedirect = urlToRedirect.replace(new RegExp('(&updated=[0-9]+)'), '&updated=' + updatedCounter);
}
var currentHashStr = window.location.hash;
if(currentHashStr.length > 0) {
urlToRedirect += currentHashStr;
}
piwikHelper.redirectToUrl(urlToRedirect);
}
/** /**
* Sets the callback called in case of an error within the request * Sets the callback called in case of an error within the request
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter