From: <jbo...@li...> - 2006-05-16 20:46:09
|
Author: soh...@jb... Date: 2006-05-16 16:46:01 -0400 (Tue, 16 May 2006) New Revision: 4256 Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml Log: 1) http://jira.jboss.com/jira/browse/JBFORUMS-56 - Create New Forum 2) http://jira.jboss.com/jira/browse/JBFORUMS-63 - Move Up 3) http://jira.jboss.com/jira/browse/JBFORUMS-64 - Move Down 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-16 20:17:40 UTC (rev 4255) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-05-16 20:46:01 UTC (rev 4256) @@ -21,14 +21,12 @@ */ package org.jboss.portlet.forums.ui.action; +import java.util.Iterator; + import org.jboss.portlet.forums.ui.*; import org.jboss.portlet.forums.model.Category; import org.jboss.portlet.forums.model.Forum; -import org.jboss.portlet.forums.model.Topic; -import org.jboss.portlet.forums.model.Poll; -import org.jboss.portlet.forums.model.PollOption; -import org.jboss.portlet.forums.model.Poster; /** * @@ -38,6 +36,9 @@ */ public class AdminController extends ActionController { + private static final int up = -15; + private static final int down = 15; + /** * ui data associated with "Category" information * @@ -172,5 +173,137 @@ } } return navState; - } + } + + /** + * + * + */ + public String moveCategoryUp() + { + String navState = null; + try + { + //get the categoryId where this forum should be added + int categoryId = -1; + String cour = ForumUtil.getParameter(Constants.p_categoryId); + if(cour!=null && cour.trim().length()>0) + { + categoryId = Integer.parseInt(cour); + } + + Category category = BaseController.getForumsModule().findCategoryById(new Integer(categoryId)); + category.setOrder(category.getOrder() + AdminController.up); + Iterator categories = BaseController.getForumsModule().findCategories().iterator(); + for (int index = 10; categories.hasNext(); index += 10) + { + category = (Category)categories.next(); + category.setOrder(index); + } + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + return navState; + } + + /** + * + * + */ + public String moveCategoryDown() + { + String navState = null; + try + { + //get the categoryId where this forum should be added + int categoryId = -1; + String cour = ForumUtil.getParameter(Constants.p_categoryId); + if(cour!=null && cour.trim().length()>0) + { + categoryId = Integer.parseInt(cour); + } + + Category category = BaseController.getForumsModule().findCategoryById(new Integer(categoryId)); + category.setOrder(category.getOrder() + AdminController.down); + Iterator categories = BaseController.getForumsModule().findCategories().iterator(); + for (int index = 10; categories.hasNext(); index += 10) + { + category = (Category)categories.next(); + category.setOrder(index); + } + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + return navState; + } + + /** + * + * + */ + public String moveForumUp() + { + String navState = null; + try + { + //get the categoryId where this forum should be added + int forumId = -1; + String cour = ForumUtil.getParameter(Constants.p_forumId); + if(cour!=null && cour.trim().length()>0) + { + forumId = Integer.parseInt(cour); + } + + Forum forum = BaseController.getForumsModule().findForumById(new Integer(forumId)); + forum.setOrder(forum.getOrder() + AdminController.up); + Iterator forums = BaseController.getForumsModule().findForumsByCategoryId(forum.getCategory().getId()).iterator(); + for (int index = 10; forums.hasNext(); index += 10) + { + forum = (Forum)forums.next(); + forum.setOrder(index); + } + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + return navState; + } + + /** + * + * + */ + public String moveForumDown() + { + String navState = null; + try + { + //get the categoryId where this forum should be added + int forumId = -1; + String cour = ForumUtil.getParameter(Constants.p_forumId); + if(cour!=null && cour.trim().length()>0) + { + forumId = Integer.parseInt(cour); + } + + Forum forum = BaseController.getForumsModule().findForumById(new Integer(forumId)); + forum.setOrder(forum.getOrder() + AdminController.down); + Iterator forums = BaseController.getForumsModule().findForumsByCategoryId(forum.getCategory().getId()).iterator(); + for (int index = 10; forums.hasNext(); index += 10) + { + forum = (Forum)forums.next(); + forum.setOrder(index); + } + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + return navState; + } } 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-16 20:17:40 UTC (rev 4255) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml 2006-05-16 20:46:01 UTC (rev 4256) @@ -68,8 +68,16 @@ </td> <td class="cat" align="center" valign="middle" nowrap="nowrap"> <span class="gen"> - <a href="">${resource.Move_up}</a> - <a href="">${resource.Move_down}</a> + <h:form> + <input type="hidden" name="c" value="#{category.id}"/> + <h:commandLink action="#{adminController.moveCategoryUp}"> + <h:outputText value="${resource.Move_up}"/> + </h:commandLink> + &nbsp;&nbsp;&nbsp; + <h:commandLink action="#{adminController.moveCategoryDown}"> + <h:outputText value="${resource.Move_down}"/> + </h:commandLink> + </h:form> </span> </td> <td class="catRight" align="center" valign="middle"> @@ -103,9 +111,16 @@ </td> <td class="row1" align="center" valign="middle"> <span class="gen"> - <a href="">${resource.Move_up}</a> - <br/> - <a href="">${resource.Move_down}</a> + <h:form> + <input type="hidden" name="f" value="#{forum.id}"/> + <h:commandLink action="#{adminController.moveForumUp}"> + <h:outputText value="${resource.Move_up}"/> + </h:commandLink> + &nbsp;&nbsp;&nbsp; + <h:commandLink action="#{adminController.moveForumDown}"> + <h:outputText value="${resource.Move_down}"/> + </h:commandLink> + </h:form> </span> </td> <td class="row2" align="center" valign="middle"> |