Commit 7e5f3f60 authored by Robert Lyon's avatar Robert Lyon

Bug 1854421: Allow site form to reload page on save

If certain fields are changed, like theme / language.
As we can't 'see' the changes until we reload the page.

We used to have some code to reload the page if theose fields changed
but it go broken over the years. This tries to fix that.

Change-Id: I62b6740bbdd2757752a21a18e3d76fb0cefcf4d6
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 30d592c3
......@@ -12,7 +12,11 @@
// Add here as appropriate
var forceReloadElements = ['sitename', 'lang', 'theme',
'defaultaccountlifetime_units',
'defaultaccountlifetimeupdate'];
'defaultaccountlifetimeupdate',
'defaultregistrationexpirylifetime_units',
'defaultaccountinactiveexpire_units',
'defaultaccountinactivewarn_units',
'searchplugin', 'remoteavatars']; // Changes that are visible on site options page
var isReloadRequired = false;
// if strict privacy is enabled, disables multiple institutions per user
......@@ -65,33 +69,38 @@ function update_allowpublicprofiles() {
}
var checkReload = (function($) {
// Disconnects the pieform submit handler and changes the form target back to
// the page itself (rather than pieform's hidden iframe), so a full post/reload
// cycle will happen when the form is submitted
// Checks to see if we need to refresh the page after form is saved
// Normally we only load back in the form but for things like language/theme
// changes we want to see them right away.
function reloadRequired() {
isReloadRequired = true;
$('#siteoptions').off();
$('#siteoptions')[0].target = '';
}
// Wires up appropriate elements to cause a full page reload if they're changed
function connectElements() {
$(forceReloadElements).each(function(id, element) {
if ($('#siteoptions_' + element).length) {
$('#siteoptions_' + element).on('change', reloadRequired);
$('#siteoptions_' + element).on('change', reloadRequired);
}
});
$('#siteoptions_allowpublicviews').on('click', update_allowpublicprofiles);
}
connectElements();
jQuery(function() {
connectElements();
});
// Javascript success handler for the form. Re-wires up the elements
return function(form, data) {
update_allowpublicprofiles();
isReloadRequired = false;
if (isReloadRequired == true) {
isReloadRequired = false;
jQuery('#siteoptions_applying').removeClass('d-none');
setTimeout(function() {
window.location.href = data.goto;
}, 1000);
}
connectElements();
jQuery('#siteoptions_institutionstrictprivacy').on("click", function() {
......
......@@ -217,6 +217,7 @@ $string['cleanurlsdescriptionshort'] = 'Configure site to use human-readable URL
// sanity check warnings
$string['warnings'] = 'Warning';
$string['applyingchanges'] = 'Applying changes';
// Group management
$string['groupcategories'] = 'Group categories';
......
......@@ -6,4 +6,13 @@
}
.loading-message {
margin-left: 5px;
}
\ No newline at end of file
}
.applying-box {
font-size: 1.2em;
left: calc(50% - 150px);
top: 50%;
width: 300px;
position: absolute;
text-align: center;
padding: 10px 0;
}
......@@ -10,4 +10,10 @@
{$siteoptionform|safe}
</div>
</div>
<div id="siteoptions_applying" class="modal modal-docked active d-none">
<div class="applying-box loading-inner navbar-default">
<span class="icon-spinner icon-pulse icon icon-lg"></span>
{str tag=applyingchanges section=admin}
</div>
</div>
{include file="footer.tpl"}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment