<?php $pageTitle='Usergroups';
$showCreateLink=session::canCreateUsergroups();
include realpath(__DIR__).'/../_common/header.php'; ?>
<script type="text/javascript">
window.addEventListener('DOMContentLoaded',function(){


    let headers = ['Name', 'Description'];
    let cellTemplates = ['<a href="/usergroup/{{id}}">{{name}}</a>', '{{description}}'];
    let showFilters=['name','description'];
    let sortOrders=['name','description'];
    if(isAdmin){
		headers=['Name','Description','Visibility','Membership','System','Create<br>Projects','Create<br>Groups'];
		cellTemplates=['<a href="/usergroup/{{id}}">{{name}}</a>','{{description}}','{{groupvisibility}}','{{membershipvisibility}}',[ui.checkmark,'issystem'],[ui.checkmark,'cancreateprojects'],[ui.checkmark,'cancreateusergroups'] ];
        showFilters=['name','description','','','','',''];
        sortOrders=['name','description','groupvisibility','membershipvisibility','','',''];
	}
	
	ui.grid().box({ 
		classes:'r1 c1 h3 w3',
		url:'/api/usergroup',
		headers:headers,
        showFilters:showFilters,
        sortOrders:sortOrders,
		cellTemplates:cellTemplates
	});


});
</script>
<?php include realpath(__DIR__).'/../_common/footer.php'; ?>