<?page title="${labels.RightsFormTitle}" contentType="text/html;charset=UTF-8"?>
<zk>
<window id="editWin" border="normal" 
	closable="true" 
	width="750px" 
	apply="org.zkoss.bind.BindComposer"
	viewModel="@id('vm') @init('info.bukova.isspst.ui.users.PermissionForm')"
	height="100%">
	<caption zclass="form-caption" label="${labels.AgendaRights}" />
	<label value="@load(vm.dataBean.description)" style="font-weight: bold;"/>
	<hbox>
		<checkbox label="${labels.WorkgroupFunction}"
			checked="@bind(vm.dataBean.workgroup)"
			disabled="@load(not vm.canChangeWorkgroup or vm.inWorkflow)"
			tooltip="@load((not vm.canChangeWorkgroup or vm.inWorkflow) ? 'wgUsage' : '')" />
		<checkbox label="${labels.CentreFunction}"
			checked="@bind(vm.dataBean.centre)"
			disabled="@load(not vm.canChangeCentre or vm.inWorkflow)"
			tooltip="@load((not vm.canChangeCentre or vm.inWorkflow) ? 'wgUsage' : '')" />
	</hbox>
	
	<popup id="wgUsage">
		<vbox>
			<label value="${labels.PermissionFormUsedIn}" style="font-weight: bold;"/>
			<vbox children="@load(vm.usage)">
				<template name="children">
					<label value="@load(each)"/>
				</template>				
			</vbox>
		</vbox>
	</popup>
	
	<panel vflex="1">
		<panelchildren style="overflow:auto;">
			<vbox children="@load(vm.modules)" width="705px">
				<template name="children" var="module">
					<groupbox closable="false" mold="3d" width="705px">
						<caption label="@load(module.name)"/>
						<hbox children="@load(vm.rolePerms.permissionChecks)">
							<template name="children" var="perm">
								<checkbox label="@load(perm.permission.description)"  checked="@bind(perm.checked)" visible="@load(perm.permission.module eq module.id)" disabled="@load(vm.dataBean.authority eq 'ROLE_ADMIN')" />
							</template>
						</hbox>
					</groupbox>
				</template>
			</vbox>	
		</panelchildren>
	</panel>
	
	<include src="/app/formButtons.zul"/>
</window>
</zk>