Try to clean up the whole weird store.clear('slide') mess, make it more semantic

This commit is contained in:
Alexandre Aubin 2019-10-14 03:40:55 +02:00
parent e2dcb1765f
commit 46c5e1c4ad
9 changed files with 121 additions and 177 deletions

View file

@ -245,7 +245,7 @@
});
});
// Perform application
// Perform app action
app.put('#/apps/:app/actions/:action', function(c) {
// taken from app install
$.each(c.params, function(k, v) {
@ -265,7 +265,7 @@
}
c.api('PUT', '/apps/'+app_id+'/actions/'+action_id, params, function() {
c.redirect('#/apps/'+app_id+'/actions');
c.redirect_to('#/apps/'+app_id+'/actions', {slide:false});
});
});
@ -298,7 +298,7 @@
}
c.api('POST', '/apps/'+app_id+'/config', params, function() {
c.redirect('#/apps/'+app_id+'/config-panel');
c.redirect_to('#/apps/'+app_id+'/config-panel', {slide:false});
});
})
@ -306,7 +306,7 @@
app.get('#/apps/install/custom', function (c) {
// If we try to GET /apps/install/custom, it means that installation fail.
// Need to redirect to apps/install to get rid of pacamn and see the log.
c.redirect('#/apps/install');
c.redirect_to('#/apps/install');
});
// Helper function that formats YunoHost style arguments for generating a form
@ -502,7 +502,7 @@
},
function(){
$('div.loader').remove();
c.redirect('#/apps/install');
c.redirect_to('#/apps/install', {slide:false});
}
);
}
@ -544,13 +544,12 @@
}
c.api('POST', '/apps', params, function() {
c.redirect('#/apps');
c.redirect_to('#/apps');
});
}
else {
c.flash('warning', y18n.t('app_install_cancel'));
store.clear('slide');
c.redirect('#/apps/install');
c.redirect_to('#/apps/install', {slide: false});
}
});
@ -590,14 +589,12 @@
})
.fail(function(xhr) {
c.flash('fail', y18n.t('app_install_custom_no_manifest'));
store.clear('slide');
c.redirect('#/apps/install');
c.redirect_to('#/apps/install', {slide:false});
});
},
function(){
c.flash('warning', y18n.t('app_install_cancel'));
store.clear('slide');
c.redirect('#/apps/install');
c.redirect_to('#/apps/install');
}
);
});
@ -609,12 +606,11 @@
y18n.t('confirm_uninstall', [c.params['app']]),
function() {
c.api('DELETE', '/apps/'+ c.params['app'], {}, function() { // http://api.yunohost.org/#!/app/app_remove_delete_4
c.redirect('#/apps');
c.redirect_to('#/apps');
});
},
function() {
store.clear('slide');
c.redirect('#/apps/'+ c.params['app']);
c.redirect_to('#/apps/'+ c.params['app'], {slide:false});
}
);
});
@ -675,13 +671,11 @@
users: []
};
c.api('DELETE', '/access?'+c.serialize(params), params, function(data) {
store.clear('slide');
c.redirect('#/apps/'+ c.params['app']+ '/access');
c.redirect_to('#/apps/'+ c.params['app']+ '/access', {slide:false});
});
},
function() {
store.clear('slide');
c.redirect('#/apps/'+ c.params['app']+ '/access');
c.redirect_to('#/apps/'+ c.params['app']+ '/access', {slide:false});
}
);
});
@ -697,13 +691,11 @@
users: c.params['user']
};
c.api('DELETE', '/access?'+c.serialize(params), params, function(data) {
store.clear('slide');
c.redirect('#/apps/'+ c.params['app']+ '/access');
c.redirect_to('#/apps/'+ c.params['app']+ '/access', {slide:false});
});
},
function() {
store.clear('slide');
c.redirect('#/apps/'+ c.params['app']+ '/access');
c.redirect_to('#/apps/'+ c.params['app']+ '/access', {slide:false});
}
);
});
@ -719,13 +711,11 @@
users: null
};
c.api('PUT', '/access', params, function() {
store.clear('slide');
c.redirect('#/apps/'+ c.params['app'] +'/access');
c.redirect_to('#/apps/'+ c.params['app'] +'/access', {slide:false});
});
},
function() {
store.clear('slide');
c.redirect('#/apps/'+ c.params['app']+ '/access');
c.redirect_to('#/apps/'+ c.params['app']+ '/access', {slide:false});
}
);
});
@ -737,8 +727,7 @@
apps: c.params['app']
};
c.api('PUT', '/access', params, function() {
store.clear('slide');
c.redirect('#/apps/'+ c.params['app'] +'/access');
c.redirect_to('#/apps/'+ c.params['app'] +'/access', {slide:false});
});
});
@ -752,13 +741,11 @@
apps: c.params['app']
};
c.api('POST', '/access', params, function() {
store.clear('slide');
c.redirect('#/apps/'+ c.params['app'] +'/access');
c.redirect_to('#/apps/'+ c.params['app'] +'/access', {slide:false});
});
},
function() {
store.clear('slide');
c.redirect('#/apps/'+ c.params['app']+ '/access');
c.redirect_to('#/apps/'+ c.params['app']+ '/access', {slide:false});
}
);
});
@ -770,13 +757,11 @@
y18n.t('confirm_app_default'),
function() {
c.api('PUT', '/apps/'+c.params['app']+'/default', {}, function() {
store.clear('slide');
c.redirect('#/apps/'+ c.params['app']);
c.redirect_to('#/apps/'+ c.params['app'], {slide:false});
});
},
function() {
store.clear('slide');
c.redirect('#/apps/'+ c.params['app']);
c.redirect_to('#/apps/'+ c.params['app'], {slide:false});
}
);
});
@ -796,8 +781,7 @@
app.post('#/apps/:app/changelabel', function (c) {
params = {'new_label': c.params['label']};
c.api('PUT', '/apps/' + c.params['app'] + '/label', params, function(data) { // Call changelabel API
store.clear('slide');
c.redirect('#/apps/'+ c.params['app']);
c.redirect_to('#/apps/'+ c.params['app']);
});
});
@ -837,13 +821,11 @@
function() {
params = {'domain': c.params['domain'], 'path': c.params['path']};
c.api('PUT', '/apps/' + c.params['app'] + '/changeurl', params, function(data) { // Call changeurl API
store.clear('slide');
c.redirect('#/apps/'+ c.params['app']);
c.redirect_to('#/apps/'+ c.params['app']);
});
},
function() {
store.clear('slide');
c.redirect('#/apps/'+ c.params['app'] + '/changeurl');
c.redirect_to('#/apps/'+ c.params['app'] + '/changeurl', {slide:false});
}
);
});

