<?page title="${labels.AgendaWorkflow}" contentType="text/html;charset=UTF-8"?>
<zk>
<window border="normal" apply="org.zkoss.bind.BindComposer"
	viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.RequirementTypesVM')"
	vflex="1">
<caption zclass="form-caption" label="${labels.AgendaWorkflow}" />
<vbox>
	<hbox>
		<label value="${labels.RequirementType}"/>
		<combobox model="@load(vm.reqTypes)" readonly="true" width="300px" selectedItem="@bind(vm.selected)">
			<template name="model">
				<comboitem label="@load(each.description)"/>
			</template>
		</combobox>
	</hbox>
	<groupbox mold="3d">
	<caption label="${labels.Centres}"/>
		<vbox>
			<checkbox label="${labels.OfferSelectedOnly}"
				checked="@bind(vm.selected.limitCentres)"
				disabled="@load(empty vm.selected)" 
				onClick="@command('clearCentres')" />
			<button label="${labels.Select}"
				disabled="@load(empty vm.selected or not vm.selected.limitCentres)"
				onClick="@command('centresDialog')" 
				sclass="nicebutton"/>
			<hbox children="@load(vm.selected.offeredCentres)">
				<template name="children">
					<label value="@load(each.fullName.concat(', '))"/>
				</template>
			</hbox>
		</vbox>
	</groupbox>
	<hbox>
		<div hflex="1">
		<groupbox mold="3d" hflex="1">
		<caption label="${labels.AvailableRoles}"/>
			<vbox>
				<listbox id="allWgRoles" model="@load(vm.workgroupRoles)" droppable="workgroup" 
				onDrop="@command('removeRoleWg', event=event)">
					<listhead>
						<listheader label="${labels.WorkgroupRoles}"/>
					</listhead>
					<template name="model">
						<listitem label="@load(each.description)" draggable="workgroup" droppable="workgroup"
						onDrop="@command('removeRoleCentre', event=event)"/>
					</template>
				</listbox>
				<listbox id="allCentreRoles" model="@load(vm.centreRoles)" droppable="centre" 
				onDrop="@command('removeRoleCentre', event=event)">
					<listhead>
						<listheader label="${labels.CentreRoles }"/>
					</listhead>
					<template name="model">
						<listitem label="@load(each.description)" draggable="centre" droppable="centre"
						onDrop="@command('removeRoleCentre', event=event)"/>
					</template>
				</listbox>
			</vbox>
		</groupbox>
		</div>
		<div hflex="1">
		<groupbox mold="3d" visible="@load(not empty vm.selected)">
		<caption label="${labels.Workflow}"/>
			<vbox>
				<listbox id="wgWorkflow" model="@load(vm.selected.workflow)" droppable="workgroup"
				onDrop="@command('addRoleWg', event=event)"
				selectedItem="@bind(vm.wgSelWorkflow)">
					<listhead>
						<listheader label="${labels.WorkgroupWorkflow}"/>
					</listhead>
					<template name="model">
						<listitem label="@load(each.role.description)" visible="@load(not each.centre)"
						onDrop="@command('reorderWg', event=event)" draggable="workgroup" droppable="workgroup"
						context="limitPopUpWg"
						style="@load(empty each.limit ? '' : 'background-color: #e1fdd5')"
						tooltiptext="@load(empty each.limit ? '' : labels.Limit.concat(' ').concat(each.limit))"/>
					</template>
				</listbox>
				<listbox id="centreWorkflow" model="@load(vm.selected.workflow)" droppable="centre"
				onDrop="@command('addRoleCentre', event=event)"
				selectedItem="@bind(vm.centreSelWorkflow)">
					<listhead>
						<listheader label="${labels.CentreWorkflow}"/>
					</listhead>
					<template name="model">
						<listitem label="@load(each.role.description)" visible="@load(each.centre)"
						onDrop="@command('reorderCentre', event=event)" draggable="centre" droppable="centre"
						context="limitPopUp"
						style="@load(empty each.limit ? '' : 'background-color: #e1fdd5')"
						tooltiptext="@load(empty each.limit ? '' : labels.Limit.concat(' ').concat(each.limit))"/>
					</template>
				</listbox>
			</vbox>
		</groupbox>
		<menupopup id="limitPopUp">
			<menuitem label="${labels.OverLimit}" checkmark="true"
			checked="@load(not empty vm.centreSelWorkflow.limit)" 
			onClick="@command('overLimit', workflow=centreWorkflow.selectedItem.value)"/>
		</menupopup>
		<menupopup id="limitPopUpWg">
			<menuitem label="${labels.OverLimit}" checkmark="true"
			checked="@load(not empty vm.wgSelWorkflow.limit)" 
			onClick="@command('overLimit', workflow=wgWorkflow.selectedItem.value)"/>
		</menupopup>
		</div>
	</hbox>
</vbox>
</window>
</zk>