package info.bukova.isspst.ui.requirement;

import info.bukova.isspst.data.RequirementType;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.workgroups.WorkgroupService;
import info.bukova.isspst.ui.DocumentViewModel;
import info.bukova.isspst.ui.ListChecks;

import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ExecutionArgParam;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Window;

public class OfferedCentresVM extends DocumentViewModel
{
	private RequirementType selectedType;
	@WireVariable
	private WorkgroupService workgroupService;
	private ListChecks<Workgroup> wgChecks;
	
	@Init(superclass = true)
	public void init(@ExecutionArgParam("type") RequirementType type) {
		this.selectedType = type;
		wgChecks = new ListChecks<Workgroup>(selectedType.getOfferedCentres(), workgroupService.getCentres());
	}

	@Command
	public void save(@BindingParam("window") Window window) {
		window.detach();
	}
	
	public boolean isCanSave() {
		return true;
	}
	
	public RequirementType getSelectedType() {
		return selectedType;
	}

	public void setSelectedType(RequirementType selectedType) {
		this.selectedType = selectedType;
	}

	public ListChecks<Workgroup> getWgChecks() {
		return wgChecks;
	}

}
