Commit 73192165 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

When configuring a read-only textbox, allow copying (bug #736665)



When configuring a textbox containing a read-only artefact (or one
which has copies in other blocks), the user will often want to
create a new copy of the note instead of reusing the note.  This
patch adds a 'copy' link beside the read-only message, which will
unhide the tinymce box and set a flag to ensure that a new html
artefact gets created on submission.

Change-Id: I5214c5b0ae615cd9f32dfc5c71efc942b5961756
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent ea22bbf6
......@@ -34,3 +34,4 @@ $string['usecontentfromanothertextbox'] = 'Use content from another text box';
$string['textusedinotherblocks'] = 'If you edit the text of this block, it will also be changed in %s other block(s) where it appears.';
$string['managealltextboxcontent'] = 'Manage all textbox content';
$string['readonlymessage'] = 'The text you have selected is not editable on this page.';
$string['makeacopy'] = 'Make a copy';
......@@ -8,3 +8,5 @@ note is contained in your Notes area under the Content menu.</p>
other group or institution members may have inserted this text inside
their own pages. If you edit it here, it will be updated on their
pages too.</p>
<p>You can also make a copy of the selected note, and then
when you edit it, the changes will only affect this page.</p>
......@@ -7,4 +7,6 @@ groups inside your own personal page.</p>
your page whenever it is changed by the owner. If you want to update
it yourself, you must do that through a page with the same owner as
the note.</p>
<p>Alternatively, you may take your own copy of this content, and then
when you edit it, the changes will only affect this page.</p>
......@@ -116,6 +116,7 @@ function updateTextContent(a) {
setNodeAttribute('instconf_title', 'value', a.title);
tinyMCE.activeEditor.setContent(a.description);
$('instconf_textreadonly_display').innerHTML = a.safedescription;
$('instconf_makecopy').checked = false;
if (a.editable == 1) {
addElementClass('instconf_textreadonly_container', 'hidden');
addElementClass('instconf_readonlymsg_container', 'hidden');
......@@ -151,6 +152,21 @@ connect('chooseartefactlink', 'onclick', function(e) {
toggleElementClass('hidden', 'instconf_artefactid_container');
toggleElementClass('hidden', 'instconf_managenotes_container');
});
forEach(getElementsByTagAndClassName('a', 'copytextboxnote', 'instconf'), function(link) {
connect(link, 'onclick', function(e) {
e.stop();
forEach(getElementsByTagAndClassName('input', 'radio', 'artefactid_data'), function(i) {
if (i.checked) {
i.checked = false;
}
});
$('instconf_makecopy').checked = true;
addElementClass('instconf_textreadonly_container', 'hidden');
addElementClass('instconf_readonlymsg_container', 'hidden');
addElementClass('instconf_otherblocksmsg_container', 'hidden');
removeElementClass('instconf_text_container', 'hidden');
});
});
EOF;
}
......@@ -210,14 +226,16 @@ EOF;
'otherblocksmsg' => array(
'type' => 'html',
'class' => 'message info' . (($otherblockcount && !$readonly) ? '' : ' hidden'),
'value' => $otherblocksmsg,
'value' => $otherblocksmsg
. ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a>',
'help' => true,
),
// Add a message whenever this text cannot be edited here
'readonlymsg' => array(
'type' => 'html',
'class' => 'message info' . ($readonly ? '' : ' hidden'),
'value' => get_string('readonlymessage', 'blocktype.internal/textbox'),
'value' => get_string('readonlymessage', 'blocktype.internal/textbox')
. ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a>',
'help' => true,
),
'text' => array(
......@@ -235,6 +253,11 @@ EOF;
'width' => '100%',
'value' => '<div id="instconf_textreadonly_display">' . $text . '</div>',
),
'makecopy' => array(
'type' => 'checkbox',
'class' => 'hidden',
'defaultvalue' => false,
),
'chooseartefact' => array(
'type' => 'html',
'class' => 'nojs-hidden-block',
......@@ -260,7 +283,7 @@ EOF;
$data[$f] = $view->get($f);
}
if (empty($values['artefactid'])) {
if (empty($values['artefactid']) || $values['makecopy']) {
// The artefact title will be the same as the block title when the
// artefact is first created, or, if there's no block title, generate
// 'Note (1)', 'Note (2)', etc. After that, the artefact title can't
......@@ -307,6 +330,7 @@ EOF;
unset($values['otherblocksmsg']);
unset($values['readonlymsg']);
unset($values['textreadonly']);
unset($values['makecopy']);
unset($values['chooseartefact']);
unset($values['managenotes']);
......
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