Commit c91a9d68 authored by michael.simon's avatar michael.simon
Browse files

reduce role handling to one view

parent 762ddd37
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean.admin.role;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import edu.kit.scc.webreg.entity.AdminRoleEntity;
import edu.kit.scc.webreg.service.AdminRoleService;
import edu.kit.scc.webreg.util.ViewIds;
@ManagedBean
@ViewScoped
public class EditAdminRoleBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private AdminRoleService service;
private AdminRoleEntity entity;
private Long id;
public void preRenderView(ComponentSystemEvent ev) {
if (entity == null) {
entity = service.findWithUsers(id);
}
}
public String save() {
entity = service.save(entity);
return ViewIds.SHOW_ADMIN_ROLE + "?faces-redirect=true&id=" + entity.getId();
}
public String cancel() {
return ViewIds.SHOW_ADMIN_ROLE + "?faces-redirect=true&id=" + entity.getId();
}
public AdminRoleEntity getEntity() {
return entity;
}
public void setEntity(AdminRoleEntity entity) {
this.entity = entity;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean.admin.role;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import edu.kit.scc.webreg.entity.ApproverRoleEntity;
import edu.kit.scc.webreg.service.ApproverRoleService;
import edu.kit.scc.webreg.util.ViewIds;
@ManagedBean
@ViewScoped
public class EditApproverRoleBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private ApproverRoleService service;
private ApproverRoleEntity entity;
private Long id;
public void preRenderView(ComponentSystemEvent ev) {
if (entity == null) {
entity = service.findWithUsers(id);
}
}
public String save() {
entity = service.save(entity);
return ViewIds.SHOW_APPROVER_ROLE + "?faces-redirect=true&id=" + entity.getId();
}
public String cancel() {
return ViewIds.SHOW_APPROVER_ROLE + "?faces-redirect=true&id=" + entity.getId();
}
public ApproverRoleEntity getEntity() {
return entity;
}
public void setEntity(ApproverRoleEntity entity) {
this.entity = entity;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean.admin.role;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import edu.kit.scc.webreg.entity.GroupAdminRoleEntity;
import edu.kit.scc.webreg.service.GroupAdminRoleService;
import edu.kit.scc.webreg.util.ViewIds;
@ManagedBean
@ViewScoped
public class EditGroupAdminRoleBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private GroupAdminRoleService service;
private GroupAdminRoleEntity entity;
private Long id;
public void preRenderView(ComponentSystemEvent ev) {
if (entity == null) {
entity = service.findWithUsers(id);
}
}
public String save() {
entity = service.save(entity);
return ViewIds.SHOW_GROUP_ADMIN_ROLE + "?faces-redirect=true&id=" + entity.getId();
}
public String cancel() {
return ViewIds.SHOW_GROUP_ADMIN_ROLE + "?faces-redirect=true&id=" + entity.getId();
}
public GroupAdminRoleEntity getEntity() {
return entity;
}
public void setEntity(GroupAdminRoleEntity entity) {
this.entity = entity;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean.admin.role;
import java.io.Serializable;
import javax.enterprise.context.RequestScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import javax.inject.Named;
import edu.kit.scc.webreg.entity.AdminRoleEntity;
import edu.kit.scc.webreg.service.AdminRoleService;
@Named("showAdminRoleBean")
@RequestScoped
public class ShowAdminRoleBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private AdminRoleService service;
private AdminRoleEntity entity;
private Long id;
public void preRenderView(ComponentSystemEvent ev) {
entity = service.findWithUsers(id);
}
public AdminRoleEntity getEntity() {
return entity;
}
public void setEntity(AdminRoleEntity entity) {
this.entity = entity;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean.admin.role;
import java.io.Serializable;
import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import javax.inject.Named;
import edu.kit.scc.webreg.entity.ApproverRoleEntity;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.service.ApproverRoleService;
@Named("showApproverRoleBean")
@RequestScoped
public class ShowApproverRoleBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private ApproverRoleService service;
private ApproverRoleEntity entity;
private List<UserEntity> userInRoleList;
private Long id;
public void preRenderView(ComponentSystemEvent ev) {
entity = service.findWithUsers(id);
}
public ApproverRoleEntity getEntity() {
return entity;
}
public void setEntity(ApproverRoleEntity entity) {
this.entity = entity;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public List<UserEntity> getUserInRoleList() {
return userInRoleList;
}
public void setUserInRoleList(List<UserEntity> userInRoleList) {
this.userInRoleList = userInRoleList;
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.bean.admin.role;
import java.io.Serializable;
import javax.enterprise.context.RequestScoped;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import javax.inject.Named;
import edu.kit.scc.webreg.entity.GroupAdminRoleEntity;
import edu.kit.scc.webreg.service.GroupAdminRoleService;
@Named("showGroupAdminRoleBean")
@RequestScoped
public class ShowGroupAdminRoleBean implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
private GroupAdminRoleService service;
private GroupAdminRoleEntity entity;
private Long id;
public void preRenderView(ComponentSystemEvent ev) {
entity = service.findWithUsers(id);
}
public GroupAdminRoleEntity getEntity() {
return entity;
}
public void setEntity(GroupAdminRoleEntity entity) {
this.entity = entity;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
......@@ -7,10 +7,11 @@
<c:set var="id" value="#{not empty id ? id : label}" />
<c:set var="required" value="#{not empty required and required}" />
<c:set var="rendered" value="#{not empty rendered ? rendered : true}" />
<p:outputLabel for="#{id}" value="#{label}" />
<p:outputLabel for="#{id}" value="#{label}" rendered="#{rendered}"/>
<h:panelGroup>
<p:inputText id="#{id}" size="50" value="#{value}" label="#{label}" required="#{required}">
<p:inputText id="#{id}" size="50" value="#{value}" label="#{label}" required="#{required}" rendered="#{rendered}">
<f:ajax event="blur" execute="@this" render="#{id}-message" />
</p:inputText>
<p:message id="#{id}-message" for="#{id}" />
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:bw="http://www.scc.kit.edu/bwfacelets"
xmlns:p="http://primefaces.org/ui">
<head>
<title></title>
</head>
<body>
<f:view>
<f:metadata>
<f:viewParam name="id" value="#{editAdminRoleBean.id}"/>
<f:event type="javax.faces.event.PreRenderViewEvent"
listener="#{editAdminRoleBean.preRenderView}" />
</f:metadata>
<ui:composition template="/template/default-admin.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h:form id="form">
<h2><h:outputText value="#{messages.role}: #{editAdminRoleBean.entity.name}"/></h2>
<div id="panelInline">
<p:panel header="#{messages.role}">
<p:panelGrid id="baseData" columns="2">
<h:outputText value="#{messages.id}:" />
<h:outputText value="#{editAdminRoleBean.entity.id}" />
<bw:inputText id="nameField" label="#{messages.name}"
value="#{editAdminRoleBean.entity.name}" required="true" />
</p:panelGrid>
<p:commandButton id="save" action="#{editAdminRoleBean.save}" value="#{messages.save}"/>
<p:commandButton id="cancel" action="#{editAdminRoleBean.cancel}" value="#{messages.cancel}" immediate="true"/>
</p:panel>
</div>
</h:form>
</ui:define>
</ui:composition>
</f:view>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:bw="http://www.scc.kit.edu/bwfacelets"
xmlns:p="http://primefaces.org/ui">
<head>
<title></title>
</head>
<body>
<f:view>
<f:metadata>
<f:viewParam name="id" value="#{editApproverRoleBean.id}"/>
<f:event type="javax.faces.event.PreRenderViewEvent"
listener="#{editApproverRoleBean.preRenderView}" />
</f:metadata>
<ui:composition template="/template/default-admin.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h:form id="form">
<h2><h:outputText value="#{messages.role}: #{editApproverRoleBean.entity.name}"/></h2>
<div id="panelInline">
<p:panel header="#{messages.role}">
<p:panelGrid id="baseData" columns="2">
<h:outputText value="#{messages.id}:" />
<h:outputText value="#{editApproverRoleBean.entity.id}" />
<bw:inputText id="nameField" label="#{messages.name}"
value="#{editApproverRoleBean.entity.name}" required="true" />
<bw:inputText id="approvalBeanField"
label="#{messages.approval_bean}"
value="#{editApproverRoleBean.entity.approvalBean}"
required="true" />
</p:panelGrid>
<p:commandButton id="save" action="#{editApproverRoleBean.save}" value="#{messages.save}"/>
<p:commandButton id="cancel" action="#{editApproverRoleBean.cancel}" value="#{messages.cancel}" immediate="true"/>
</p:panel>
</div>
</h:form>
</ui:define>
</ui:composition>
</f:view>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:bw="http://www.scc.kit.edu/bwfacelets"
xmlns:p="http://primefaces.org/ui">
<head>
<title></title>
</head>
<body>
<f:view>
<f:metadata>
<f:viewParam name="id" value="#{editGroupAdminRoleBean.id}"/>
<f:event type="javax.faces.event.PreRenderViewEvent"
listener="#{editGroupAdminRoleBean.preRenderView}" />
</f:metadata>
<ui:composition template="/template/default-admin.xhtml">
<ui:param name="title" value="#{messages.title}"/>
<ui:define name="content">
<h:form id="form">
<h2><h:outputText value="#{messages.role}: #{editGroupAdminRoleBean.entity.name}"/></h2>
<div id="panelInline">
<p:panel header="#{messages.role}">
<p:panelGrid id="baseData" columns="2">
<h:outputText value="#{messages.id}:" />
<h:outputText value="#{editGroupAdminRoleBean.entity.id}" />
<bw:inputText id="nameField" label="#{messages.name}"
value="#{editGroupAdminRoleBean.entity.name}" required="true" />
</p:panelGrid>
<p:commandButton id="save" action="#{editGroupAdminRoleBean.save}" value="#{messages.save}"/>
<p:commandButton id="cancel" action="#{editGroupAdminRoleBean.cancel}" value="#{messages.cancel}" immediate="true"/>
</p:panel>
</div>
</h:form>
</ui:define>
</ui:composition>
</f:view>
</body>
</html>
......@@ -34,6 +34,12 @@
<bw:inputText id="nameField" label="#{messages.name}"
value="#{editRoleBean.entity.name}" required="true" />
<bw:inputText id="approvalBeanField"
label="#{messages.approval_bean}"
value="#{editRoleBean.entity.approvalBean}"
rendered="#{editRoleBean.entity.class.simpleName == 'ApproverRoleEntity'}"
required="true" />
</p:panelGrid>
<p:commandButton id="save" action="#{editRoleBean.save}" value="#{messages.save}"/>
......
......@@ -28,20 +28,7 @@
<f:facet name="header">
<h:outputText value="#{messages.name}" />
</f:facet>
<h:link outcome="show-approver-role.xhtml" value="#{role.name}"
rendered="#{role.class.simpleName == 'ApproverRoleEntity'}">
<f:param name="id" value="#{role.id}"/>
</h:link>
<h:link outcome="show-admin-role.xhtml" value="#{role.name}"
rendered="#{role.class.simpleName == 'AdminRoleEntity'}">
<f:param name="id" value="#{role.id}"/>
</h:link>
<h:link outcome="show-group-admin-role.xhtml" value="#{role.name}"