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

Hide/show access item feedback checkboxes depending on view allowcomments settings


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent fcd164bd
......@@ -83,11 +83,11 @@ function renderAccessListItem(item) {
TH(null, null),
TD(null, get_string('datetimeformatguide'))
),
TR(null,
TR({'class':'comments' + (allowcomments ? ' hidden' : '')},
TH(null, get_string('allowfeedback') + ':'),
TD(null, allowfdbk)
),
TR(null,
TR({'class':'comments' + (allowcomments ? ' hidden' : '')},
TH(null, get_string('approvefeedback') + ':'),
TD(null, approvefdbk)
)
......
......@@ -178,6 +178,29 @@ EOF;
$js .= "function update_loggedin_access() {}\n";
}
$allowcomments = json_encode($view->get('allowcomments'));
$js .= <<<EOF
var allowcomments = {$allowcomments};
function update_comment_options() {
allowcomments = $('editaccess_allowcomments').checked;
if (allowcomments) {
forEach(getElementsByTagAndClassName('tr', 'comments', 'accesslistitems'), function (elem) {
addElementClass(elem, 'hidden');
});
}
else {
forEach(getElementsByTagAndClassName('tr', 'comments', 'accesslistitems'), function (elem) {
removeElementClass(elem, 'hidden');
});
}
}
addLoadEvent(function() {
connect('editaccess_allowcomments', 'onchange', update_comment_options);
});
EOF;
$form['elements']['accesslist'] = array(
'type' => 'viewacl',
'defaultvalue' => isset($view) ? $view->get_access(get_string('strftimedatetimeshort')) : null
......
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