Author: soh...@jb... Date: 2006-05-09 13:01:41 -0400 (Tue, 09 May 2006) New Revision: 4159 Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/delete_poll.xhtml Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/EditPost.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/NewTopic.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PollController.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PostAction.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_edit_body.xhtml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml Log: http://jira.jboss.com/jira/browse/JBFORUMS-68 - Delete the poll on the topic Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/EditPost.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/EditPost.java 2006-05-09 16:29:16 UTC (rev 4158) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/EditPost.java 2006-05-09 17:01:41 UTC (rev 4159) @@ -120,6 +120,31 @@ * * */ + public String deletePoll() + { + String navState = null; + try + { + //cleanout poll related data from this controller + this.question = null; + this.options = new ArrayList(); + this.activeDuration = 0; + + navState = Constants.SUCCESS; + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + + return navState; + } + + + /** + * + * + */ public String execute() { String navState = null; Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/NewTopic.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/NewTopic.java 2006-05-09 16:29:16 UTC (rev 4158) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/NewTopic.java 2006-05-09 17:01:41 UTC (rev 4159) @@ -88,14 +88,7 @@ this.forumId = forumId; //get the poll title if one was specified - this.question = ForumUtil.getParameter(Constants.p_poll_title); - - //set the proper poll delete activation status - String activatePollDel = ForumUtil.getParameter(Constants.p_poll_delete); - if(activatePollDel!=null && activatePollDel.trim().length()>0) - { - this.deletePollActivated = true; - } + this.question = ForumUtil.getParameter(Constants.p_poll_title); } navState = Constants.START_NEW_TOPIC; Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PollController.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PollController.java 2006-05-09 16:29:16 UTC (rev 4158) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PollController.java 2006-05-09 17:01:41 UTC (rev 4159) @@ -71,8 +71,7 @@ //dont process a vote return null; } - - + Topic topic = this.getForumsModule().findTopicById(new Integer(topicId)); Poll poll = topic.getPoll(); PollOption selectedOption = (PollOption)poll.getOptions().get(voteIndex); @@ -91,5 +90,5 @@ JSFUtil.handleException(e); } return navState; - } + } } Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PostAction.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PostAction.java 2006-05-09 16:29:16 UTC (rev 4158) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PostAction.java 2006-05-09 17:01:41 UTC (rev 4159) @@ -58,9 +58,8 @@ protected String question = null; protected Collection options = new ArrayList(); protected int activeDuration = 0; - protected boolean deletePoll = false; - protected boolean deletePollActivated = false; + //attachment related view data protected String attachmentComment = null; protected UploadedFile attachment = null; @@ -195,36 +194,8 @@ { return this.options; } - + /** - * - * @return - */ - public boolean getDeletePoll() - { - return this.deletePoll; - } - - /** - * - * @param deletePoll - */ - public void setDeletePoll(boolean deletePoll) - { - this.deletePoll = deletePoll; - } - - /** - * - * @return - */ - public boolean isDeletePollActivated() - { - return this.deletePollActivated; - } - - - /** * @return Returns the attachmentComment. */ public String getAttachmentComment() @@ -356,8 +327,6 @@ this.question = null; this.options = new ArrayList(); this.activeDuration = 0; - this.deletePoll = false; - this.deletePollActivated = false; //cleanup attachment related data this.attachment = null; 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-09 16:29:16 UTC (rev 4158) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-09 17:01:41 UTC (rev 4159) @@ -215,6 +215,14 @@ <to-view-id>/views/topics/viewtopic_body.xhtml</to-view-id> </navigation-case> </navigation-rule> + <navigation-rule> + <from-view-id>/views/topics/delete_poll.xhtml</from-view-id> + <!-- represents delete of the selected poll was successfull --> + <navigation-case> + <from-outcome>success</from-outcome> + <to-view-id>/views/topics/posting_edit_body.xhtml</to-view-id> + </navigation-case> + </navigation-rule> <!-- managedBean for the viewTopic usecase --> <managed-bean> @@ -283,5 +291,5 @@ <managed-bean-name>pollController</managed-bean-name> <managed-bean-class>org.jboss.portlet.forums.ui.action.PollController</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> - </managed-bean> + </managed-bean> </faces-config> \ No newline at end of file Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/delete_poll.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/delete_poll.xhtml 2006-05-09 16:29:16 UTC (rev 4158) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/delete_poll.xhtml 2006-05-09 17:01:41 UTC (rev 4159) @@ -0,0 +1,61 @@ +<!-- +/* +* 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:t="http://myfaces.apache.org/tomahawk" + xmlns:forums="http://www.jboss.com/products/jbossportal/forums" + class="bb" +> + +<ui:composition template="/views/common/common.xhtml"> +<ui:define name="mainContent"> + + <table class="forumline" width="100%" cellspacing="1" cellpadding="3" border="0"> + <tr> + <th class="thHead" height="25" valign="middle"><span class="tableTitle">Information</span></th> + </tr> + <tr> + <td class="row1" align="center"> + <h:form> + <span class="gen"><br/> + Are you sure you want to delete this poll? + <br/><br/> + <h:commandButton type="submit" value="Yes" styleClass="mainoption" action="#{editPost.deletePoll}"/> + &nbsp;&nbsp; + <h:commandButton type="button" value="No" styleClass="liteoption" onclick="javascript:history.back();"/> + </span> + </h:form> + </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/topics/posting_edit_body.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_edit_body.xhtml 2006-05-09 16:29:16 UTC (rev 4158) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_edit_body.xhtml 2006-05-09 17:01:41 UTC (rev 4159) @@ -476,16 +476,13 @@ </td> </tr> - <c:if test="#{true}"> + <c:if test="#{editPost.pollPresent}"> <!-- poll ui --> <!-- TODO: security check to make sure this user has permission to "ADD/EDIT" "Poll" in the Post --> <!-- title --> <tr> <th class="thHead" colspan="2">${resource.Add_poll}</th> - </tr> - <tr> - <td class="row1" colspan="2"><span class="gensmall">${resource.Add_poll_explain}</span></td> - </tr> + </tr> <!-- setup poll question --> <tr> @@ -541,15 +538,13 @@ <!-- enable/disable delete option --> <!-- TODO: security check to make sure this user has permission to "EDIT" "Post" in the Forum --> - <c:if test="#{editPost.deletePollActivated}"> - <tr> - <td class="row1"><span class="gen"><b>${resource.Delete_poll}</b></span></td> - <td class="row2"> - <h:selectBooleanCheckbox value="#{editPost.deletePoll}"/> - </td> - </tr> - </c:if> - </c:if> + <tr> + <td colspan="2" align="center"> + <input type="button" value="${resource.Delete_poll}" + onclick="javascript:document.location='#{forums:outputLink('/views/topics/delete_poll.jsf',true)}';"/> + </td> + </tr> + </c:if> <!-- attachment ui --> Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml 2006-05-09 16:29:16 UTC (rev 4158) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml 2006-05-09 17:01:41 UTC (rev 4159) @@ -540,20 +540,7 @@ </td> </tr> - - <!-- enable/disable delete option --> - <!-- TODO: security check to make sure this user has permission to "EDIT" "Post" in the Forum --> - <c:if test="#{newTopic.deletePollActivated}"> - <tr> - <td class="row1"><span class="gen"><b>${resource.Delete_poll}</b></span></td> - <td class="row2"> - <h:selectBooleanCheckbox value="#{newTopic.deletePoll}"/> - </td> - </tr> - </c:if> - - - + <!-- attachment ui --> <!-- TODO: security check to make sure this user has permission to "AddAttachmentInPost" --> <tr> |