Commit 72b6e3aa authored by Nigel McNie's avatar Nigel McNie
Browse files

Ensure you can only configure one blockinstance at once.

* In the non javascript version, make sure that request variables are not passed through, which can result in the newly chosen form artefact chooser starting on the wrong page
* In the javascript version, close the old form when opening a new one.

Also, added a 'loading' spinner/message to be displayed while the configuration form is being retrieved.
parent 056b05ef
......@@ -254,21 +254,44 @@ function ViewManager() {
connect(button, 'onclick', function(e) {
setNodeAttribute(button, 'disabled', 'disabled');
// If there is a configuration form open, close it. This is because
// each one shares the same form tag - the one for the entire form.
// We might be able to support having more than one form open at
// any one time, as long as we can detect precisely which form was
// submitted
if (self.currentConfigureData) {
self.currentConfigureData['contentdiv'].innerHTML = self.currentConfigureData['oldcontent'];
removeNodeAttribute(self.currentConfigureData['button'], 'disabled');
self.currentConfigureData = null;
var pd = {'id': $('viewid').value, 'change': 1};
pd[getNodeAttribute(e.src(), 'name')] = 1;
var blockinstance = getFirstParentByTagAndClassName(button, 'div', 'blockinstance');
var blockinstanceId ='_') + 1);
var contentDiv = getFirstElementByTagAndClassName('div', 'blockinstance-content', blockinstance);
var oldContent = contentDiv.innerHTML;
// Put a loading message in place while the form downloads
replaceChildNodes(contentDiv, IMG({'src': config.theme['images/loading.gif']}), ' ', get_string('loading'));
sendjsonrequest('blocks.json.php', pd, 'POST', function(data) {
var blockinstance = getFirstParentByTagAndClassName(button, 'div', 'blockinstance');
var blockinstanceId ='_') + 1);
var content = getFirstElementByTagAndClassName('div', 'blockinstance-content', blockinstance);
var oldContent = content.innerHTML;
content.innerHTML =['html'];
self.currentConfigureData = {
'contentdiv': contentDiv,
'oldcontent': oldContent,
'button' : button
contentDiv.innerHTML =['html'];
// Make the cancel button be supersmart
var cancelButton = $('cancel_cb_' + blockinstanceId + '_action_configureblockinstance_id_' + blockinstanceId);
connect(cancelButton, 'onclick', function(e) {
content.innerHTML = oldContent;
contentDiv.innerHTML = oldContent;
self.currentConfigureData = null;
removeNodeAttribute(button, 'disabled');
......@@ -951,6 +974,10 @@ function ViewManager() {
// it is dropped. Needs a margin the same as the blockinstances
this.blockPlaceholder = DIV({'id': 'block-placeholder'});
// A container for information about the blockinstance current being
// configured
this.currentConfigureData = null;
// The column container - set in self.init
this.columnContainer = null;
......@@ -2,7 +2,7 @@
{include file="columnfullstart.tpl"}
<form action="" method="post">
<form action="{$formurl}" method="post">
<input type="hidden" id="viewid" name="id" value="{$view}">
<input type="hidden" name="change" value="1">
<input type="hidden" id="category" name="c" value="{$category}">
......@@ -60,6 +60,7 @@ $smarty->assign('columns', $columns);
// Tell smarty we're editing rather than just rendering
$smarty->assign('editing', true);
$smarty->assign('formurl', get_config('wwwroot') . 'view/blocks.php');
$smarty->assign('category', $category);
$smarty->assign('new', $new);
$smarty->assign('view', $view->get('id'));
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