<?page title="${labels.AgendaWorkgroups}" contentType="text/html;charset=UTF-8"?>
<zk>
	<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
	<window
		border="normal"
		apply="org.zkoss.bind.BindComposer"
		viewModel="@id('vm') @init('info.bukova.isspst.ui.workgroups.WorkgroupList')"
		vflex="1"
		hflex="1">
		<caption
			zclass="form-caption"
			label="${labels.AgendaWorkgroups}" />
		<include src="/app/toolbar.zul" />
		<hlayout vflex="1">
			<listbox
				model="@load(vm.dataList)"
				selectedItem="@bind(vm.dataBean)"
				hflex="1"
				vflex="1">
				<listhead menupopup="auto">
					<listheader
						label="${labels.code}"
						sort="czech(code)"
						hflex="10" />
					<listheader
						label="${labels.name}"
						sort="czech(name)"
						hflex="15" />
					<listheader
						label="${labels.centre}"
						hflex="5" />
				</listhead>
				<auxhead
					sclass="category-center"
					visible="@load(vm.filter)">
					<auxheader>
						<div sclass="find-grid-cell">
							<div sclass="find-grid-divtextbox">
								<textbox
									value="@bind(vm.filterTemplate.code)"
									instant="true"
									onChange="@command('doFilter')"
									sclass="find-grid-textbox" />
							</div>
							<div sclass="find-grid-img">
								<image src="/img/funnel.png" />
							</div>
						</div>
					</auxheader>
					<auxheader>
						<div sclass="find-grid-cell">
							<div sclass="find-grid-divtextbox">
								<textbox
									value="@bind(vm.filterTemplate.name)"
									instant="true"
									onChange="@command('doFilter')"
									sclass="find-grid-textbox" />
							</div>
							<div sclass="find-grid-img">
								<image src="/img/funnel.png" />
							</div>
						</div>
					</auxheader>
					<auxheader>
						<div sclass="find-grid-cell">
							<div sclass="find-grid-divtextbox">
								<checkbox
									label="${labels.centre}"
									checked="@bind(vm.filterTemplate.centre)"
									onClick="@command('doFilter')" />
							</div>
							<div sclass="find-grid-img">
								<image src="/img/funnel.png" />
							</div>
						</div>
					</auxheader>
				</auxhead>
				<template name="model">
					<listitem>
						<listcell label="@load(each.code)" />
						<listcell label="@load(each.name)" />
						<listcell label="@load(each.centre) @converter(vm.boolConverter)" />
					</listitem>
				</template>
			</listbox>
			<panel
				vflex="1"
				hflex="1">
				<panelchildren sclass="addScrollbar">
					<vbox
						vflex="1"
						hflex="1">
						<vbox children="@load(vm.workgroupRoles)">
							<template name="children">
								<grid
									model="@load(vm.dataBean.members)"
									visible="@load(each.authority ne 'ROLE_USER')">
									<columns>
										<column label="@load(each.description)" />
									</columns>
									<rows>
										<template
											name="model"
											var="member">
											<row visible="@load(member.role eq each)">
												<hbox>
													<image src="/img/user-small-red.png" />
													<label value="@load(member.member.fullName)" />
												</hbox>
											</row>
										</template>
									</rows>
								</grid>
							</template>
						</vbox>
						<groupbox
							mold="3d"
							closable="false"
							vflex="1"
							hflex="1">
							<caption label="${labels.members}" />
							<tree
								hflex="1"
								vflex="1"
								model="@load(vm.workgroupTreeModel)">
								<treecols>
									<treecol />
								</treecols>
								<template name="model">
									<treeitem>
										<treerow>
											<treecell
												image="@load(each.data.person ? '/img/user-small.png' : '/img/commission-small.png')"
												label="@load(each.data.fullName)" />
										</treerow>
									</treeitem>
								</template>
							</tree>
						</groupbox>
					</vbox>
				</panelchildren>
			</panel>
		</hlayout>
	</window>
</zk>