View file

@ -39,8 +39,7 @@
// Create a storage
app.post('#/storages', function (c) {
store.clear('slide');
c.redirect('#/storages');
c.redirect_to('#/storages');
});
// Create a backup
@ -64,8 +63,7 @@
app.post('#/backup/:storage', function (c) {
var params = c.ungroupHooks(c.params['system_parts'],c.params['apps']);
c.api('POST', '/backup', params, function() {
store.clear('slide');
c.redirect('#/backup/'+ c.params['storage']);
c.redirect_to('#/backup/'+ c.params['storage']);
});
});
@ -78,13 +76,11 @@
var params = c.ungroupHooks(c.params['system_parts'],c.params['apps']);
params['force'] = '';
c.api('POST', '/backup/restore/'+c.params['archive'], params, function(data) {
store.clear('slide');
c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']);
c.redirect_to('#/backup/'+ c.params['storage']+'/'+c.params['archive']);
});
}, this, c),
function(){
store.clear('slide');
c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']);
c.redirect_to('#/backup/'+ c.params['storage']+'/'+c.params['archive'], {slide: false});
}
);
});
@ -96,12 +92,11 @@
y18n.t('confirm_delete', [c.params['archive']]),
function(){
c.api('DELETE', '/backup/archives/'+c.params['archive'], {}, function(data) {
c.redirect('#/backup/'+ c.params['storage']);
c.redirect_to('#/backup/'+ c.params['storage']);
});
},
function(){
store.clear('slide');
c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']);
c.redirect_to('#/backup/'+ c.params['storage']+'/'+c.params['archive'], {slide: false});
}
);
});
@ -109,20 +104,18 @@
// Download a backup
app.get('#/backup/:storage/:archive/download', function (c) {
c.api('GET', '/backup/'+c.params['archive']+'/download', {}, function(data) {
c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']);
c.redirect_to('#/backup/'+ c.params['storage']+'/'+c.params['archive'], {slide: false});
});
});
// Copy a backup
app.get('#/backup/:storage/:archive/copy', function (c) {
store.clear('slide');
c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']);
c.redirect_to('#/backup/'+ c.params['storage']+'/'+c.params['archive'], {slide: false});
});
// Upload a backup
app.get('#/backup/:storage/:archive/upload', function (c) {
store.clear('slide');
c.redirect('#/backup/'+ c.params['storage']+'/'+c.params['archive']);
c.redirect_to('#/backup/'+ c.params['storage']+'/'+c.params['archive'], {slide: false});
});
// Get archive info

View file

@ -68,8 +68,7 @@
if (c.params['domain'] === '') {
if (c.params['ddomain'] === '') {
c.flash('fail', y18n.t('error_select_domain'));
store.clear('slide');
c.redirect('#/domains/add');
c.redirect_to('#/domains/add');
}
params.domain = c.params['ddomain'] + c.params['ddomain-ext'];
endurl = 'dyndns';
@ -78,7 +77,7 @@
}
c.api('POST', '/domains?'+endurl, params, function(data) {
c.redirect('#/domains');
c.redirect_to('#/domains');
});
});
@ -210,13 +209,11 @@
y18n.t('confirm_cert_install_LE', [c.params['domain']]),
function(){
c.api('POST', '/domains/cert-install/' + c.params['domain'], {}, function(data) {
store.clear('slide');
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
c.redirect_to('#/domains/'+c.params['domain']+'/cert-management', {slide:false});
});
},
function(){
store.clear('slide');
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
c.redirect_to('#/domains/'+c.params['domain']+'/cert-management', {slide:false});
}
);
});
@ -228,13 +225,11 @@
y18n.t('confirm_cert_regen_selfsigned', [c.params['domain']]),
function(){
c.api('POST', '/domains/cert-install/' + c.params['domain'] + "?self_signed", {}, function(data) {
store.clear('slide');
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
c.redirect_to('#/domains/'+c.params['domain']+'/cert-management', {slide:false});
});
},
function(){
store.clear('slide');
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
c.redirect_to('#/domains/'+c.params['domain']+'/cert-management', {slide:false});
}
);
});
@ -246,13 +241,11 @@
y18n.t('confirm_cert_manual_renew_LE', [c.params['domain']]),
function(){
c.api('POST', '/domains/cert-renew/' + c.params['domain'] + "?force", {}, function(data) {
store.clear('slide');
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
c.redirect_to('#/domains/'+c.params['domain']+'/cert-management', {slide:false});
});
},
function(){
store.clear('slide');
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
c.redirect_to('#/domains/'+c.params['domain']+'/cert-management', {slide:false});
}
);
});
@ -264,13 +257,11 @@
y18n.t('confirm_cert_revert_to_selfsigned', [c.params['domain']]),
function(){
c.api('POST', '/domains/cert-install/' + c.params['domain'] + "?self_signed&force", {}, function(data) {
store.clear('slide');
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
c.redirect_to('#/domains/'+c.params['domain']+'/cert-management', {slide:false});
});
},
function(){
store.clear('slide');
c.redirect('#/domains/'+c.params['domain']+'/cert-management');
c.redirect_to('#/domains/'+c.params['domain']+'/cert-management', {slide:false});
}
);
});
@ -283,23 +274,19 @@
y18n.t('confirm_delete', [c.params['domain']]),
function(){
c.api('DELETE', '/domains/'+ c.params['domain'], {}, function(data) {
store.clear('slide');
c.redirect('#/domains');
c.redirect_to('#/domains');
});
},
function(){
store.clear('slide');
c.redirect('#/domains');
}
);
c.redirect_to('#/domains/' + c.params["domain"], {slide:false});
})
});
// Set default domain
app.post('#/domains', function (c) {
if (c.params['domain'] === '') {
c.flash('fail', y18n.t('error_select_domain'));
store.clear('slide');
c.redirect('#/domains');
c.redirect_to('#/domains', {slide:false});
} else {
c.confirm(
y18n.t('domains'),
@ -309,19 +296,18 @@
new_domain: c.params['domain']
};
c.api('PUT', '/domains/main', params, function(data) {
store.clear('slide');
c.redirect('#/domains');
c.redirect_to('#/domains');
});
// WTF ... why is this hack needed v_v
// Wait 15s and refresh the page
var refreshDomain = window.setTimeout(function(){
store.clear('slide');
c.redirect('#/domains');
c.redirect_to('#/domains');
}, 15000);
},
function(){
store.clear('slide');
c.redirect('#/domains');
c.redirect_to('#/domains', {slide:false});
}
);
}

