<?page title="${labels.WorkgroupFormTitle}" contentType="text/html;charset=UTF-8"?>
<zk>
	<window id="editWin" closable="true" border="normal" position="center" apply="org.zkoss.bind.BindComposer" 
		viewModel="@id('vm') @init('info.bukova.isspst.ui.workgroups.WorkgroupForm')">
		<caption src="/img/commission.png" zclass="form-caption" label="${labels.WorkgroupFormTitle}" />
		<vlayout>
			<grid hflex="min">
				<columns>
					<column align="right" hflex="min" />
					<column />
				</columns>
				<rows>
					<row>
						<cell sclass="row-title">${labels.code} :</cell>
						<cell>
							<textbox
								id="code"
								constraint="@load(vm.constriant)"
								width="200px"
								maxlength="@load(vm.lengthText)"
								value="@bind(vm.dataBean.code)" />
						</cell>
					</row>
					<row>
						<cell sclass="row-title">${labels.name} :</cell>
						<cell>
							<textbox
								id="name"
								width="200px"
								maxlength="@load(vm.lengthText)"
								value="@bind(vm.dataBean.name)" />
						</cell>
					</row>
					<row>
						<cell>
							<checkbox label="Středisko" checked="@bind(vm.centre)" disabled="@load(not empty vm.dataBean.created)"/>
						</cell>
					</row>
					<row>
						<cell sclass="row-title">${labels.WorkgroupFormOrderLimit} :</cell>
						<cell>
							<textbox
								id="limit"
								width="200px"
								value="@bind(vm.dataBean.limit) @converter(vm.bdConverter)"
								maxlength="@load(vm.lengthText)"
								disabled="@load(vm.centre)" />
						</cell>
					</row>
				</rows>
			</grid>
			<label value="Přetáhněte myší:"/>
			<hlayout>
				<vbox>
					<textbox
						value="@bind(vm.findUser)"
						onChange="@command('find')"
						instant="true"
						maxlength="@load(vm.lengthText)"
						width="300px" />
					<listbox id="users" model="@bind(vm.users)" height="380px" width="300px" multiple="true"
						droppable="true" onDrop="@command('addMember', event=event)" selectedItems="@bind(vm.selectedUsers)">
						<listhead>
							<listheader label="Uživatelé" sort="czech(fullName)"/>
						</listhead>
						<template name="model">
							<listitem image="@load(each.person ? '/img/user-small.png' : '/img/commission-small.png')" label="@load(each.fullName)" draggable="user" droppable="user"
							onDrop="@command('addMember', event=event)" attributes.item="@load(each)"/>
						</template>
					</listbox>
				</vbox>
				
				<tabbox mold="accordion" width="300px">
					<tabs children="@load(vm.workgroupRoles)">
						<template name="children">
							<tab label="@load(each.authority eq 'ROLE_USER' ? 'Členové' : each.description)" />
						</template>
					</tabs>
					<tabpanels children="@load(vm.workgroupRoles)">
						<template name="children">
							<tabpanel>
								<listbox id="@load(each.authority)"
									model="@bind(vm.dataBean.members)" height="200px" width="290px"
									multiple="true" droppable="true"
									onDrop="@command('addMember', event=event)">
									<!-- <listhead>
										<listheader label="@load(each.description)" sort="czech(fullName)"/>
										</listhead>  -->
									<template name="model" var="member">
										<listitem
											image="@load(member.member.person ? '/img/user-small.png' : '/img/commission-small.png')"
											label="@load(member.member.fullName)" draggable="user"
											droppable="user" onDrop="@command('addMember', event=event)"
											attributes.item="@load(member)"
											visible="@load(member.role.authority eq each.authority)" />
									</template>
								</listbox>
							</tabpanel>
						</template>
					</tabpanels>
				</tabbox>
				
				<!-- 
				<vlayout children="@load(vm.workgroupRoles)">
					<template name="children">
						<listbox id="@load(each.authority)" model="@bind(vm.dataBean.members)" height="120px" width="200px" multiple="true" 
						droppable="true" onDrop="@command('addMember', event=event)">
						<listhead>
							<listheader label="@load(each.description)" sort="czech(fullName)"/>
						</listhead>
						<template name="model" var="member">
							<listitem image="@load(member.member.person ? '/img/user-small.png' : '/img/commission-small.png')" label="@load(member.member.fullName)" draggable="user" droppable="user"
							onDrop="@command('addMember', event=event)" attributes.item="@load(member)" visible="@load(member.role.authority eq each.authority)"/>
						</template>
					</listbox>	
					</template>
				
				</vlayout>
				 -->
			</hlayout>
			<include src="/app/formButtons.zul" />
		</vlayout>	
	</window>
</zk>