* Fix edit api lib's acl linkage issue.
This commit is contained in:
@@ -260,3 +260,88 @@ function genKey()
|
||||
key += Math.random().toString(36).substr(2)
|
||||
return key
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle acl.
|
||||
*
|
||||
* @param string $acl
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function toggleAcl(type)
|
||||
{
|
||||
const acl = $('input[name=acl]:checked').val();
|
||||
let libID = $('input[name=lib]').val();
|
||||
if($('input[name=lib]').length == 0 && $('input[name=module]').length > 0)
|
||||
{
|
||||
let moduleID = $('input[name=module]').val();
|
||||
if(moduleID.indexOf('_') >= 0) libID = moduleID.substr(0, moduleID.indexOf('_'));
|
||||
}
|
||||
if(acl == 'private')
|
||||
{
|
||||
$('#whiteListBox').removeClass('hidden');
|
||||
$('#groupBox').removeClass('hidden');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#whiteListBox').addClass('hidden');
|
||||
$('#groupBox').addClass('hidden');
|
||||
}
|
||||
|
||||
if(type == 'lib')
|
||||
{
|
||||
if(libType == 'project' && typeof(doclibID) != 'undefined')
|
||||
{
|
||||
let link = $.createLink('doc', 'ajaxGetWhitelist', 'doclibID=' + doclibID + '&acl=' + acl);
|
||||
$.getJSON(link, function(users)
|
||||
{
|
||||
if(users != 'private' && users)
|
||||
{
|
||||
const $usersPicker = $('select[name^=users]').zui('picker');
|
||||
$usersPicker.render({items: users});
|
||||
$usersPicker.$.setValue('');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
else if(type == 'doc')
|
||||
{
|
||||
$('#whiteListBox').toggleClass('hidden', acl == 'open');
|
||||
$('#groupBox').toggleClass('hidden', acl == 'open');
|
||||
loadWhitelist(libID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load whitelist by libID.
|
||||
*
|
||||
* @param int $libID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
window.loadWhitelist = function(libID)
|
||||
{
|
||||
let groupLink = $.createLink('doc', 'ajaxGetWhitelist', 'libID=' + libID + '&acl=&control=group');
|
||||
let userLink = $.createLink('doc', 'ajaxGetWhitelist', 'libID=' + libID + '&acl=&control=user');
|
||||
$.getJSON(groupLink, function(groups)
|
||||
{
|
||||
if(groups != 'private' && groups)
|
||||
{
|
||||
groups = JSON.parse(groups);
|
||||
const $groupsPicker = $('select[name^=groups]').zui('picker');
|
||||
$groupsPicker.render({items: groups});
|
||||
$groupsPicker.$.setValue('');
|
||||
}
|
||||
});
|
||||
|
||||
$.getJSON(userLink, function(users)
|
||||
{
|
||||
if(users != 'private' && users)
|
||||
{
|
||||
const $usersPicker = $('select[name^=users]').zui('picker');
|
||||
$usersPicker.render({items: users});
|
||||
$usersPicker.$.setValue('');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
$(function()
|
||||
{
|
||||
toggleAcl('lib');
|
||||
})
|
||||
@@ -10,6 +10,8 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
jsVar('doclibID', $lib->id);
|
||||
jsVar('libType', $lib->type);
|
||||
modalHeader
|
||||
(
|
||||
set::title($lang->api->editLib),
|
||||
|
||||
Reference in New Issue
Block a user