View file

@ -45,13 +45,11 @@
action : c.params['action']
};
c.api('GET', '/firewall/upnp', params, function(data) {
store.clear('slide');
c.redirect('#/tools/firewall');
c.redirect_to('#/tools/firewall');
});
},
function(){
store.clear('slide');
c.redirect('#/tools/firewall');
c.redirect_to('#/tools/firewall', {slide: false});
}
);
});
@ -65,8 +63,7 @@
if (port != parseInt(port) || port < 0 || port > 65535) {
c.flash('fail', y18n.t('unknown_argument', [port]));
store.clear('slide');
c.redirect('#/tools/firewall');
c.redirect_to('#/tools/firewall', {slide: false});
}
switch (connection) {
@ -98,8 +95,7 @@
break;
default:
c.flash('fail', y18n.t('unknown_action', [action]));
store.clear('slide');
c.redirect('#/tools/firewall');
c.redirect_to('#/tools/firewall', {slide: false});
}
if (method !== null && protocol !== null && port !== null) {
@ -116,13 +112,11 @@
protocol : protocol
};
c.api(method, '/firewall/port?'+endurl, params, function(data) {
store.clear('slide');
c.redirect('#/tools/firewall');
c.redirect_to('#/tools/firewall');
});
}
else {
store.clear('slide');
c.redirect('#/tools/firewall');
c.redirect_to('#/tools/firewall');
}
return;
});
@ -143,8 +137,7 @@
);
},
function(){
store.clear('slide');
c.redirect('#/tools/firewall');
c.redirect_to('#/tools/firewall', {slide: false});
}
);
});
@ -163,8 +156,7 @@
);
},
function(){
store.clear('slide');
c.redirect('#/tools/firewall');
c.redirect_to('#/tools/firewall', {slide: false});
}
);
});

View file

