Commit 50258165 authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review

Merge "Adding default message on the access share page (Bug #1190720)"

parents 6c24a36a 964ff27f
......@@ -159,6 +159,7 @@ $string['share'] = 'Share';
$string['sharedbyme'] = 'Shared by me';
$string['sharewith'] = 'Share with';
$string['accesslist'] = 'Access list';
$string['defaultaccesslistmessage'] = 'Nobody besides you can view your selected pages / collections. Add people to give them access.';
$string['sharewithmygroups'] = 'Share with my groups';
$string['sharewithmyinstitutions'] = 'Share with my institutions';
$string['sharewithusers'] = 'Share with users';
......
......@@ -87,7 +87,8 @@ function pieform_element_viewacl(Pieform $form, $element) {
}
}
}
$defaultaccesslist = ($accesslist) ? 0 : 1;
$myinstitutions = array();
foreach ($USER->get('institutions') as $i) {
$myinstitutions[] = array(
......@@ -155,6 +156,7 @@ function pieform_element_viewacl(Pieform $form, $element) {
$smarty->assign('potentialpresets', json_encode($allowedpresets));
$smarty->assign('loggedinindex', $loggedinindex);
$smarty->assign('accesslist', json_encode($accesslist));
$smarty->assign('defaultaccesslist', $defaultaccesslist);
$smarty->assign('viewid', $form->get_property('viewid'));
$smarty->assign('formname', $form->get_property('name'));
$smarty->assign('myinstitutions', json_encode($myinstitutions));
......
......@@ -2297,7 +2297,7 @@ table.secreturls table tr td {
#viewacl-advanced #results thead, #viewacl-advanced #results tfoot {
font-weight: bold;
}
#accesslisttable {
#accesslisttable, #accesslisttabledefault {
margin: 5px 0;
}
#accesslistitem1 td {
......
......@@ -44,6 +44,21 @@
</tbody>
</table>
<table id="accesslisttabledefault" class="fr hidden fullwidth">
<thead>
<tr class="accesslist-head1">
<th>{{str tag=Added section=view}}</th>
</tr>
<tr class="accesslist-head2">
<th>&nbsp;</th>
</tr>
</thead>
<tbody id="accesslistitems">
<tr>
<td>{{str tag=defaultaccesslistmessage section=view}}</td>
</tr>
</tbody>
</table>
<div class="cb"></div>
</div>
......@@ -83,6 +98,11 @@ function renderPotentialPresetItem(item) {
return row;
}
function renderAccessListDefault() {
addElementClass('accesslisttable', 'hidden');
removeElementClass('accesslisttabledefault', 'hidden');
}
// Given a row, render it on the right hand side
function renderAccessListItem(item) {
var removeButton = BUTTON({'type': 'button', 'title': {{jstr tag=remove}}});
......@@ -177,10 +197,11 @@ function renderAccessListItem(item) {
connect(removeButton, 'onclick', function() {
removeElement(row);
if (!getFirstElementByTagAndClassName('tr', null, 'accesslistitems')) {
addElementClass('accesslisttable', 'hidden');
renderAccessListDefault();
}
});
appendChildNodes('accesslistitems', row);
addElementClass('accesslisttabledefault', 'hidden');
removeElementClass('accesslisttable', 'hidden');
if (notpublicorallowed) {
......@@ -425,12 +446,16 @@ function search(e) {
// Right hand side
addLoadEvent(function () {
{{if $defaultaccesslist}}
renderAccessListDefault();
{{else}}
var accesslist = {{$accesslist|safe}};
if (accesslist) {
forEach(accesslist, function(item) {
renderAccessListItem(item);
});
}
{{/if}}
update_loggedin_access();
});
......
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