From 60accd156c49dcc772b91fe9015f3d842cb03601 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Sun, 31 Aug 2014 15:48:55 +0200 Subject: [PATCH] =?UTF-8?q?Umo=C5=BEn=C4=9Bno=20nastaven=C3=AD=20nab=C3=AD?= =?UTF-8?q?zen=C3=BDch=20st=C5=99edisek=20k=20typ=C5=AFm=20po=C5=BEadavk?= =?UTF-8?q?=C5=AF.=20refs=20#130?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bukova/isspst/data/RequirementType.java | 26 ++++++++++ .../ui/requirement/OfferedCentresVM.java | 49 +++++++++++++++++++ .../ui/requirement/RequirementTypesVM.java | 17 +++++++ .../WEB-INF/locales/zk-label.properties | 4 ++ .../settings/workflow/offeredCentres.zul | 19 +++++++ .../webapp/settings/workflow/workflow.zul | 18 +++++++ 6 files changed, 133 insertions(+) create mode 100644 src/main/java/info/bukova/isspst/ui/requirement/OfferedCentresVM.java create mode 100644 src/main/webapp/settings/workflow/offeredCentres.zul diff --git a/src/main/java/info/bukova/isspst/data/RequirementType.java b/src/main/java/info/bukova/isspst/data/RequirementType.java index ce5b3a88..af399193 100644 --- a/src/main/java/info/bukova/isspst/data/RequirementType.java +++ b/src/main/java/info/bukova/isspst/data/RequirementType.java @@ -6,6 +6,9 @@ import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.JoinTable; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToMany; import javax.persistence.OneToMany; import javax.persistence.OrderBy; import javax.persistence.Table; @@ -25,9 +28,16 @@ public class RequirementType extends BaseData { @LazyCollection(LazyCollectionOption.FALSE) @OrderBy("CENTRE, WORDER") private List workflow; + @Column(name = "LIMIT_CENTRES") + private Boolean limitCentres; + @ManyToMany + @LazyCollection(LazyCollectionOption.FALSE) + @JoinTable(name="REQUIREMENTTYPE_WORKGROUP", joinColumns={@JoinColumn(name="REQUIREMENTTYPE_ID")}, inverseJoinColumns={@JoinColumn(name="WORKGROUP_ID")}) + private List offeredCentres; public RequirementType() { workflow = new ArrayList(); + offeredCentres = new ArrayList(); } public RequirementType(String type, String description) { @@ -68,4 +78,20 @@ public class RequirementType extends BaseData { return false; } + public Boolean getLimitCentres() { + return limitCentres; + } + + public void setLimitCentres(Boolean limitCentres) { + this.limitCentres = limitCentres; + } + + public List getOfferedCentres() { + return offeredCentres; + } + + public void setOfferedCentres(List offeredCentres) { + this.offeredCentres = offeredCentres; + } + } diff --git a/src/main/java/info/bukova/isspst/ui/requirement/OfferedCentresVM.java b/src/main/java/info/bukova/isspst/ui/requirement/OfferedCentresVM.java new file mode 100644 index 00000000..0d6de93c --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/requirement/OfferedCentresVM.java @@ -0,0 +1,49 @@ +package info.bukova.isspst.ui.requirement; + +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; + +import info.bukova.isspst.data.RequirementType; +import info.bukova.isspst.data.Workgroup; +import info.bukova.isspst.services.workgroups.WorkgroupService; +import info.bukova.isspst.ui.ListChecks; + +public class OfferedCentresVM { + + private RequirementType selectedType; + @WireVariable + private WorkgroupService workgroupService; + private ListChecks wgChecks; + + @Init + public void init(@ExecutionArgParam("type") RequirementType type) { + this.selectedType = type; + wgChecks = new ListChecks(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 getWgChecks() { + return wgChecks; + } + +} diff --git a/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java b/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java index 597ecdd8..279b8e7d 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java @@ -242,6 +242,23 @@ public class RequirementTypesVM { public void refresh() { reqTypeService.update(selected); } + + @Command + public void centresDialog() { + Map param = new HashMap(); + param.put("type", selected); + Window win = (Window) Executions.createComponents("/settings/workflow/offeredCentres.zul", null, param); + win.doModal(); + } + + @Command + @NotifyChange("selected") + public void clearCentres() { + if (!selected.getLimitCentres()) { + selected.getOfferedCentres().clear(); + refresh(); + } + } public Workflow getWgSelWorkflow() { return wgSelWorkflow; diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 75dec75f..4a1f6f1b 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -137,6 +137,10 @@ CentreWorkflow=Schválení ve středisku LimitFormTitle=Limit pro schválení Limit=Limit: OverLimit=Pouze nadlimitní +Centres=Střediska +OfferSelectedOnly=Nabízet pouze vybraná střediska +Select=Vybrat +OfferedCentres=Nabízená střediska Number=Číslo: Prefix=Prefix: diff --git a/src/main/webapp/settings/workflow/offeredCentres.zul b/src/main/webapp/settings/workflow/offeredCentres.zul new file mode 100644 index 00000000..d3bbb96d --- /dev/null +++ b/src/main/webapp/settings/workflow/offeredCentres.zul @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/settings/workflow/workflow.zul b/src/main/webapp/settings/workflow/workflow.zul index 663b06bd..8dde8362 100644 --- a/src/main/webapp/settings/workflow/workflow.zul +++ b/src/main/webapp/settings/workflow/workflow.zul @@ -13,6 +13,24 @@ + + + + +