@ -13,7 +13,7 @@
$('#masthead').hide();
c.checkInstall(function(isInstalled) {
if (isInstalled || typeof isInstalled === 'undefined') {
c.redirect('#/login');
c.redirect_to('#/login');
} else {
c.view('postinstall/postinstall_1');
}
@ -41,7 +41,6 @@
if ($('#domain').val() === '') {
if ($('#ddomain').val() === '') {
e.preventDefault();
store.clear('slide');
c.flash('fail', y18n.t('error_select_domain'));
} else {
domain = $('#ddomain').val() + $('select[name="ddomain-ext"]').val();
@ -59,8 +58,7 @@
app.get('#/postinstall/password', function(c) {
$('#masthead').hide();
if (!store.get('maindomain')) {
store.clear('slide');
c.redirect('#/postinstall/domain');
c.redirect_to('#/postinstall/domain');
} else {
c.view('postinstall/postinstall_3', { 'domain': store.get('maindomain').toLowerCase() },
function() { },
@ -76,8 +74,7 @@
else if (c.params['password'] == c.params['confirmation']) {
if (c.params['domain'] === '') {
c.flash('fail', y18n.t('error_select_domain'));
store.clear('slide');
c.redirect('#/postinstall/domain');
c.redirect_to('#/postinstall/domain', {slide: false});
} else {
var params = {
domain: c.params['domain'].toLowerCase()
@ -93,7 +90,7 @@
store.set('url', window.location.hostname +'/yunohost/api');
store.set('user', 'admin');
c.api('POST', '/postinstall', params, function(data) {
c.redirect('#/login');
c.redirect_to('#/login');
});
},
function(){

View file

@ -64,7 +64,6 @@
{
data2.service.active_at = 0;
}
store.clear('slide');
c.view('service/service_info', data2);
});
});
@ -111,24 +110,20 @@
break;
default:
c.flash('fail', y18n.t('unknown_action', [c.params['action']]));
store.clear('slide');
c.redirect('#/services/'+ c.params['service']);
c.redirect_to('#/services/'+ c.params['service'], {slide: false});
}
if (method && endurl) {
c.api(method, '/services/'+ endurl, {}, function(data) {
store.clear('slide');
c.redirect('#/services/'+ c.params['service']);
c.redirect_to('#/services/'+ c.params['service'], {slide: false});
});
}
else {
store.clear('slide');
c.redirect('#/services/'+ c.params['service']);
c.redirect_to('#/services/'+ c.params['service'], {slide: false});
}
},
function(){
store.clear('slide');
c.redirect('#/services/'+ c.params['service']);
c.redirect_to('#/services/'+ c.params['service'], {slide: false});
}
);
});

View file

@ -26,12 +26,10 @@
});
if ($.isEmptyObject(params)) {
c.flash('fail', y18n.t('error_modify_something'));
store.clear('slide');
c.redirect('#/tools/adminpw');
c.redirect_to('#/tools/adminpw', {slide: false});
} else if (params['new_password'] !== params['confirm_new_password']) {
c.flash('fail', y18n.t('passwords_dont_match'));
store.clear('slide');
c.redirect('#/tools/adminpw');
c.redirect_to('#/tools/adminpw', {slide: false});
} else {
c.api('POST', '/login', { 'password': params['old_password'] }, function(data) {
// Remove useless variable
@ -40,7 +38,7 @@
// Update password and redirect to the home
c.api('PUT', '/adminpw', params, function(data) {
c.redirect('#/logout');
c.redirect_to('#/logout');
});
}, undefined, false);
}
@ -61,13 +59,11 @@
y18n.t('confirm_update_' + c.params['type'].toLowerCase()),
function(){
c.api('PUT', '/upgrade?'+c.params["type"], {}, function(data) {
store.clear('slide');
c.redirect('#/tools/logs');
c.redirect_to('#/tools/logs');
});
},
function(){
store.clear('slide');
c.redirect('#/update');
c.redirect_to('#/update', {slide: false});
}
);
});
@ -79,13 +75,11 @@
y18n.t('confirm_update_specific_app', [c.params['app']]),
function(){
c.api('PUT', '/upgrade/apps?app='+c.params['app'].toLowerCase(), {}, function(data) {
store.clear('slide');
c.redirect('#/tools/logs');
c.redirect_to('#/tools/logs');
});
},
function(){
store.clear('slide');
c.redirect('#/update');
c.redirect_to('#/update', {slide: false});
}
);
});
@ -220,7 +214,7 @@
function(){
c.api('PUT', '/'+action+'?force', {}, function(data) {
// This code is not executed due to 502 response (reboot or shutdown)
c.redirect('#/logout');
c.redirect_to('#/logout');
}, function (xhr) {
c.flash('success', y18n.t('tools_' + action + '_done'))
// Disconnect from the webadmin
@ -244,20 +238,17 @@
// Force scrollTop on page load
$('html, body').scrollTop(0);
store.clear('slide');
}, false);
},
function(){
store.clear('slide');
c.redirect('#/tools/reboot');
c.redirect_to('#/tools/reboot', {slide: false});
}
);
}
else {
c.flash('fail', y18n.t('unknown_action', [action]));
store.clear('slide');
c.redirect('#/tools/reboot');
c.redirect_to('#/tools/reboot', {slide: false});
}
});
@ -313,7 +304,7 @@
{
// FIXME / TODO i18n
c.flash('fail', "Some of these migrations require you to acknowledge a disclaimer before running them.");
c.redirect('#/tools/migrations');
c.redirect_to('#/tools/migrations', {slide: false});
return;
}
else
@ -328,15 +319,13 @@
if (withAcceptDisclaimerFlag)
{
c.api('POST', '/migrations/migrate?accept_disclaimer', {}, function (data) {
store.clear('slide');
c.redirect('#/tools/migrations');
c.redirect_to('#/tools/migrations', {slide: false});
})
}
else
{
c.api('POST', '/migrations/migrate', {}, function (data) {
store.clear('slide');
c.redirect('#/tools/migrations');
c.redirect_to('#/tools/migrations', {slide: false});
})
}
});
@ -347,13 +336,11 @@
y18n.t('confirm_migrations_skip'),
function(){
c.api('POST', '/migrations/migrate?skip&targets=' + c.params['migration_id'], {}, function(data) {
store.clear('slide');
c.redirect('#/tools/migrations');
c.redirect_to('#/tools/migrations', {slide: false});
});
},
function(){
store.clear('slide');
c.redirect('#/tools/migrations');
c.redirect_to('#/tools/migrations', {slide: false});
}
);
});
@ -384,8 +371,7 @@
}
c.api('PUT', '/appslists', list, function(data) {
store.clear('slide');
c.redirect('#/tools/appslists/' + list.name);
c.redirect_to('#/tools/appslists/' + list.name);
});
});
@ -403,8 +389,7 @@
}
else {
c.flash('warning', y18n.t('appslists_unknown_list', [c.params['appslist']]));
store.clear('slide');
c.redirect('#/tools/appslists');
c.redirect_to('#/tools/appslists', {slide: false});
}
});
});
@ -412,15 +397,14 @@
// Refresh available apps list
app.get('#/tools/appslists/refresh', function (c) {
c.api('PUT', '/appslists', {}, function(data) {
// c.redirect(store.get('path'));
c.redirect('#/apps/install');
c.redirect_to('#/apps/install', {slide: false});
});
});
// Refresh specific apps list
app.get('#/tools/appslists/:appslist/refresh', function (c) {
c.api('PUT', '/appslists', {'name' : c.params['appslist']}, function(data) {
c.redirect('#/tools/appslists');
c.redirect_to('#/tools/appslists', {slide: false});
});
});
@ -431,12 +415,11 @@
y18n.t('appslists_confirm_remove', [c.params['app']]),
function() {
c.api('DELETE', '/appslists', {'name' : c.params['appslist']}, function() {
c.redirect('#/tools/appslists');
c.redirect_to('#/tools/appslists');
});
},
function() {
store.clear('slide');
c.redirect('#/tools/appslists/'+ c.params['appslist']);
c.redirect_to('#/tools/appslists/'+ c.params['appslist'], {slide: false});
}
);
});

