From: <jbo...@li...> - 2006-05-24 17:39:54
|
Author: soh...@jb... Date: 2006-05-24 13:39:43 -0400 (Wed, 24 May 2006) New Revision: 4407 Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/deleteCategory.xhtml Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/editForum.xhtml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml Log: http://jira.jboss.com/jira/browse/JBFORUMS-59 - Delete Category Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-24 15:47:52 UTC (rev 4406) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-24 17:39:43 UTC (rev 4407) @@ -39,6 +39,7 @@ public static final String FEEDBACK = "feedback"; public static final String EDIT_CATEGORY = "editCategory"; public static final String EDIT_FORUM = "editForum"; + public static final String DELETE_CATEGORY = "deleteCategory"; //---------parameter constants-------------------------------------------------------------------------------------------------- public static final String p_categoryId = "c"; public static final String p_forumId = "f"; Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-05-24 15:47:52 UTC (rev 4406) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-05-24 17:39:43 UTC (rev 4407) @@ -52,7 +52,11 @@ */ private String forumName = null; private String forumDescription = null; - private int forumCategory = 0; + + /** + * ui data associated with selecting a category to perform a certain operation + */ + private int selectedCategory = 0; //-----ui data------------------------------------------------------------------------------------------------------------------------- /** * @return Returns the categoryName. @@ -100,18 +104,29 @@ * * */ - public int getForumCategory() + public int getSelectedCategory() { - return this.forumCategory; + return this.selectedCategory; } /** * * */ - public void setForumCategory(int forumCategory) + public void setSelectedCategory(int selectedCategory) { - this.forumCategory = forumCategory; + this.selectedCategory = selectedCategory; } + //cleanup related---------------------------------------------------------------------------------------------------------------------- + /** + * + */ + public void cleanup() + { + this.categoryName = null; + this.forumName = null; + this.forumDescription = null; + this.selectedCategory = 0; + } //------------------------------------------------------------------------------------------------------------------------------------- /** * @@ -148,7 +163,7 @@ Forum forum = BaseController.getForumsModule().findForumById(new Integer(forumId)); this.forumName = forum.getName(); this.forumDescription = forum.getDescription(); - this.forumCategory = forum.getCategory().getId().intValue(); + this.selectedCategory = forum.getCategory().getId().intValue(); } } catch(Exception e) @@ -181,7 +196,7 @@ if(success) { //cleanup the state - this.categoryName = null; + this.cleanup(); } } return navState; @@ -221,13 +236,59 @@ if(success) { //cleanup the state - this.categoryName = null; + this.cleanup(); } } return navState; } /** + * + * + */ + public String deleteCategory() + { + String navState = null; + boolean success = false; + try + { + int categoryId = -1; + String cour = ForumUtil.getParameter(Constants.p_categoryId); + if(cour!=null && cour.trim().length()>0) + { + categoryId = Integer.parseInt(cour); + } + + //grab the category from the module and set the title + Category source = BaseController.getForumsModule().findCategoryById(new Integer(categoryId)); + Category target = BaseController.getForumsModule().findCategoryById(new Integer(this.selectedCategory)); + + //move all the forums from source category to the selected target category + BaseController.getForumsModule().addAllForums(source,target); + + //remove the source category + BaseController.getForumsModule().removeCategory(source); + + JSFUtil.setMessage(Constants.FEEDBACK,"The Category \""+this.categoryName+"\" was successfully deleted."); + navState = Constants.DELETE_CATEGORY; + success = true; + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + finally + { + if(success) + { + //cleanup the state + this.cleanup(); + } + } + return navState; + } + + /** * adds a new forum * */ @@ -261,8 +322,7 @@ if(success) { //cleanup the state - this.forumName = null; - this.forumDescription = null; + this.cleanup(); } } return navState; @@ -287,7 +347,7 @@ //grab the forum from the module and set the proper information Forum forum = getForumsModule().findForumById(new Integer(forumId)); - Category selectedCategory = getForumsModule().findCategoryById(new Integer(this.forumCategory)); + Category selectedCategory = getForumsModule().findCategoryById(new Integer(this.selectedCategory)); forum.setCategory(selectedCategory); forum.setName(this.forumName); forum.setDescription(this.forumDescription); @@ -305,9 +365,7 @@ if(success) { //cleanup the state - this.forumName = null; - this.forumDescription = null; - this.forumCategory = 0; + this.cleanup(); } } return navState; Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2006-05-24 15:47:52 UTC (rev 4406) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2006-05-24 17:39:43 UTC (rev 4407) @@ -2347,3 +2347,5 @@ Message_code=Code Message_quote=Quote Message_wrote=wrote + +Category_delete=Delete Category Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-24 15:47:52 UTC (rev 4406) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-24 17:39:43 UTC (rev 4407) @@ -367,6 +367,13 @@ </navigation-case> </navigation-rule> <navigation-rule> + <from-view-id>/views/admin/deleteCategory.xhtml</from-view-id> + <navigation-case> + <from-outcome>deleteCategory</from-outcome> + <to-view-id>/views/admin/index.xhtml</to-view-id> + </navigation-case> + </navigation-rule> + <navigation-rule> <from-view-id>/views/admin/editForum.xhtml</from-view-id> <navigation-case> <from-outcome>editForum</from-outcome> Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/deleteCategory.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/deleteCategory.xhtml 2006-05-24 15:47:52 UTC (rev 4406) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/deleteCategory.xhtml 2006-05-24 17:39:43 UTC (rev 4407) @@ -0,0 +1,83 @@ +<!-- +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +--> + +<div xmlns="http://www.w3.org/1999/xhtml" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:c="http://java.sun.com/jstl/core" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:forums="http://www.jboss.com/products/jbossportal/forums" class="bb"> + + <ui:composition template="/views/common/common.xhtml"> + <ui:define name="mainContent"> + + <h1>${resource.Category_delete}</h1> + + <p>${resource.Forum_delete_explain}</p> + + <!-- display the delete category widget --> + <h:form> + <input type="hidden" name="c" value="#{param['c']}"/> + <table cellpadding="4" cellspacing="1" border="0" class="forumline" align="center"> + <tr> + <th colspan="2" class="thHead">${resource.Category_delete}</th> + </tr> + <tr> + <td class="row1">${resource.Category}</td> + <td class="row1"><span class="row1">#{adminController.categoryName}</span></td> + </tr> + <tr> + <td class="row1">${resource.Move_contents} to - </td> + <td class="row1"> + <h:selectOneMenu value="#{adminController.selectedCategory}"> + <c:forEach items="#{adminPanel.categories}" var="category"> + <c:if test="#{category.id != param['c']}"> + <f:selectItem itemValue="#{category.id}" itemLabel="#{category.title}" /> + </c:if> + </c:forEach> + </h:selectOneMenu> + </td> + </tr> + <tr> + <td class="catBottom" colspan="2" align="center"> + <h:commandButton value="Submit" styleClass="mainoption" action="#{adminController.deleteCategory}"/> + </td> + </tr> + </table> + </h:form> + + + + <!-- integrate the jump box --> + <table cellspacing="0" cellpadding="0" border="0" align="right"> + <tr> + <td align="right" valign="top" nowrap="nowrap"> + <ui:include src="/views/jumpbox.xhtml"/> + </td> + </tr> + </table> + + </ui:define> + </ui:composition> +</div> \ No newline at end of file Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/editForum.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/editForum.xhtml 2006-05-24 15:47:52 UTC (rev 4406) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/editForum.xhtml 2006-05-24 17:39:43 UTC (rev 4407) @@ -60,7 +60,7 @@ <tr> <td class="row1">${resource.Category}</td> <td class="row2"> - <h:selectOneMenu value="#{adminController.forumCategory}"> + <h:selectOneMenu value="#{adminController.selectedCategory}"> <c:forEach items="#{adminPanel.categories}" var="category"> <f:selectItem itemValue="#{category.id}" itemLabel="#{category.title}" /> </c:forEach> @@ -68,7 +68,7 @@ </td> </tr> <tr> - <td class="catBottom" colspan="2" align="center"><input type="hidden" name="mode" value="modforum"/> + <td class="catBottom" colspan="2" align="center"> <h:commandButton value="Update" styleClass="mainoption" action="#{adminController.editForum}"/> </td> </tr> Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml 2006-05-24 15:47:52 UTC (rev 4406) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml 2006-05-24 17:39:43 UTC (rev 4407) @@ -68,9 +68,15 @@ </forums:isAllowed> </td> <td class="cat" align="center" valign="middle"> - <span class="gen"> - <a href="">${resource.Delete}</a> - </span> + <!-- security check to make sure this link should be displayed or not --> + <forums:isAllowed fragment="acl://deleteCategory/deleteLink" contextData="#{category}"> + <span class="gen"> + <h:outputLink value="#{forums:outputLink('/views/admin/deleteCategory.jsf',true)}"> + <f:param name="c" value="#{category.id}"/> + <h:outputText value="${resource.Delete}"/> + </h:outputLink> + </span> + </forums:isAllowed> </td> <td class="cat" align="center" valign="middle" nowrap="nowrap"> <span class="gen"> |