Do agendy Budovy byl přidán položkový grid pro definici místností.

closes #95
multitenant
Josef Rokos 11 years ago
parent dd369c5186
commit 8c204e0d7a

@ -1,9 +1,16 @@
package info.bukova.isspst.data;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.validator.constraints.NotBlank;
@Entity
@ -18,6 +25,14 @@ public class Building extends BaseData implements DataModel {
@Column(name = "DESCRIPTION")
private String description;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "building", orphanRemoval = true)
@LazyCollection(LazyCollectionOption.FALSE)
private List<Room> rooms;
public Building() {
rooms = new ArrayList<Room>();
}
/**
* @return the code
@ -64,4 +79,22 @@ public class Building extends BaseData implements DataModel {
public void setDescription(String description) {
this.description = description;
}
public List<Room> getRooms() {
return rooms;
}
public void setRooms(List<Room> rooms) {
this.rooms = rooms;
}
public void addRoom(Room room) {
room.setBuilding(this);
rooms.add(room);
}
public void removeRoom(Room room) {
rooms.remove(room);
}
}

@ -0,0 +1,94 @@
package info.bukova.isspst.data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "ROOM")
public class Room {
@Id
@Column(name = "ID")
@GeneratedValue
private int id;
@Column(name = "CODE")
private String code;
@Column(name = "SHORTCUT")
private String shortcut;
@Column(name = "NAME")
private String name;
@Column(name = "FLOOR")
private Integer floor;
@Column(name = "NUMBER")
private Integer number;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "BUILDING_ID")
private Building building;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getShortcut() {
return shortcut;
}
public void setShortcut(String shortcut) {
this.shortcut = shortcut;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getFloor() {
return floor;
}
public void setFloor(Integer floor) {
this.floor = floor;
}
public Integer getNumber() {
return number;
}
public void setNumber(Integer number) {
this.number = number;
}
public Building getBuilding() {
return building;
}
public void setBuilding(Building building) {
this.building = building;
}
public boolean equals(Object o) {
return ((o instanceof Room) && (((Room)o).getId() == this.getId()));
}
}

@ -1,9 +1,13 @@
package info.bukova.isspst.ui.buildings;
import info.bukova.isspst.data.Building;
import info.bukova.isspst.data.Room;
import info.bukova.isspst.ui.FormViewModel;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
public class BuildingForm extends FormViewModel<Building> {
@ -11,5 +15,18 @@ public class BuildingForm extends FormViewModel<Building> {
public void init() {
}
@Command
@NotifyChange("dataBean")
public void addRoom() {
Room r = new Room();
getDataBean().addRoom(r);
}
@Command
@NotifyChange("dataBean")
public void removeRoom(@BindingParam("room") Room room) {
getDataBean().getRooms().remove(room);
}
}

@ -11,6 +11,7 @@
<mapping class="info.bukova.isspst.data.BaseData"></mapping>
<mapping class="info.bukova.isspst.data.Address"></mapping>
<mapping class="info.bukova.isspst.data.Building"></mapping>
<mapping class="info.bukova.isspst.data.Room"></mapping>
<mapping class="info.bukova.isspst.data.MUnit"></mapping>
<mapping class="info.bukova.isspst.data.Material"></mapping>
<mapping class="info.bukova.isspst.data.Workgroup"></mapping>

@ -23,6 +23,11 @@ zipCode=PSČ
#Budova
code=Kód
name=Název
rooms=Místnosti
#Místnost
shortcut=Zkratka
number=Číslo
floor=Podlaží
#Uživatel
accountNonExpired=Platný

@ -39,9 +39,13 @@ BuildingsFormTitle=Budova
BuildingsFormCode=Kód
BuildingsFormName=Název
BuildingsFormDescription=Popis
BuildingsFormAddRoom=Přidat místnost
BuildingsFormRemove=Odstranit
BuildingsGridColumnCode=Kód
BuildingsGridColumnName=Název
BuildingsGridColumnDescription=Popis
BuildingsGridRooms=Místnosti:
AgendaRooms=Místnosti

@ -33,7 +33,7 @@
<menuitem label="${labels.AgendaServices}" href="/lists/service" disabled="${not sec:isAllGranted('PERM_READ_SERVICES')}"/>
<menuitem label="${labels.AgendaMUnits}" href="/lists/munits" disabled="${not sec:isAllGranted('PERM_READ_MUNITS')}" width="120px"/>
<menuitem label="${labels.AgendaBuildings}" href="/lists/buildings" disabled="${not sec:isAllGranted('PERM_READ_BUILDINGS')}" />
<menuitem label="${labels.AgendaRooms}" href="/lists/rooms" disabled="${not sec:isAllGranted('PERM_READ_ROOMS')}" />
<!-- <menuitem label="${labels.AgendaRooms}" href="/lists/rooms" disabled="${not sec:isAllGranted('PERM_READ_ROOMS')}" /> -->
</menubar>
</tabpanel>
<tabpanel>

@ -5,54 +5,79 @@
<caption zclass="form-caption" label="${labels.AgendaBuildings}" />
<include src="/app/toolbar.zul" />
<listbox model="@load(vm.dataList)" selectedItem="@bind(vm.dataBean)">
<listhead menupopup="auto">
<listheader label="${labels.BuildingsGridColumnCode}" sort="czech(code)" width="10%" />
<listheader label="${labels.BuildingsGridColumnName}" sort="czech(name)" width="30%" />
<listheader label="${labels.BuildingsGridColumnDescription}" sort="czech(description)" width="60%" />
</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" />
<hbox width="100%">
<listbox model="@load(vm.dataList)" selectedItem="@bind(vm.dataBean)" hflex="4">
<listhead menupopup="auto">
<listheader label="${labels.BuildingsGridColumnCode}" sort="czech(code)" width="10%" />
<listheader label="${labels.BuildingsGridColumnName}" sort="czech(name)" width="30%" />
<listheader label="${labels.BuildingsGridColumnDescription}" sort="czech(description)" width="60%" />
</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>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</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>
</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" />
</auxheader>
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<textbox value="@bind(vm.filterTemplate.description)" instant="true" onChange="@command('doFilter')" sclass="find-grid-textbox" />
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</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.description)" instant="true" onChange="@command('doFilter')" sclass="find-grid-textbox" />
</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.description)" />
</listitem>
</template>
</listbox>
</auxheader>
</auxhead>
<template name="model">
<listitem>
<listcell label="@load(each.code)" />
<listcell label="@load(each.name)" />
<listcell label="@load(each.description)" />
</listitem>
</template>
</listbox>
<vbox>
<label value="${labels.BuildingsGridRooms}"/>
<grid model="@load(vm.dataBean.rooms)" hflex="6">
<columns menupopup="auto">
<column label="${labels.code}"/>
<column label="${labels.name}"/>
<column label="${labels.shortcut}"/>
<column label="${labels.number}"/>
<column label="${labels.floor}"/>
</columns>
<rows>
<template name="model">
<row>
<label value="@bind(each.code)"/>
<label value="@bind(each.name)"/>
<label value="@bind(each.shortcut)"/>
<label value="@bind(each.number)"/>
<label value="@bind(each.floor)"/>
</row>
</template>
</rows>
</grid>
</vbox>
</hbox>
</window>
</zk>

@ -1,6 +1,7 @@
<?page title="${labels.BuildingsFormTitle}" 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.buildings.BuildingForm')">
<window id="editWin" closable="true" border="normal" position="center" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.buildings.BuildingForm')" width="750px">
<caption src="/img/building.png" zclass="form-caption" label="${labels.BuildingsFormTitle}" />
<vlayout>
<grid hflex="min">
@ -29,6 +30,27 @@
</row>
</rows>
</grid>
<button image="/img/item-add.png" label="${labels.BuildingsFormAddRoom}" onClick="@command('addRoom')"/>
<listbox model="@load(vm.dataBean.rooms)">
<listhead>
<listheader label="${labels.code}"/>
<listheader label="${labels.name}"/>
<listheader label="${labels.shortcut}"/>
<listheader label="${labels.number}"/>
<listheader label="${labels.floor}"/>
<listheader/>
</listhead>
<template name="model">
<listitem>
<listcell><textbox inplace="true" value="@bind(each.code)"/></listcell>
<listcell><textbox inplace="true" value="@bind(each.name)"/></listcell>
<listcell><textbox inplace="true" value="@bind(each.shortcut)"/></listcell>
<listcell><textbox inplace="true" value="@bind(each.number)"/></listcell>
<listcell><textbox inplace="true" value="@bind(each.floor)"/></listcell>
<listcell><button image="/img/item-remove.png" label="${labels.BuildingsFormRemove}" onClick="@command('removeRoom', room=each)"/></listcell>
</listitem>
</template>
</listbox>
<include src="/app/formButtons.zul" />
</vlayout>
</window>

Loading…
Cancel
Save