View file

@ -40,7 +40,6 @@
if (c.params['password'] == c.params['confirmation']) {
if (c.params['password'].length < PASSWORD_MIN_LENGTH) {
c.flash('fail', y18n.t('password_too_short'));
store.clear('slide');
}
else {
// Force unit or disable quota
@ -53,13 +52,11 @@
c.params['mail'] = c.params['email'] + c.params['domain'];
c.api('POST', '/users', c.params.toHash(), function(data) {
c.redirect('#/users');
c.redirect_to('#/users');
});
}
} else {
c.flash('fail', y18n.t('passwords_dont_match'));
store.clear('slide');
//c.redirect('#/users/create');
}
});
@ -163,31 +160,28 @@
if ($.isEmptyObject(params)) {
c.flash('fail', y18n.t('error_modify_something'));
store.clear('slide');
c.redirect('#/users/'+ c.params['user'] + '/edit');
c.redirect_to('#/users/'+ c.params['user'] + '/edit', {slide: false});
} else {
if (params['password']) {
if (params['password'] == params['confirmation']) {
if (params['password'].length < PASSWORD_MIN_LENGTH) {
c.flash('fail', y18n.t('password_too_short'));
store.clear('slide');
c.redirect('#/users/'+ c.params['user'] + '/edit');
c.redirect_to('#/users/'+ c.params['user'] + '/edit', {slide: false});
}
else {
params['change_password'] = params['password'];
c.api('PUT', '/users/'+ c.params['user'], params, function(data) {
c.redirect('#/users/'+ c.params['user']);
c.redirect_to('#/users/'+ c.params['user']);
});
}
} else {
c.flash('fail', y18n.t('passwords_dont_match'));
store.clear('slide');
c.redirect('#/users/'+ c.params['user'] + '/edit');
c.redirect_to('#/users/'+ c.params['user'] + '/edit', {slide: false});
}
}
else {
c.api('PUT', '/users/'+ c.params['user'], params, function(data) {
c.redirect('#/users/'+ c.params['user']);
c.redirect_to('#/users/'+ c.params['user']);
});
}
}
@ -210,12 +204,11 @@
confirmModalContent,
function(){
c.api('DELETE', '/users/'+ c.params['user'], params, function(data) {
c.redirect('#/users');
c.redirect_to('#/users');
});
},
function(){
store.clear('slide');
c.redirect('#/users/'+ c.params['user']);
c.redirect_to('#/users/'+ c.params['user'], {slide: false});
}
);

View file

@ -565,6 +565,29 @@
$('div.loader').remove();
});
});
},
redirect_to: function(destination, options) {
options = options !== undefined ? options : {};
// If destination if the same as current url,
// we don't want to display the slide animation
// (or if the code explicitly state to disable slide animation)
if ((c.path.split("#")[1] == destination.split("#")[1]) || (options.slide == false))
{
store.clear('slide');
}
c = this;
// This is a copy-pasta of some of the redirect/refresh code of
// sammy.js because for some reason calling the original
// redirect/refresh function in some context does not work >.>
// (e.g. if you're already on the page)
c.trigger('redirect', {to: destination});
c.app.last_location = c.path;
c.app.setLocation(destination);
c.app.trigger('location-changed');
}
});