Pollen-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
May 2012
- 5 participants
- 74 discussions
r3377 - in trunk/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions resources/i18n
by tchemit@users.chorem.org 24 May '12
by tchemit@users.chorem.org 24 May '12
24 May '12
Author: tchemit
Date: 2012-05-24 11:11:22 +0200 (Thu, 24 May 2012)
New Revision: 3377
Url: http://chorem.org/repositories/revision/pollen/3377
Log:
fixes #563: Allow simple date in choice list
Modified:
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/DateConverter.java
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/DateConverter.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/DateConverter.java 2012-05-18 14:50:18 UTC (rev 3376)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/DateConverter.java 2012-05-24 09:11:22 UTC (rev 3377)
@@ -28,7 +28,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.util.StrutsTypeConverter;
-import org.nuiton.i18n.I18n;
import org.nuiton.util.DateUtil;
import java.text.ParseException;
@@ -36,20 +35,23 @@
import java.util.Locale;
import java.util.Map;
+import static org.nuiton.i18n.I18n.l_;
+
/**
* Created: 18/04/12
*
* @author fdesbois <desbois(a)codelutin.com>
+ * @since 1.3
*/
public class DateConverter extends StrutsTypeConverter {
-
+
private static final Log log = LogFactory.getLog(DateConverter.class);
@Override
public Date convertFromString(Map context, String[] values, Class toClass) {
String value = values[0];
Date result = convertFromString(value);
- return result;
+ return result;
}
@Override
@@ -58,29 +60,42 @@
String result = convertToString(date);
return result;
}
-
+
public static String convertToString(Date date) {
- String result = DateUtil.formatDate(date, getDatePattern());
+ String result = DateUtil.formatDate(date, getDateTimePattern());
return result;
}
public static Date convertFromString(String value) {
Date result = null;
if (StringUtils.isNotBlank(value)) {
+ // try first with a date-time pattern
try {
- result = DateUtil.parseDate(value, getDatePattern());
+ result = DateUtil.parseDate(value, getDateTimePattern());
} catch (ParseException e) {
- if (log.isErrorEnabled()) {
- log.error("Error parsing date '" + value + "'", e);
+
+ // fall-back, try with a date pattern
+ try {
+ result = DateUtil.parseDate(value, getDatePattern());
+ } catch (ParseException e1) {
+ if (log.isErrorEnabled()) {
+ log.error("Error parsing date '" + value + "'", e1);
+ }
}
}
}
return result;
}
+ private static String getDateTimePattern() {
+ Locale locale = ActionContext.getContext().getLocale();
+ String result = l_(locale, "pollen.common.dateTimePattern");
+ return result;
+ }
+
private static String getDatePattern() {
Locale locale = ActionContext.getContext().getLocale();
- String result = I18n.l_(locale, "pollen.common.datePattern");
+ String result = l_(locale, "pollen.common.datePattern");
return result;
}
}
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-05-18 14:50:18 UTC (rev 3376)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-05-24 09:11:22 UTC (rev 3377)
@@ -66,8 +66,9 @@
pollen.common.commentText=Comment
pollen.common.comments=Comments about this poll
pollen.common.csvImport=CSV import
-pollen.common.datePattern=MM/dd/yyyy HH\:mm
+pollen.common.datePattern=MM/dd/yyyy
pollen.common.datePickerPattern=mm/dd/yy
+pollen.common.dateTimePattern=MM/dd/yyyy HH\:mm
pollen.common.description=Description
pollen.common.displayType-group=Results by groups
pollen.common.displayType-normal=Results
@@ -147,7 +148,7 @@
pollen.error.choice.empty=%s mandatory
pollen.error.comment.name.empty=Comment name mandatory
pollen.error.comment.text.empty=Comment text mandatory
-pollen.error.date.format=Begin date does not match pattern 12/31/2000 12\:59
+pollen.error.date.format=Date does not match pattern MM/dd/yyyy [hh:mm] (example 12/31/2000 12\:59)
pollen.error.email.invalid=The email doesn't have the good format
pollen.error.email.required=You must provide an email
pollen.error.favoriteList.already.used=List name already used
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-05-18 14:50:18 UTC (rev 3376)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-05-24 09:11:22 UTC (rev 3377)
@@ -66,8 +66,9 @@
pollen.common.commentText=Commentaire
pollen.common.comments=Commentaire à propos du sondage
pollen.common.csvImport=Import CSV
-pollen.common.datePattern=dd/MM/yyyy HH\:mm
+pollen.common.datePattern=dd/MM/yyyy
pollen.common.datePickerPattern=dd/mm/yy
+pollen.common.dateTimePattern=dd/MM/yyyy HH\:mm
pollen.common.description=Description
pollen.common.displayType-group=Résultats par groupes
pollen.common.displayType-normal=Résultats
@@ -145,7 +146,7 @@
pollen.error.choice.empty=%s obligatoire
pollen.error.comment.name.empty=Nom du commentaire obligatoire
pollen.error.comment.text.empty=Texte du commentaire obligatoire
-pollen.error.date.format=La date doit être au format 31/12/2000 23\:59
+pollen.error.date.format=La date doit être au format jj/MM/aaaa [hh:mm] (exemple 31/12/2000 23\:59)
pollen.error.email.invalid=Email non valide
pollen.error.email.required=Email obligatoire
pollen.error.favoriteList.already.used=Nom de liste déjà utilisé
1
0
r3376 - trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions
by tchemit@users.chorem.org 18 May '12
by tchemit@users.chorem.org 18 May '12
18 May '12
Author: tchemit
Date: 2012-05-18 16:50:18 +0200 (Fri, 18 May 2012)
New Revision: 3376
Url: http://chorem.org/repositories/revision/pollen/3376
Log:
uncomment used code (but not at the good place)
Modified:
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-05-18 14:15:42 UTC (rev 3375)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-05-18 14:50:18 UTC (rev 3376)
@@ -45,7 +45,6 @@
import javax.servlet.http.HttpServletRequest;
import java.net.URL;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -202,30 +201,30 @@
return new Date();
}
-// public String getVoteCountingTypeHelp(VoteCountingType voteCountingType) {
-// String result;
-// switch (voteCountingType) {
-//
-// default:
-// case NORMAL:
-// result =
-// _("pollen.common.voteCountingTypeHelp.normal");
-// break;
-// case PERCENTAGE:
-// result =
-// _("pollen.common.voteCountingTypeHelp.percentage");
-// break;
-// case CONDORCET:
-// result =
-// _("pollen.common.voteCountingTypeHelp.condorcet");
-// break;
-// case NUMBER:
-// result =
-// _("pollen.common.voteCountingTypeHelp.number");
-// }
-// return result;
-// }
-
+ public String getVoteCountingTypeHelp(VoteCountingType voteCountingType) {
+ String result;
+ switch (voteCountingType) {
+
+ default:
+ case NORMAL:
+ result =
+ _("pollen.common.voteCountingTypeHelp.normal");
+ break;
+ case PERCENTAGE:
+ result =
+ _("pollen.common.voteCountingTypeHelp.percentage");
+ break;
+ case CONDORCET:
+ result =
+ _("pollen.common.voteCountingTypeHelp.condorcet");
+ break;
+ case NUMBER:
+ result =
+ _("pollen.common.voteCountingTypeHelp.number");
+ }
+ return result;
+ }
+
public String getCurrentUrl() {
HttpServletRequest request = ServletActionContext.getRequest();
String result = request.getRequestURL().toString();
@@ -274,6 +273,7 @@
// }
return result;
}
+
public boolean hasFlashMessages() {
List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
return CollectionUtils.isNotEmpty(result);
1
0
r3375 - in trunk/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions/poll resources/i18n webapp/WEB-INF/jsp/poll
by tchemit@users.chorem.org 18 May '12
by tchemit@users.chorem.org 18 May '12
18 May '12
Author: tchemit
Date: 2012-05-18 16:15:42 +0200 (Fri, 18 May 2012)
New Revision: 3375
Url: http://chorem.org/repositories/revision/pollen/3375
Log:
#537: The poll must not be updatable after closing it
Removed:
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/edit.jsp
Modified:
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/LoadPoll.java
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/LoadPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/LoadPoll.java 2012-05-18 12:48:26 UTC (rev 3374)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/LoadPoll.java 2012-05-18 14:15:42 UTC (rev 3375)
@@ -66,6 +66,9 @@
String pollUid = pollUri == null ? null : pollUri.getPollId();
poll = getPollService().getPollEditable(pollUid, userAccount, clone);
+ if (poll.isClosed()) {
+ addFlashWarning(_("pollen.warning.poll.is.closed.so.read.only"));
+ }
List<Choice> pollChoices = poll.getChoice();
List<VotingList> pollVotingLists = poll.getVotingList();
@@ -84,7 +87,7 @@
setReminder(true);
setReminderHourCountdown(reminder.getSensibility());
}
-
+
PreventRule notification = poll.getPreventRuleByScope(
PreventRuleService.SCOPE_VOTE);
if (notification != null) {
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-05-18 12:48:26 UTC (rev 3374)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-05-18 14:15:42 UTC (rev 3375)
@@ -291,5 +291,6 @@
pollen.title.selectPersonListToAddVotingList=Select a voter list to import in voting list
pollen.title.selectPersonListToCreateVotingList=Select a favorite list to import in a new voting list
pollen.title.usersList=Users administration
+pollen.warning.poll.is.closed.so.read.only=Poll is closed, you can not modifiy it anymore.
title=Create a poll
vote.anonymous=Anonymous vote
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-05-18 12:48:26 UTC (rev 3374)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-05-18 14:15:42 UTC (rev 3375)
@@ -287,5 +287,6 @@
pollen.title.selectPersonListToAddVotingList=Sélectionner une liste de votants à ajouter
pollen.title.selectPersonListToCreateVotingList=Sélectionner une liste de votants pour créer un nouveau groupe
pollen.title.usersList=Gestion des utilisateurs
+pollen.warning.poll.is.closed.so.read.only=Le sondage est clos, vous ne pouvez plus le modifer
title=Création d'un sondage
vote.anonymous=Vote anonyme
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp 2012-05-18 12:48:26 UTC (rev 3374)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/create.jsp 2012-05-18 14:15:42 UTC (rev 3375)
@@ -25,7 +25,8 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
-<link rel="stylesheet" type="text/css" href="<s:url value='/css/pollCreation.css'/>"/>
+<link rel="stylesheet" type="text/css"
+ href="<s:url value='/css/pollCreation.css'/>"/>
<link rel="stylesheet" type="text/css" href="<s:url value='/css/tipTip.css'/>"/>
<script type="text/javascript">
@@ -56,17 +57,19 @@
choiceType:'<s:property value="%{poll.choiceType.name()}"/>',
pollType:'<s:property value="%{poll.pollType.name()}"/>',
- confirmCloseTitle: "<s:text name='pollen.title.close.poll'/>",
- confirmCloseUrl: '<s:url action="confirmClosePoll/" namespace="/poll"/>'
- + '<s:property value="%{poll.adminId}"/>',
- confirmCloseRedirectUrl: '<s:url action="resultLink/" namespace="/poll"/>'
- + '<s:property value="%{poll.adminId}"/>'
+ confirmCloseTitle:"<s:text name='pollen.title.close.poll'/>",
+ confirmCloseUrl:'<s:url action="confirmClosePoll/" namespace="/poll"/>'
+ + '<s:property value="%{poll.adminId}"/>',
+ confirmCloseRedirectUrl:'<s:url action="resultLink/" namespace="/poll"/>'
+ + '<s:property value="%{poll.adminId}"/>'
}
);
</script>
-<script type="text/javascript" src='<s:url value="/js/createPoll.js"/>'></script>
-<script type="text/javascript" src='<s:url value="/js/jquery.tipTip.minified.js"/>'></script>
+<script type="text/javascript"
+ src='<s:url value="/js/createPoll.js"/>'></script>
+<script type="text/javascript"
+ src='<s:url value="/js/jquery.tipTip.minified.js"/>'></script>
<s:url id='errorImg' value='/img/exclamation.png'/>
@@ -225,8 +228,10 @@
</div>
<div id="pollTypeRESTRICTED" class="pollType">
- <s:iterator value="restrictedVotingList" status="status" var="votingList">
- <s:set name="votingListNumber"><s:property value="%{#status.index}"/></s:set>
+ <s:iterator value="restrictedVotingList" status="status"
+ var="votingList">
+ <s:set name="votingListNumber"><s:property
+ value="%{#status.index}"/></s:set>
<s:set name="votingListType">RESTRICTED</s:set>
<%@include file="displayVotingList.jsp" %>
</s:iterator>
@@ -234,8 +239,10 @@
<div id="pollTypeGROUP" class="pollType">
<div id="votingListGROUP">
- <s:iterator value="groupVotingList" status="status" var="votingList">
- <s:set name="votingListNumber"><s:property value="%{#status.index}"/></s:set>
+ <s:iterator value="groupVotingList" status="status"
+ var="votingList">
+ <s:set name="votingListNumber"><s:property
+ value="%{#status.index}"/></s:set>
<s:set name="votingListType">GROUP</s:set>
<%@include file="displayVotingList.jsp" %>
</s:iterator>
@@ -286,6 +293,11 @@
addErrorImage($('#tabOptions a'));
}
+ if (<s:property value="%{poll.closed}"/>) {
+ $('#registerForm input, textarea').attr('disabled', true);
+ $('#registerForm :button, fieldset a, :submit, input[type="file"]').hide();
+ }
+
});
</script>
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp 2012-05-18 12:48:26 UTC (rev 3374)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp 2012-05-18 14:15:42 UTC (rev 3375)
@@ -191,12 +191,10 @@
alt="<s:text name='pollen.image.not.loaded'/>"
title="<s:text name='pollen.image.not.loaded'/>"
src="<s:property value='imageUrl'/>" width="100px" height="75px">
- <span style="float: left; margin-left:50px; ">
<s:file key='imageChoice[%{#choiceNumber}]' label=''
theme="simple"
- cssClass="nameField"
- disabled="%{voteStarted}" cssStyle="clear: both;"/>
- </span>
+ cssClass="nameField fleft"
+ disabled="%{voteStarted}" cssStyle="margin-left:50px;"/>
</s:else>
Deleted: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/edit.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/edit.jsp 2012-05-18 12:48:26 UTC (rev 3374)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/edit.jsp 2012-05-18 14:15:42 UTC (rev 3375)
@@ -1,25 +0,0 @@
-<%--
- #%L
- Pollen :: UI (strust2)
-
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- #L%
- --%>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<h2>edit poll TODO</h2>
\ No newline at end of file
1
0
18 May '12
Author: tchemit
Date: 2012-05-18 14:48:26 +0200 (Fri, 18 May 2012)
New Revision: 3374
Url: http://chorem.org/repositories/revision/pollen/3374
Log:
fixes #517: Add a WARNING message level
Added:
trunk/pollen-ui-struts2/src/main/webapp/img/warning.png
Removed:
trunk/pollen-ui-struts2/src/main/webapp/css/screen.css
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
trunk/pollen-ui-struts2/src/main/webapp/css/common.css
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-05-18 07:40:41 UTC (rev 3373)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-05-18 12:48:26 UTC (rev 3374)
@@ -1,3 +1,26 @@
+/*
+ * #%L
+ * Pollen :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
package org.chorem.pollen.entities.migration;
import org.nuiton.topia.TopiaException;
Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java 2012-05-18 07:40:41 UTC (rev 3373)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java 2012-05-18 12:48:26 UTC (rev 3374)
@@ -23,6 +23,7 @@
*/
package org.chorem.pollen.ui;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.opensymphony.xwork2.ActionContext;
import org.apache.commons.logging.Log;
@@ -32,6 +33,7 @@
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
+import java.util.List;
import java.util.Map;
/**
@@ -52,6 +54,8 @@
public static final String SESSION_TOKEN_ERRORS = "errors";
+ public static final String SESSION_TOKEN_WARNINGS = "warnings";
+
public static PollenSession get(ServletRequest servletRequest) {
HttpSession httpSession = ((HttpServletRequest) servletRequest).getSession(true);
PollenSession pollenSession = (PollenSession) httpSession.getAttribute(SESSION_PARAMETER);
@@ -101,6 +105,14 @@
return (T) result;
}
+ public <T> T consumeDynamicData(String token) {
+ Object result = getDynamicData().get(token);
+ if (result != null) {
+ removeDynamicData(token);
+ }
+ return (T) result;
+ }
+
public void putDynamicData(String token, Object data) {
getDynamicData().put(token, data);
if (log.isDebugEnabled()) {
@@ -130,4 +142,14 @@
}
return dynamicData;
}
+
+ public void addMessage(String messageScope, String message) {
+ List<String> messages = getDynamicData(messageScope);
+ if (messages == null) {
+ messages = Lists.newArrayList(message);
+ putDynamicData(messageScope, messages);
+ } else {
+ messages.add(message);
+ }
+ }
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-05-18 07:40:41 UTC (rev 3373)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-05-18 12:48:26 UTC (rev 3374)
@@ -202,29 +202,29 @@
return new Date();
}
- public String getVoteCountingTypeHelp(VoteCountingType voteCountingType) {
- String result;
- switch (voteCountingType) {
-
- default:
- case NORMAL:
- result =
- _("pollen.common.voteCountingTypeHelp.normal");
- break;
- case PERCENTAGE:
- result =
- _("pollen.common.voteCountingTypeHelp.percentage");
- break;
- case CONDORCET:
- result =
- _("pollen.common.voteCountingTypeHelp.condorcet");
- break;
- case NUMBER:
- result =
- _("pollen.common.voteCountingTypeHelp.number");
- }
- return result;
- }
+// public String getVoteCountingTypeHelp(VoteCountingType voteCountingType) {
+// String result;
+// switch (voteCountingType) {
+//
+// default:
+// case NORMAL:
+// result =
+// _("pollen.common.voteCountingTypeHelp.normal");
+// break;
+// case PERCENTAGE:
+// result =
+// _("pollen.common.voteCountingTypeHelp.percentage");
+// break;
+// case CONDORCET:
+// result =
+// _("pollen.common.voteCountingTypeHelp.condorcet");
+// break;
+// case NUMBER:
+// result =
+// _("pollen.common.voteCountingTypeHelp.number");
+// }
+// return result;
+// }
public String getCurrentUrl() {
HttpServletRequest request = ServletActionContext.getRequest();
@@ -233,45 +233,47 @@
}
public void addFlashMessage(String message) {
- List<String> messages = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
- if (messages == null) {
- messages = Lists.newArrayList(message);
- getPollenSession().putDynamicData(PollenSession.SESSION_TOKEN_MESSAGES, messages);
- } else {
- messages.add(message);
- }
+ getPollenSession().addMessage(PollenSession.SESSION_TOKEN_MESSAGES, message);
}
public void addFlashError(String message) {
- List<String> messages = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
- if (messages == null) {
- messages = Lists.newArrayList(message);
- getPollenSession().putDynamicData(PollenSession.SESSION_TOKEN_ERRORS, messages);
- } else {
- messages.add(message);
- }
+ getPollenSession().addMessage(PollenSession.SESSION_TOKEN_ERRORS, message);
}
+ public void addFlashWarning(String message) {
+ getPollenSession().addMessage(PollenSession.SESSION_TOKEN_WARNINGS, message);
+ }
+
public Collection<String> getFlashMessages() {
- List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
- if (result == null) {
- result = Collections.emptyList();
- } else {
- getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
- }
+
+ List<String> result = getPollenSession().consumeDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
+// if (result == null) {
+// result = Collections.emptyList();
+// } else {
+// getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
+// }
return result;
}
public Collection<String> getFlashErrors() {
- List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
- if (result == null) {
- result = Collections.emptyList();
- } else {
- getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
- }
+ List<String> result = getPollenSession().consumeDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
+// if (result == null) {
+// result = Collections.emptyList();
+// } else {
+// getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
+// }
return result;
}
+ public Collection<String> getFlashWarnings() {
+ List<String> result = getPollenSession().consumeDynamicData(PollenSession.SESSION_TOKEN_WARNINGS);
+// if (result == null) {
+// result = Collections.emptyList();
+// } else {
+// getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_ERRORS);
+// }
+ return result;
+ }
public boolean hasFlashMessages() {
List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
return CollectionUtils.isNotEmpty(result);
@@ -282,6 +284,11 @@
return CollectionUtils.isNotEmpty(result);
}
+ public boolean hasFlashWarnings() {
+ List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_WARNINGS);
+ return CollectionUtils.isNotEmpty(result);
+ }
+
public void clearFlashMessages() {
List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_MESSAGES);
if (result != null) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-05-18 07:40:41 UTC (rev 3373)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-05-18 12:48:26 UTC (rev 3374)
@@ -321,7 +321,7 @@
} else if (isPollFinished()) {
addFlashMessage(_("pollen.information.pollFinished"));
} else if (pollCreator.equals(pollAccount)) {
- addFlashMessage(_("pollen.information.vote.creatorUser"));
+ addFlashWarning(_("pollen.information.vote.creatorUser"));
}
if (isPollChoiceRunning()) {
addFlashMessage(_("pollen.information.pollChoiceRunning"));
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-05-18 07:40:41 UTC (rev 3373)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-05-18 12:48:26 UTC (rev 3374)
@@ -185,7 +185,7 @@
addFlashError(_("pollen.error.userNotAllowed"));
} else if (poll.isRunning(serviceContext.getCurrentTime())) {
- addFlashMessage(_("pollen.information.pollRunning"));
+ addFlashWarning(_("pollen.information.pollRunning"));
loadResults();
} else {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-05-18 07:40:41 UTC (rev 3373)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-05-18 12:48:26 UTC (rev 3374)
@@ -118,6 +118,7 @@
getPollService().addVoteToPoll(getPoll(), voteCreated);
}
+ //TODO tchemit-2012-05-18 Why clean messages and just messages here ?
clearFlashMessages();
// For free Poll, display the update Url (useless if user is logged)
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-05-18 07:40:41 UTC (rev 3373)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-05-18 12:48:26 UTC (rev 3374)
@@ -208,6 +208,7 @@
pollen.fieldset.userInformation.toCreate=User informations to create
pollen.fieldset.userInformation.toDelete=User informations to delete
pollen.fieldset.userInformation.toUpdate=User informations to update
+pollen.image.not.loaded=Image not loaded
pollen.information.confirmClonePoll=Confirm clone of poll\:
pollen.information.confirmClosePoll=Confirm close of poll\:
pollen.information.confirmDeleteChoice=Confirm delete of choice %s
@@ -292,4 +293,3 @@
pollen.title.usersList=Users administration
title=Create a poll
vote.anonymous=Anonymous vote
-pollen.image.not.loaded=Image not loaded
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-05-18 07:40:41 UTC (rev 3373)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-05-18 12:48:26 UTC (rev 3374)
@@ -206,6 +206,7 @@
pollen.fieldset.userInformation.toCreate=Informations de l'utilisateur à créer
pollen.fieldset.userInformation.toDelete=Informations de l'utilisateur à supprimer
pollen.fieldset.userInformation.toUpdate=Informations de l'utilisateur à mettre à jour
+pollen.image.not.loaded=Image non chargée
pollen.information.confirmClonePoll=Confirmer le clonage du sondage \:
pollen.information.confirmClosePoll=Confirmer la fermeture du sondage \:
pollen.information.confirmDeleteFavoriteList=Confirmer la suppression de la liste de votants \:
@@ -288,4 +289,3 @@
pollen.title.usersList=Gestion des utilisateurs
title=Création d'un sondage
vote.anonymous=Vote anonyme
-pollen.image.not.loaded=Image non chargée
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-05-18 07:40:41 UTC (rev 3373)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-05-18 12:48:26 UTC (rev 3374)
@@ -33,8 +33,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Pollen - <d:title default="Pollen"/></title>
<d:head/>
- <%--<link rel="stylesheet" type="text/css" href="<s:url value='/css/pollen.css' />"/>--%>
- <%--<link rel="stylesheet" type="text/css" href="<s:url value='/css/screen.css' />"/>--%>
<link rel="stylesheet" type="text/css" href="<s:url value='/css/main.css' />"/>
<link rel="stylesheet" type="text/css" href="<s:url value='/css/common.css' />"/>
<link rel="icon" type="image/png" href="<s:url value='/favicon.png' />"/>
@@ -280,6 +278,15 @@
</div>
</s:if>
+ <s:if test="hasFlashWarnings()">
+ <div class="info_warning clearfix">
+ <ul class="actionWarnings fleft">
+ <s:iterator value="flashWarnings" var="message">
+ <li><span><s:property value="#message" escapeHtml="false"/></span></li>
+ </s:iterator>
+ </ul>
+ </div>
+ </s:if>
<s:if test="hasFlashErrors()">
<div class="info_error clearfix">
<ul class="actionErrors fleft">
Modified: trunk/pollen-ui-struts2/src/main/webapp/css/common.css
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/css/common.css 2012-05-18 07:40:41 UTC (rev 3373)
+++ trunk/pollen-ui-struts2/src/main/webapp/css/common.css 2012-05-18 12:48:26 UTC (rev 3374)
@@ -149,6 +149,28 @@
color: #880000;
margin-left:0px;
}
+
+.info_warning {
+ background: no-repeat scroll 8px 5px #fff71f;
+ border: 2px solid #FFCC00;
+ width: 970px;
+ margin-bottom: 5px;
+ margin-top: 10px;
+}
+.info_warning ul{
+ margin: 5px;
+ padding-left: 5px;
+ width: 950px;
+}
+.info_warning li{
+ background: url("../img/warning.png") no-repeat ;
+ list-style: none;
+ font-style: italic;
+ padding-left: 25px;
+ color: #e09210;
+ margin-left:0px;
+}
+
#tooltip {
position:absolute;
z-index:9999;
Deleted: trunk/pollen-ui-struts2/src/main/webapp/css/screen.css
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/css/screen.css 2012-05-18 07:40:41 UTC (rev 3373)
+++ trunk/pollen-ui-struts2/src/main/webapp/css/screen.css 2012-05-18 12:48:26 UTC (rev 3374)
@@ -1,162 +0,0 @@
-/*
- * #%L
- * Pollen :: UI (strust2)
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-/** {*/
- /*font-family: sans-serif;*/
-/*}*/
-
-.inline {
- display:inline;
-}
-
-.fontsize11 {
- font-size: 11px;
-}
-
-.ui-tabs-panel {
- font-family: monospace;
- font-size: 9pt;
-}
-
-.ui-tabs .ui-tabs-nav li a {
- float: left;
- padding: .5em .1em;
- text-decoration: none;
- font-size: 11px;
-}
-
-.clearBoth {
- clear: both;
-}
-
-.hidden {
- display:none;
-}
-
-.displayBlock {
- display:block;
-}
-
-.floatLeft {
- float:left;
-}
-
-.floatRight {
- float:right;
-}
-
-.info_success {
- background: no-repeat scroll 8px 5px #DFFFDF;
- border: 2px solid #9FCF9F;
- width: 800px;
- margin-bottom: 5px;
-}
-.info_success ul{
- margin: 5px;
- padding-left: 5px;
-}
-.info_success li{
- background: url("../img/true.png") no-repeat ;
- list-style: none;
- font-style: italic;
- padding-left: 25px;
- color: #005F00;
- margin-left:0px;
-}
-
-.info_error {
- background: no-repeat scroll 8px 5px #FFE3E3;
- border: 2px solid #DD0000;
- width: 800px;
- margin-bottom: 5px;
-}
-.info_error ul{
- margin: 5px;
- padding-left: 5px;
-}
-.info_error li{
- background: url("../img/exclamation.png") no-repeat ;
- list-style: none;
- font-style: italic;
- padding-left: 25px;
- color: #880000;
- margin-left:0px;
-}
-
-.errorMessage li{
- background: url("../img/exclamation.png") no-repeat ;
- list-style: none;
- font-style: italic;
- padding-left: 25px;
- color: #880000;
- margin-left:0px;
-}
-
-.verticalAlignTop {
- vertical-align: top;
-}
-
-fieldset, hr , .cleanBoth{
- clear: both
-}
-.wwlbl {
- float: left;
- clear: both;
- width: 300px;
-/*# text-align: right;*/
-}
-.wwctrl {
- float: left;
-}
-
-.wwerr {
- clear: both;
- float: left;
-}
-
-div.errorMessage{
- clear: both;
- float: left;
-}
-.errorMessage {
- background: url("../img/exclamation.png") no-repeat ;
- list-style: none;
- font-style: italic;
- padding-left: 25px;
- color: #880000;
- margin-left:0px;
-}
-
-.required {
- color: #880000;
- font-style: italic;
-}
-
-.clearfix {
- display: inline-block;
-}
-
-/* Hide from IE Mac \*/
-.clearfix {
- display: block;
-}
Added: trunk/pollen-ui-struts2/src/main/webapp/img/warning.png
===================================================================
(Binary files differ)
Property changes on: trunk/pollen-ui-struts2/src/main/webapp/img/warning.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r3373 - in trunk/pollen-ui-struts2/src/main: resources/i18n webapp/WEB-INF/jsp/poll webapp/js
by tchemit@users.chorem.org 18 May '12
by tchemit@users.chorem.org 18 May '12
18 May '12
Author: tchemit
Date: 2012-05-18 09:40:41 +0200 (Fri, 18 May 2012)
New Revision: 3373
Url: http://chorem.org/repositories/revision/pollen/3373
Log:
add thumb on uploaded image choices + fix add new choices
Modified:
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayDateChoice.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayImageChoice.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayTextChoice.jsp
trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-05-18 06:52:21 UTC (rev 3372)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-05-18 07:40:41 UTC (rev 3373)
@@ -21,7 +21,7 @@
pollen.action.deleteUser=Delete selected user
pollen.action.deleteVote=Supprimer ce vote
pollen.action.editFavoriteList=Edit a list
-pollen.action.editPoll=Edit the poll
+pollen.action.editPoll=Edit the pollLes deux mots de passe saisis non identiques
pollen.action.editPollAccount=Edit selected member
pollen.action.editUser=Edit selected user
pollen.action.editVote=Modifier le vote
@@ -163,7 +163,7 @@
pollen.error.no.poll.found=Poll not found with id %s
pollen.error.password.required=Your must provide a password
pollen.error.password2.required=You must repeat your password for confirmation
-pollen.error.passwords.not.equals=Les deux mots de passe saisis non identiques
+pollen.error.passwords.not.equals=The two password are not the same
pollen.error.poll.detected.duplicate.choice.name=Choices must be unique.
pollen.error.poll.endChoiceDate.after.endDate=The choice end date must be sooner than the poll end date.
pollen.error.poll.endChoiceDate.before.beginChoiceDate=The choice end date must be later than the begin date.
@@ -292,3 +292,4 @@
pollen.title.usersList=Users administration
title=Create a poll
vote.anonymous=Anonymous vote
+pollen.image.not.loaded=Image not loaded
Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-05-18 06:52:21 UTC (rev 3372)
+++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-05-18 07:40:41 UTC (rev 3373)
@@ -288,3 +288,4 @@
pollen.title.usersList=Gestion des utilisateurs
title=Création d'un sondage
vote.anonymous=Vote anonyme
+pollen.image.not.loaded=Image non chargée
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp 2012-05-18 06:52:21 UTC (rev 3372)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp 2012-05-18 07:40:41 UTC (rev 3373)
@@ -26,195 +26,220 @@
<%@ taglib prefix="sp" uri="/nuiton-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
<fieldset>
- <legend><s:text name="pollen.fieldset.poll.choices"/></legend>
- <s:radio key='poll.choiceType' list="choiceTypes" label=''
- theme="simple" disabled="%{voteStarted}"/>
- <hr/>
- <s:fielderror fieldName="poll.choices"/>
+<legend><s:text name="pollen.fieldset.poll.choices"/></legend>
+<s:radio key='poll.choiceType' list="choiceTypes" label=''
+ theme="simple" disabled="%{voteStarted}"/>
+<hr/>
+<s:fielderror fieldName="poll.choices"/>
- <s:set id='deleteTitle'><s:text
- name="pollen.action.pollChoiceDelete"/></s:set>
- <s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
- <s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
+<s:set id='deleteTitle'><s:text
+ name="pollen.action.pollChoiceDelete"/></s:set>
+<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
+<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
- <div id="choicesTEXT" class="choices">
- <s:iterator value="textChoices" status="status" var="choice">
- <s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
- <s:set name="prefix">textChoice_<s:property
- value="%{#choiceNumber}"/></s:set>
- <div id='choicesTEXT_<s:property value="choiceNumber"/>'>
- <s:hidden key='%{#prefix}.topiaId' value='%{#choice.topiaId}' label=''/>
- <sp:fielderror fieldName="%{#prefix}"/>
- <div class="fleft choiceName">
- <s:label for="%{#prefix}.name" id="choicesTEXT_label_%{#choiceNumber}"
- theme="simple" value=''/>
- <s:textfield cssClass="nameField" id='%{#prefix}.name'
- key="%{#prefix}.name"
- label='' theme="simple" value="%{#choice.name}"
+<div id="choicesTEXT" class="choices">
+ <s:iterator value="textChoices" status="status" var="choice">
+ <s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
+ <s:set name="prefix">textChoice_<s:property
+ value="%{#choiceNumber}"/></s:set>
+ <div id='choicesTEXT_<s:property value="choiceNumber"/>'>
+ <s:hidden key='%{#prefix}.topiaId' value='%{#choice.topiaId}' label=''/>
+ <sp:fielderror fieldName="%{#prefix}"/>
+ <div class="fleft choiceName">
+ <s:label for="%{#prefix}.name" id="choicesTEXT_label_%{#choiceNumber}"
+ theme="simple" value=''/>
+ <s:textfield cssClass="nameField" id='%{#prefix}.name'
+ key="%{#prefix}.name"
+ label='' theme="simple" value="%{#choice.name}"
+ disabled="%{voteStarted}"/>
+ -
+ <s:label for="%{#prefix}.description" key="pollen.common.description"
+ theme="simple"/>
+ <%--/div>
+ <div class="fleft"--%>
+ <s:textarea cols="30" id="%{#prefix}.description" label=''
+ theme="simple"
+ key="%{#prefix}.description"
+ value="%{#choice.description}"
+ disabled="%{voteStarted}"/>
+ </div>
+ <s:if test="!voteStarted">
+ <div class="fright">
+ <s:a id='choicesTEXT_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesTEXT_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a>
+ <s:a href='#'
+ onclick="return deleteChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
+ </div>
+ </s:if>
+ <div class="cleanBoth"></div>
+ </div>
+ </s:iterator>
+</div>
+<div id="choicesDATE" class="choices">
+ <s:iterator value="dateChoices" status="status" var="choice">
+ <s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
+ <s:set name="prefix">dateChoice_<s:property
+ value="%{#choiceNumber}"/></s:set>
+ <div id='choicesDATE_<s:property value="choiceNumber"/>'>
+ <s:hidden key='%{#prefix}.topiaId' id='%{#prefix}.topiaId'
+ value='%{#choice.topiaId}' label='' theme="simple"/>
+ <sp:fielderror fieldName="%{#prefix}"/>
+ <div class="fleft choiceName">
+ <s:label for="%{#prefix}.name" id="choicesDATE_label_%{choiceNumber}"
+ theme="simple" value=''/>
+ <sj:datepicker id='%{#prefix}.name' key="%{#prefix}.name"
+ changeMonth="true"
+ changeYear="true" labelSeparator="" theme="simple"
+ label=""
+ timepicker="true" value="%{#choice.date}"
+ displayFormat="%{getText('pollen.common.datePickerPattern')}"
disabled="%{voteStarted}"/>
- -
- <s:label for="%{#prefix}.description" key="pollen.common.description"
- theme="simple"/>
- <%--/div>
- <div class="fleft"--%>
- <s:textarea cols="30" id="%{#prefix}.description" label=''
- theme="simple"
- key="%{#prefix}.description"
- value="%{#choice.description}"
- disabled="%{voteStarted}"/>
- </div>
- <s:if test="!voteStarted">
- <div class="fright">
- <s:a id='choicesTEXT_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
- </s:a>
- <s:a id='choicesTEXT_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a>
- <s:a href='#'
- onclick="return deleteChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- </div>
- </s:if>
- <div class="cleanBoth"></div>
+ -
+ <s:label for="%{#prefix}.description" key="pollen.common.description"
+ theme="simple"/>
</div>
- </s:iterator>
- </div>
- <div id="choicesDATE" class="choices">
- <s:iterator value="dateChoices" status="status" var="choice">
- <s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
- <s:set name="prefix">dateChoice_<s:property
- value="%{#choiceNumber}"/></s:set>
- <div id='choicesDATE_<s:property value="choiceNumber"/>'>
- <s:hidden key='%{#prefix}.topiaId' id='%{#prefix}.topiaId'
- value='%{#choice.topiaId}' label='' theme="simple"/>
- <sp:fielderror fieldName="%{#prefix}"/>
- <div class="fleft choiceName">
- <s:label for="%{#prefix}.name" id="choicesDATE_label_%{choiceNumber}"
- theme="simple" value=''/>
- <sj:datepicker id='%{#prefix}.name' key="%{#prefix}.name"
- changeMonth="true"
- changeYear="true" labelSeparator="" theme="simple"
- label=""
- timepicker="true" value="%{#choice.date}"
- displayFormat="%{getText('pollen.common.datePickerPattern')}"
- disabled="%{voteStarted}"/>
- -
- <s:label for="%{#prefix}.description" key="pollen.common.description"
- theme="simple"/>
+ <div class="fleft">
+ <s:textarea cols="30" id="%{#prefix}.description"
+ key="%{#prefix}.description" label='' theme="simple"
+ value="%{#choice.description}"
+ disabled="%{voteStarted}"/>
+ </div>
+ <s:if test="!voteStarted">
+ <div class="fright">
+ <s:a id='choicesDATE_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesDATE_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a>
+ <s:a href='#'
+ onclick="return deleteChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
</div>
- <div class="fleft">
- <s:textarea cols="30" id="%{#prefix}.description"
- key="%{#prefix}.description" label='' theme="simple"
- value="%{#choice.description}"
- disabled="%{voteStarted}"/>
- </div>
- <s:if test="!voteStarted">
- <div class="fright">
- <s:a id='choicesDATE_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
- </s:a>
- <s:a id='choicesDATE_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a>
- <s:a href='#'
- onclick="return deleteChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- </div>
+ </s:if>
+ <div class="cleanBoth"></div>
+ </div>
+ </s:iterator>
+</div>
+<div id="choicesIMAGE" class="choices">
+ <s:iterator value="imageChoices" status="status" var="choice">
+ <s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
+ <s:set name="prefix">imageChoice_<s:property
+ value="%{#choiceNumber}"/></s:set>
+ <div id='choicesIMAGE_<s:property value="choiceNumber"/>'>
+ <s:hidden key='%{#prefix}.topiaId' value='%{#choice.topiaId}' label=''/>
+ <sp:fielderror fieldName="%{#prefix}"/>
+ <div class="fleft choiceName">
+ <s:label for="%{#prefix}.name" id="choicesIMAGE_label_%{choiceNumber}"
+ theme="simple" value=''/>
+ <s:if test="#choice.name != null">
+
+ <%--Uploaded image--%>
+ <s:hidden id="%{#prefix}.name" name="%{#prefix}.name"
+ value="%{#choice.name}" label='' theme="simple"/>
+
+ <s:hidden id="%{#prefix}.location" name="%{#prefix}.location"
+ value="%{#choice.location}" label='' theme="simple"/>
+ <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage"
+ escapeAmp="false">
+ <s:param name="choiceId" value="%{#choice.name}"/>
+ <s:param name="pollId" value="poll.pollId"/>
+ <s:param name="thumb" value="true"/>
+ </s:url>
+ <img name="<s:property value="#prefix"/>.thumb"
+ alt="<s:property value='name'/>"
+ title="<s:property value='name'/>"
+ src="<s:property value='imageUrl'/>">
+
+ <!--s:label label='' theme="simple" cssClass="nameField"
+ value="%{#choice.name}" readonly="true"/-->
</s:if>
- <div class="cleanBoth"></div>
- </div>
- </s:iterator>
- </div>
- <div id="choicesIMAGE" class="choices">
- <s:iterator value="imageChoices" status="status" var="choice">
- <s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
- <s:set name="prefix">imageChoice_<s:property
- value="%{#choiceNumber}"/></s:set>
- <div id='choicesIMAGE_<s:property value="choiceNumber"/>'>
- <s:hidden key='%{#prefix}.topiaId' value='%{#choice.topiaId}' label=''/>
- <sp:fielderror fieldName="%{#prefix}"/>
- <div class="fleft choiceName">
- <s:label for="%{#prefix}.name" id="choicesIMAGE_label_%{choiceNumber}"
- theme="simple" value=''/>
- <s:if test="#choice.name != null">
+ <s:else>
+ <%--New image--%>
+ <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage"
+ escapeAmp="false" value="/img/7ter.jpg">
+ <s:param name="choiceId" value="%{#choice.name}"/>
+ <s:param name="pollId" value="poll.pollId"/>
+ <s:param name="thumb" value="true"/>
+ </s:url>
+ <img name="<s:property value="#prefix"/>.thumb"
+ alt="<s:text name='pollen.image.not.loaded'/>"
+ title="<s:text name='pollen.image.not.loaded'/>"
+ src="<s:property value='imageUrl'/>" width="100px" height="75px">
+ <span style="float: left; margin-left:50px; ">
+ <s:file key='imageChoice[%{#choiceNumber}]' label=''
+ theme="simple"
+ cssClass="nameField"
+ disabled="%{voteStarted}" cssStyle="clear: both;"/>
+ </span>
- <%--Uploaded image--%>
- <s:hidden id="%{#prefix}.name" name="%{#prefix}.name"
- value="%{#choice.name}" label='' theme="simple"/>
+ </s:else>
- <s:hidden id="%{#prefix}.location" name="%{#prefix}.location"
- value="%{#choice.location}" label='' theme="simple"/>
-
- <s:label label='' theme="simple" cssClass="nameField"
- value="%{#choice.name}" readonly="true"/>
- </s:if>
- <s:else>
- <%--New image--%>
- <s:file key='imageChoice[%{#choiceNumber}]' label='' theme="simple"
- cssClass="nameField"
+ </div>
+ <div class="fleft">
+ -
+ <s:label for="%{#prefix}.description" key="pollen.common.description"
+ theme="simple"/>
+ <s:textarea cols="30" id="%{#prefix}.description" label=''
+ theme="simple"
+ key="%{#prefix}.description"
+ value="%{#choice.description}"
disabled="%{voteStarted}"/>
- </s:else>
- -
- <s:label for="%{#prefix}.description" key="pollen.common.description"
- theme="simple"/>
+ </div>
+ <s:if test="!voteStarted">
+ <div class="fright">
+ <s:a id='choicesIMAGE_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesIMAGE_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a>
+ <s:a href='#'
+ onclick="return deleteChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
</div>
- <div class="fleft">
- <s:textarea cols="30" id="%{#prefix}.description" label=''
- theme="simple"
- key="%{#prefix}.description"
- value="%{#choice.description}"
- disabled="%{voteStarted}"/>
- </div>
- <s:if test="!voteStarted">
- <div class="fright">
- <s:a id='choicesIMAGE_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
- </s:a>
- <s:a id='choicesIMAGE_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a>
- <s:a href='#'
- onclick="return deleteChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- </div>
- </s:if>
+ </s:if>
- <div class="cleanBoth"></div>
- </div>
- </s:iterator>
- </div>
- <hr/>
- <s:submit key="pollen.action.addChoice" align="center"
- onclick="return addNewChoice();" disabled="%{voteStarted}"/>
+ <div class="cleanBoth"></div>
+ </div>
+ </s:iterator>
+</div>
+<hr/>
+<s:submit key="pollen.action.addChoice" align="center"
+ onclick="return addNewChoice();" disabled="%{voteStarted}"/>
</fieldset>
\ No newline at end of file
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayDateChoice.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayDateChoice.jsp 2012-05-18 06:52:21 UTC (rev 3372)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayDateChoice.jsp 2012-05-18 07:40:41 UTC (rev 3373)
@@ -48,12 +48,7 @@
value="%{choice.description}"/>
</div>
<div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- <%--s:a id='choicesDATE_down_%{choiceNumber}'
+ <s:a id='choicesDATE_down_%{choiceNumber}'
cssClass="hidden" href='#'
onclick="return downChoice('choicesDATE_%{choiceNumber}')">
<image alt='<s:property value="downTitle"/>'
@@ -65,7 +60,12 @@
<image alt='<s:property value="upTitle"/>'
title='<s:property value="upTitle"/>'
src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
+ </s:a>
+ <s:a href='#' onclick="return deleteChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
</div>
<div class="cleanBoth"></div>
</div>
\ No newline at end of file
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayImageChoice.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayImageChoice.jsp 2012-05-18 06:52:21 UTC (rev 3372)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayImageChoice.jsp 2012-05-18 07:40:41 UTC (rev 3373)
@@ -34,37 +34,49 @@
<div class="fleft choiceName">
<s:label for="%{#prefix}.name" id="choicesIMAGE_label_%{choiceNumber}"
theme="simple" value=''/>
- <s:if test="choice.name != ''">
+ <%--<s:if test="choice.name != ''">--%>
- <%--Uploaded image--%>
- <s:hidden id="%{#prefix}.name" name="%{#prefix}.name"
- value="%{choice.name}" label='' theme="simple"/>
+ <%--<%–Uploaded image–%>--%>
+ <%--<s:hidden id="%{#prefix}.name" name="%{#prefix}.name"--%>
+ <%--value="%{choice.name}" label='' theme="simple"/>--%>
- <s:hidden id="%{#prefix}.location" name="%{#prefix}.location"
- value="%{choice.location}" label='' theme="simple"/>
+ <%--<s:hidden id="%{#prefix}.location" name="%{#prefix}.location"--%>
+ <%--value="%{choice.location}" label='' theme="simple"/>--%>
- <s:label label='' theme="simple" cssClass="nameField"
- value="%{choice.name}" readonly="true"/>
- </s:if>
- <s:else>
+ <%--<s:label label='' theme="simple" cssClass="nameField"--%>
+ <%--value="%{choice.name}" readonly="true"/>--%>
+ <%--</s:if>--%>
+ <%--<s:else>--%>
<%--New image--%>
- <s:file key='%{#prefix2}' label='' theme="simple" cssClass="nameField"/>
- </s:else>
+ <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage"
+ escapeAmp="false" value="/img/7ter.jpg">
+ <s:param name="choiceId" value="%{#choice.name}"/>
+ <s:param name="pollId" value="poll.pollId"/>
+ <s:param name="thumb" value="true"/>
+ </s:url>
+ <img name="<s:property value="#prefix"/>.thumb"
+ alt="<s:text name='pollen.image.not.loaded'/>"
+ title="<s:text name='pollen.image.not.loaded'/>"
+ src="<s:property value='imageUrl'/>" width="100px" height="75">
+ <span style="float: left; margin-left:50px; ">
+ <s:file key='%{#prefix2}' label=''
+ theme="simple"
+ cssClass="nameField"
+ disabled="%{voteStarted}" cssStyle="clear: both;"/>
+ </span>
+
+ <%--<s:file key='%{#prefix2}' label='' theme="simple" cssClass="nameField"/>--%>
+ <%--</s:else>--%>
+ </div>
+ <div class="fleft">
-
<s:label for="%{#prefix}.description" key="pollen.common.description"
theme="simple"/>
- </div>
- <div class="fleft">
<s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple"
key="%{#prefix}.description" value="%{choice.description}"/>
</div>
<div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- <%--s:a id='choicesIMAGE_down_%{choiceNumber}'
+ <s:a id='choicesIMAGE_down_%{choiceNumber}'
cssClass="hidden" href='#'
onclick="return downChoice('choicesIMAGE_%{choiceNumber}')">
<image alt='<s:property value="downTitle"/>'
@@ -76,7 +88,12 @@
<image alt='<s:property value="upTitle"/>'
title='<s:property value="upTitle"/>'
src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
+ </s:a>
+ <s:a href='#' onclick="return deleteChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
</div>
<div class="cleanBoth"></div>
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayTextChoice.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayTextChoice.jsp 2012-05-18 06:52:21 UTC (rev 3372)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/displayTextChoice.jsp 2012-05-18 07:40:41 UTC (rev 3373)
@@ -44,12 +44,7 @@
key="%{#prefix}.description" value="%{choice.description}"/>
</div>
<div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="deleteTitle"/>'
- title='<s:property value="deleteTitle"/>'
- src="<s:url value='/img/delete.png'/>"></image>
- </s:a>
- <%--s:a id='choicesTEXT_down_%{choiceNumber}'
+ <s:a id='choicesTEXT_down_%{choiceNumber}'
cssClass="hidden" href='#'
onclick="return downChoice('choicesTEXT_%{choiceNumber}')">
<image alt='<s:property value="downTitle"/>'
@@ -61,7 +56,12 @@
<image alt='<s:property value="upTitle"/>'
title='<s:property value="upTitle"/>'
src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
+ </s:a>
+ <s:a href='#' onclick="return deleteChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="deleteTitle"/>'
+ title='<s:property value="deleteTitle"/>'
+ src="<s:url value='/img/delete.png'/>"></image>
+ </s:a>
</div>
<div class="cleanBoth"></div>
</div>
\ No newline at end of file
Modified: trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js 2012-05-18 06:52:21 UTC (rev 3372)
+++ trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js 2012-05-18 07:40:41 UTC (rev 3373)
@@ -506,6 +506,9 @@
// change location
switchValue(choicePrefix, choiceNumber, newChoiceNumber, '.location');
+
+ // change thumb
+ switchThumb(choicePrefix, choiceNumber, newChoiceNumber);
}
return false;
}
@@ -520,6 +523,17 @@
newChoiceTI.val(choiceTIVal);
}
+function switchThumb(choicePrefix, choiceNumber, newChoiceNumber) {
+ var choiceTI = $('[name="' + choicePrefix + choiceNumber + '.thumb"]');
+ var newChoiceTI = $('[name="' + choicePrefix + newChoiceNumber + '.thumb"]');
+
+ var choiceTIVal = choiceTI.val();
+ var newChoiceTIVal = newChoiceTI.val();
+ console.info("switch " + choiceTIVal + " to " + newChoiceTIVal);
+ choiceTI.val(newChoiceTIVal);
+ newChoiceTI.val(choiceTIVal);
+}
+
function confirmClose() {
$('.ui-dialog-title').html(datas['confirmCloseTitle'])
var dialog = $("#confirmDialog");
1
0
Author: tchemit
Date: 2012-05-18 08:52:21 +0200 (Fri, 18 May 2012)
New Revision: 3372
Url: http://chorem.org/repositories/revision/pollen/3372
Log:
fixes #154: [Poll] Impossible de choisir l'ordre des choix
fixes #561: Can not create a image poll
Un petit coup de menage, car y'a des choses qui fonctionnent pas et sont tr?\195?\168s compliqu?\195?\169es pour rien au final...
Added:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
Modified:
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallback.java
trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3.java
trunk/pollen-persistence/src/main/xmi/pollen.properties
trunk/pollen-persistence/src/main/xmi/pollen.zargo
trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollDateChoice.java
trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollImageChoice.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/FileUploadAware.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/PollenFileUploadInterceptor.java
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp
trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallback.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallback.java 2012-05-18 00:56:32 UTC (rev 3371)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallback.java 2012-05-18 06:52:21 UTC (rev 3372)
@@ -44,9 +44,11 @@
public static final Version V_1_3 = VersionUtil.valueOf("1.3");
+ public static final Version V_1_4 = VersionUtil.valueOf("1.4");
+
/** Les versions de mise à jour disponibles. */
public static final Version[] AVAILABLE_VERSIONS = new Version[]{
- V_1_1, V_1_2, V_1_3
+ V_1_1, V_1_2, V_1_3, V_1_4
};
public PollenMigrationCallback() {
Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3.java 2012-05-18 00:56:32 UTC (rev 3371)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_3.java 2012-05-18 06:52:21 UTC (rev 3372)
@@ -43,7 +43,7 @@
import java.util.Map;
/**
- * Migration for version {@code 1.2.6}.
+ * Migration for version {@code 1.3}.
*
* @author tchemit <chemit(a)codelutin.com>
* @since 1.3
Added: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java
===================================================================
--- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java (rev 0)
+++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-05-18 06:52:21 UTC (rev 3372)
@@ -0,0 +1,101 @@
+package org.chorem.pollen.entities.migration;
+
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaContextImplementor;
+import org.nuiton.topia.framework.TopiaSQLQuery;
+import org.nuiton.topia.migration.TopiaMigrationCallbackByClass;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+/**
+ * Migration for version {@code 1.4}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.4
+ */
+public class PollenMigrationCallbackV1_4 extends TopiaMigrationCallbackByClass.MigrationCallBackForVersion {
+
+ public PollenMigrationCallbackV1_4(TopiaMigrationCallbackByClass callBack) {
+ super(PollenMigrationCallback.V_1_4, callBack);
+ }
+
+ @Override
+ protected void prepareMigrationScript(TopiaContextImplementor tx,
+ List<String> queries,
+ boolean showSql,
+ boolean showProgression) throws TopiaException {
+
+ // add indexed choices (says there is an order kept in db) : http://chorem.org/issues/154
+ addIndexedChoices(tx, queries);
+
+ }
+
+ private void addIndexedChoices(TopiaContextImplementor tx,
+ List<String> queries) throws TopiaException {
+
+ queries.add("ALTER TABLE choice ADD COLUMN poll_idx INTEGER;");
+
+ // get all polls
+
+
+ TopiaSQLQuery<String> getAllPollsQuery = new TopiaSQLQuery<String>() {
+
+ @Override
+ protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
+ PreparedStatement ps = connection.prepareStatement("select distinct(poll) from choice;");
+ return ps;
+ }
+
+ @Override
+ protected String prepareResult(ResultSet set) throws SQLException {
+ return set.getString(1);
+ }
+ };
+ List<String> pollIds = getAllPollsQuery.findMultipleResult(tx);
+
+ String choiceUpdate = "UPDATE choice SET poll_idx = %s WHERE topiaid = '%s';";
+
+ for (final String pollId : pollIds) {
+
+ // get all choice ids for this poll
+ List<String> choiceIds =
+ new GetChoiceIdsSQLQuery(pollId).findMultipleResult(tx);
+
+ int index = 0;
+ for (String choiceId : choiceIds) {
+ queries.add(String.format(choiceUpdate, index++, choiceId));
+ }
+
+ }
+
+ // now can add not null constraints
+ // can not use this strong not null constraint, hibernate will at create time let a null value here :(
+// queries.add("ALTER TABLE choice ALTER COLUMN poll_idx SET NOT NULL;");
+ }
+
+ private static class GetChoiceIdsSQLQuery extends TopiaSQLQuery<String> {
+
+ private final String pollId;
+
+ public GetChoiceIdsSQLQuery(String pollId) {
+ this.pollId = pollId;
+ }
+
+ @Override
+ protected PreparedStatement prepareQuery(Connection connection) throws SQLException {
+ PreparedStatement ps = connection.prepareStatement(
+ "SELECT topiaid FROM choice WHERE poll = ? ORDER BY topiacreatedate;");
+ ps.setString(1, pollId);
+ return ps;
+ }
+
+ @Override
+ protected String prepareResult(ResultSet set) throws SQLException {
+ return set.getString(1);
+ }
+ }
+}
Modified: trunk/pollen-persistence/src/main/xmi/pollen.properties
===================================================================
--- trunk/pollen-persistence/src/main/xmi/pollen.properties 2012-05-18 00:56:32 UTC (rev 3371)
+++ trunk/pollen-persistence/src/main/xmi/pollen.properties 2012-05-18 06:52:21 UTC (rev 3372)
@@ -25,12 +25,11 @@
#model.tagvalue.dbSchema=Pollen
model.tagvalue.constantPrefix=PROPERTY_
model.tagvalue.java.lang.String=text
-model.tagvalue.version=1.3
+model.tagvalue.version=1.4
model.tagvalue.doNotGenerateBooleanGetMethods=true
model.tagvalue.indexForeignKeys=true
-org.chorem.pollen.business.persistence.Poll.attribute.choice.stereotype=ordered
-org.chorem.pollen.business.persistence.Poll.attribute.choice.tagvalue.orderBy=topiaCreateDate
+org.chorem.pollen.business.persistence.Poll.attribute.choice.stereotype=indexed
org.chorem.pollen.business.persistence.Poll.attribute.vote.stereotype=ordered
org.chorem.pollen.business.persistence.Poll.attribute.vote.tagvalue.orderBy=topiaCreateDate
Modified: trunk/pollen-persistence/src/main/xmi/pollen.zargo
===================================================================
(Binary files differ)
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollDateChoice.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollDateChoice.java 2012-05-18 00:56:32 UTC (rev 3371)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollDateChoice.java 2012-05-18 06:52:21 UTC (rev 3372)
@@ -56,7 +56,6 @@
setDescription(choice.getDescription());
setTopiaId(choice.getTopiaId());
setValidate(choice.isValidate());
- setPoll(choice.getPoll());
setDate(new Date(Long.valueOf(choice.getName())));
}
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollImageChoice.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollImageChoice.java 2012-05-18 00:56:32 UTC (rev 3371)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/bean/PollImageChoice.java 2012-05-18 06:52:21 UTC (rev 3372)
@@ -54,7 +54,6 @@
setDescription(choice.getDescription());
setTopiaId(choice.getTopiaId());
setValidate(choice.isValidate());
- setPoll(choice.getPoll());
}
public void toChoice(Choice choice) {
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-05-18 00:56:32 UTC (rev 3371)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollFeedService.java 2012-05-18 06:52:21 UTC (rev 3372)
@@ -146,14 +146,14 @@
addFeedEntry(vote.getPoll(), title, content, pollVoteUrl);
}
- public void onAddChoice(Choice choice, PollUrl pollVoteUrl) {
+ public void onAddChoice(Poll poll, Choice choice, PollUrl pollVoteUrl) {
String title = _("pollen.feed.addChoiceTitle", choice.getName());
String content = _("pollen.feed.addChoiceContent",
choice.getDescription());
- addFeedEntry(choice.getPoll(), title, content, pollVoteUrl);
+ addFeedEntry(poll, title, content, pollVoteUrl);
}
/**
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-05-18 00:56:32 UTC (rev 3371)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/PollService.java 2012-05-18 06:52:21 UTC (rev 3372)
@@ -26,11 +26,8 @@
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
-import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@@ -79,7 +76,6 @@
import java.util.Date;
import java.util.List;
import java.util.Map;
-import java.util.Set;
public class PollService extends PollenServiceSupport {
@@ -132,12 +128,12 @@
* matches an existing {@link UserAccount}, the resulting poll creator will
* be attached to it.
*
- * @param pollUid Uid of the poll to edit, if not defined, a new poll is instanciated
+ * @param pollUid Uid of the poll to edit, if not defined, a new poll is instanciated
* @param userAccount User account to attach to the creator
- * @param clone Flag to copy or not ids in case of poll cloning
- * @return the Poll ready for edition (no longer linked to the topia context)
+ * @param clone Flag to copy or not ids in case of poll cloning
+ * @return the Poll ready for edition (no longer linked to the topia context)
* @see #getNewPoll(UserAccount)
- * @see #getNewPollCopy(Poll, UserAccount, boolean)
+ * @see #getNewPollCopy(Poll, UserAccount, boolean)
*/
public Poll getPollEditable(String pollUid, UserAccount userAccount, boolean clone) {
@@ -151,18 +147,18 @@
if (poll == null) {
result = getNewPoll(userAccount);
-
+
} else {
- result = getNewPollCopy(poll, userAccount, clone);
+ result = getNewPollCopy(poll, userAccount, clone);
}
}
return result;
}
-
+
protected Poll getNewPollCopy(Poll source, UserAccount userAccount, boolean clone) {
-
+
Preconditions.checkNotNull(source);
-
+
PollDAO pollDAO = getDAO(Poll.class);
Poll result = newInstance(pollDAO);
@@ -245,7 +241,7 @@
// Load votes to have the correct size used to check if vote is started
result.setVote(source.getVote());
-
+
return result;
}
@@ -354,27 +350,19 @@
// -- Choices -- //
if (!voteStarted) {
-
- // Retrieve previous existing choices
- Map<String, Choice> choicesExist = Maps.uniqueIndex(
- pollToUpdate.getChoice(),
- PollenServiceFunctions.newTopiaIdExtractor()
- );
-
+
// Save all choices from source poll
- Set<String> choicesAdded = Sets.newHashSet();
+ List<Choice> choicesAdded = Lists.newLinkedList();
for (Choice choice : poll.getChoice()) {
- String choiceId = saveChoice(pollToUpdate, choice);
- choicesAdded.add(choiceId);
+ Choice choiceLoaded = saveChoice(pollToUpdate, choice);
+ choicesAdded.add(choiceLoaded);
}
-
- // Delete all previous choices not keeped in source poll
- Map<String, Choice> choicesToDelete =
- Maps.filterKeys(choicesExist,
- Predicates.not(Predicates.in(choicesAdded)));
- for (Choice choice : choicesToDelete.values()) {
- pollToUpdate.removeChoice(choice);
- }
+
+ // removed choice will be deleted from db by composition relation
+ pollToUpdate.clearChoice();
+
+ // re-add choices in incoming order.
+ pollToUpdate.addAllChoice(choicesAdded);
}
// -- PreventRules -- //
@@ -403,12 +391,12 @@
URL applicationUrl = serviceContext.getApplicationURL();
String baseUrl = applicationUrl + "/poll/votefor/";
PollUri pollUri = PollUri.newPollUri(poll.getPollId());
-
+
if (moderate) {
String creatorId = poll.getCreator().getAccountId();
pollUri.setAccountId(creatorId);
}
-
+
PollUrl result = PollUrl.newPollUrl(baseUrl, pollUri);
return result;
}
@@ -484,24 +472,6 @@
} catch (TopiaException e) {
throw new PollenTechnicalException("Could not obtain invited polls", e);
}
-
-// try {
-// PollDAO dao = PollenDAOHelper.getPollDAO(getTransaction());
-// TopiaQuery countQuery = dao.createQuery("e");
-// countQuery.addWhere("e." + Poll.PROPERTY_CREATOR + "." + PollAccount.PROPERTY_USER_ACCOUNT, TopiaQuery.Op.EQ, user);
-// long records = dao.countByQuery(countQuery);
-// pager.setRecords((int) records);
-//
-// PagerUtil.computeRecordIndexesAndPagesNumber(pager);
-// TopiaQuery query = dao.createQuery("e");
-// TopiaFilterPagerUtil.addPagerToQuery(pager, query);
-// query.addWhere("e." + Poll.PROPERTY_CREATOR + "." + PollAccount.PROPERTY_USER_ACCOUNT, TopiaQuery.Op.EQ, user);
-//
-// List<Poll> result = dao.findAllByQuery(query);
-// return result;
-// } catch (TopiaException e) {
-// throw new PollenTechnicalException(e);
-// }
}
public Map<Poll, PollAccount> getParticipatedPolls(
@@ -558,12 +528,12 @@
* create or update is done here. The {@code poll} is used to retrieve a potential
* existing vote with pollAccount linked to {@code userAccount}.
*
- * @param accountId Id of the existing account (optional)
+ * @param accountId Id of the existing account (optional)
* @param userAccount UserAccount where account will be attached (optional)
- * @param poll Poll where pollAccount will be added
+ * @param poll Poll where pollAccount will be added
* @return the existing PollAccount or a new instance
* @throws PollAccountNotFound if accountId is defined and doesn't match any
- * existing PollAccount
+ * existing PollAccount
*/
public PollAccount getPollAccountEditable(String accountId, UserAccount userAccount, Poll poll) throws PollAccountNotFound {
PollAccount result = null;
@@ -741,7 +711,7 @@
return result;
}
- public void createChoice(String pollId, Choice choice) throws PollNotFoundException {
+ public void addChoice(String pollId, Choice choice) throws PollNotFoundException {
Preconditions.checkNotNull(pollId);
Preconditions.checkNotNull(choice);
@@ -752,12 +722,15 @@
throw new PollNotFoundException();
}
- saveChoice(poll, choice);
+ Choice choiceAdded = saveChoice(poll, choice);
- commitTransaction("Can't create new choice [" + poll.getChoiceType() + "] for poll '" + pollId + "'");
+ poll.addChoice(choiceAdded);
+
+ commitTransaction("Can't create new choice [" +
+ poll.getChoiceType() + "] for poll '" + pollId + "'");
}
- protected String saveChoice(Poll poll, Choice choice) {
+ protected Choice saveChoice(Poll poll, Choice choice) {
ChoiceType choiceType = poll.getChoiceType();
ChoiceDAO dao = getDAO(Choice.class);
@@ -772,15 +745,18 @@
if (choiceType == ChoiceType.IMAGE) {
- // copy image where it belong and generate the thumb
PollImageChoice imageChoice = (PollImageChoice) choice;
imageChoice.toChoice(choiceLoaded);
- try {
- saveImages(poll, imageChoice);
- } catch (IOException e) {
- throw new PollenTechnicalException(
- "Could not create image choice", e);
+ if (choice.getTopiaId() == null) {
+ // copy image where it belong and generate the thumb
+ // only if choice is to create
+ try {
+ saveImages(poll, imageChoice);
+ } catch (IOException e) {
+ throw new PollenTechnicalException(
+ "Could not create image choice", e);
+ }
}
} else if (choiceType == ChoiceType.DATE) {
@@ -797,8 +773,8 @@
choiceLoaded.setValidate(choice.isValidate());
choiceLoaded.setName(choice.getName());
}
-
- return choiceLoaded.getTopiaId();
+
+ return choiceLoaded;
}
public void deleteChoice(String pollId, String choiceId)
@@ -961,7 +937,7 @@
Vote voteToAdd = getEntityById(Vote.class, voteId);
pollToUpdate.addVote(voteToAdd);
-
+
// Update hasVoted flag for RESTRICTED/GROUP poll
if (PollType.FREE != poll.getPollType()) {
@@ -1015,7 +991,7 @@
result.setName(votingList.getName());
result.setWeight(votingList.getWeight());
-
+
PollUrl voteURL = getPollVoteUrl(poll, false);
// Merge PersonToList
@@ -1023,7 +999,7 @@
for (PersonToList personToList : votingList.getPollAccountPersonToList()) {
PollAccount pollAccount = personToList.getPollAccount();
-
+
PersonToList personToListLoaded;
PollAccount pollAccountLoaded;
if (personToList.getTopiaId() == null) {
@@ -1040,11 +1016,11 @@
}
pollAccountLoaded = pollAccountDAO.findByAccountId(accountId);
- if (pollAccountLoaded == null) {
+ if (pollAccountLoaded == null) {
pollAccountLoaded = create(pollAccountDAO);
pollAccountLoaded.setAccountId(accountId);
}
-
+
} else {
personToListLoaded = getEntityById(PersonToList.class, personToList.getTopiaId());
pollAccountLoaded = personToListLoaded.getPollAccount();
@@ -1071,7 +1047,7 @@
}
result.setPollAccountPersonToList(personToListsUpdated);
}
-
+
protected void savePreventRule(Poll poll, PreventRule preventRule) {
PreventRuleDAO preventRuleDAO = getDAO(PreventRule.class);
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/FileUploadAware.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/FileUploadAware.java 2012-05-18 00:56:32 UTC (rev 3371)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/FileUploadAware.java 2012-05-18 06:52:21 UTC (rev 3372)
@@ -23,19 +23,28 @@
*/
package org.chorem.pollen.ui.actions;
+import org.chorem.pollen.ui.interceptors.PollenFileUploadInterceptor;
+
import java.io.File;
-import java.util.List;
/**
+ * Contract to place on actions which needs some upload.
+ * <p/>
+ * This is linked with the {@link PollenFileUploadInterceptor} interceptor
+ * which logic is not the same than the bacis struts2 upload interceptor.
+ * <p/>
* Created: 30/03/12
*
* @author fdesbois <desbois(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.3
*/
public interface FileUploadAware {
- void setFiles(String paramName, List<File> files);
+ void addFile(int index, File file);
- void setFileContentTypes(String paramName, List<String> contentTypes);
+ void addFileContentType(int index, String contentType);
- void setFileNames(String paramName, List<String> fileNames);
+ void addFileName(int index, String fileName);
+
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java 2012-05-18 00:56:32 UTC (rev 3371)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java 2012-05-18 06:52:21 UTC (rev 3372)
@@ -24,7 +24,6 @@
package org.chorem.pollen.ui.actions.poll;
import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.interceptor.annotations.InputConfig;
import org.apache.commons.lang3.StringUtils;
@@ -36,7 +35,6 @@
import org.chorem.pollen.ui.actions.FileUploadAware;
import java.io.File;
-import java.util.List;
/**
* To add a poll comment.
@@ -50,52 +48,31 @@
protected Choice choice;
- private List<File> imageChoices;
+ private File imageChoice;
- private List<String> imageChoiceContentTypes;
+ private String imageChoiceContentType;
- private List<String> imageChoiceFileNames;
+ private String imageChoiceFileName;
public Choice getChoice() {
return choice;
}
@Override
- public void setFiles(String paramName, List<File> files) {
- this.imageChoices = Lists.newArrayList(files);
+ public void addFile(int index, File file) {
+ imageChoice = file;
}
@Override
- public void setFileContentTypes(String paramName, List<String> contentTypes) {
- this.imageChoiceContentTypes = Lists.newArrayList(contentTypes);
+ public void addFileContentType(int index, String contentType) {
+ imageChoiceContentType = contentType;
}
@Override
- public void setFileNames(String paramName, List<String> fileNames) {
- this.imageChoiceFileNames = Lists.newArrayList(fileNames);
+ public void addFileName(int index, String fileName) {
+ imageChoiceFileName = fileName;
}
- public List<File> getImageChoices() {
- if (imageChoices == null) {
- imageChoices = Lists.newArrayList();
- }
- return imageChoices;
- }
-
- public List<String> getImageChoiceContentTypes() {
- if (imageChoiceContentTypes == null) {
- imageChoiceContentTypes = Lists.newArrayList();
- }
- return imageChoiceContentTypes;
- }
-
- public List<String> getImageChoiceFileNames() {
- if (imageChoiceFileNames == null) {
- imageChoiceFileNames = Lists.newArrayList();
- }
- return imageChoiceFileNames;
- }
-
@Override
public void prepare() throws PollNotFoundException {
@@ -105,12 +82,12 @@
choice = getPollService().getNewChoice(choiceType);
// Push image choice data from uploaded file
- if (ChoiceType.IMAGE == choiceType && getImageChoices().size() == 1) {
+ if (ChoiceType.IMAGE == choiceType && imageChoice != null) {
- String fileName = getImageChoiceFileNames().get(0);
- String location = getImageChoices().get(0).getAbsolutePath();
+ String fileName = imageChoiceFileName;
+ String location = imageChoice.getAbsolutePath();
choice.setName(fileName);
- ((PollImageChoice)choice).setLocation(location);
+ ((PollImageChoice) choice).setLocation(location);
}
}
@@ -120,7 +97,7 @@
ChoiceType choiceType = getPoll().getChoiceType();
String propName = ChoiceHelper.getValuePropertyName(choiceType);
-
+
Object value = ChoiceHelper.toValue(choice, choiceType);
// -- Validate value notEmpty
@@ -145,7 +122,7 @@
@Override
public String execute() throws Exception {
- getPollService().createChoice(getPollId(), choice);
+ getPollService().addChoice(getPollId(), choice);
return SUCCESS;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java 2012-05-18 00:56:32 UTC (rev 3371)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SavePoll.java 2012-05-18 06:52:21 UTC (rev 3372)
@@ -87,15 +87,6 @@
private static final Pattern IMAGE_CHOICE_NAME_PATTERN =
Pattern.compile("imageChoice_(\\d+)\\.name");
- /** Uploaded images (for choice type poll). */
- private List<File> imageChoice;
-
- /** Uploaded images content type (for choice type poll). */
- private List<String> imageChoiceContentType;
-
- /** Uploaded images name (from use desktop) (for choice type poll). */
- private List<String> imageChoiceFileName;
-
/** Flag when there is some errors on the information panel. */
protected boolean informationsError;
@@ -106,7 +97,7 @@
* All the parameters send by request used to build back choices of the
* poll.
*/
- protected Map<String, String[]> parameters;
+ protected final Map<String, String[]> parameters = Maps.newTreeMap();
/**
* Indexed choices retreive from parameters for the choiceType selected in
@@ -137,22 +128,22 @@
userAccount = getPollService().getEntityById(UserAccount.class, userId);
}
}
-
+
poll = getPollService().getPollEditable(pollUid, userAccount, false);
// If vote is started, prepare choices and votingLists is useless
// because they can't be updated.
if (!isVoteStarted()) {
-
+
// Retrieve choiceType from parameters, the poll object will be updated after prepare
String choiceTypeParam = getNonEmptyParameterValue("poll.choiceType");
ChoiceType pollChoiceType = ChoiceType.valueOf(choiceTypeParam);
poll.setChoiceType(pollChoiceType);
-
+
// build poll choices
-
+
switch (pollChoiceType) {
-
+
case TEXT:
choices = buildTextChoices();
break;
@@ -163,30 +154,30 @@
choices = buildImageChoices();
break;
}
-
+
PollType pollType;
String pollTypeParam = getNonEmptyParameterValue("poll.pollType");
if (pollTypeParam == null) {
pollType = poll.getPollType();
-
+
} else {
pollType = PollType.valueOf(pollTypeParam);
}
-
+
switch (pollType) {
-
+
case FREE:
-
+
// empty voting list
votingLists = Maps.newTreeMap();
break;
case RESTRICTED:
-
+
// restricted voting list
votingLists = buildVotingLists(pollType);
break;
case GROUP:
-
+
// group voting lists
votingLists = buildVotingLists(pollType);
break;
@@ -197,9 +188,9 @@
@Override
public String input() {
- Collection<Choice> pollChoices =
+ Collection<Choice> pollChoices =
isVoteStarted() ? poll.getChoice() : choices.values();
- Collection<VotingList> pollVotingLists =
+ Collection<VotingList> pollVotingLists =
isVoteStarted() ? poll.getVotingList() : votingLists.values();
loadChoicesAndvotingLists(poll,
@@ -249,7 +240,7 @@
if (!isLimitChoice()) {
poll.setMaxChoiceNb(0);
}
-
+
poll.clearPreventRule();
PreventRuleService preventRuleService =
@@ -289,51 +280,39 @@
}
@Override
- public void setFiles(String paramName, List<File> files) {
- this.imageChoice = Lists.newArrayList(files);
+ public void addFile(int index, File file) {
+ parameters.put(
+ "imageChoice_" + index + ".location",
+ new String[]{file.getAbsolutePath()});
}
@Override
- public void setFileContentTypes(String paramName, List<String> contentTypes) {
- this.imageChoiceContentType = Lists.newArrayList(contentTypes);
+ public void addFileContentType(int index, String contentType) {
+ // not used here
}
@Override
- public void setFileNames(String paramName, List<String> fileNames) {
- this.imageChoiceFileName = Lists.newArrayList(fileNames);
+ public void addFileName(int index, String fileName) {
+ parameters.put("imageChoice_" + index + ".name",
+ new String[]{fileName});
}
@Override
public void setParameters(Map<String, String[]> parameters) {
- this.parameters = parameters;
+ this.parameters.putAll(parameters);
}
- public List<File> getImageChoice() {
- return imageChoice;
- }
-
- public List<String> getImageChoiceContentType() {
- if (imageChoiceContentType == null) {
- imageChoiceContentType = Lists.newArrayList();
- }
- return imageChoiceContentType;
- }
-
- public List<String> getImageChoiceFileName() {
- if (imageChoiceFileName == null) {
- imageChoiceFileName = Lists.newArrayList();
- }
- return imageChoiceFileName;
- }
-
+ @Override
public boolean isInformationsError() {
return informationsError;
}
+ @Override
public boolean isOptionsError() {
return optionsError;
}
+ @Override
public int getSelectedTab() {
int result;
if (isInformationsError()) {
@@ -415,30 +394,31 @@
}
}
}
-
+
String creatorEmail = poll.getCreator().getEmail();
if (StringUtils.isNotBlank(creatorEmail) && !StringUtil.isEmail(creatorEmail)) {
addOptionsError("poll.creator.email",
_("pollen.error.email.invalid"));
}
-
+
if (validateEndDate(poll.getBeginChoiceDate(), poll.getEndChoiceDate())) {
-
- addOptionsError("poll.endChoiceDate",
- _("pollen.error.poll.endChoiceDate.before.beginChoiceDate"));
+
+ addOptionsError(
+ "poll.endChoiceDate",
+ _("pollen.error.poll.endChoiceDate.before.beginChoiceDate"));
}
if (validateEndDate(poll.getBeginDate(), poll.getEndDate())) {
addOptionsError("poll.endDate",
- _("pollen.error.poll.endDate.before.beginDate"));
+ _("pollen.error.poll.endDate.before.beginDate"));
}
if (validateEndDate(poll.getEndChoiceDate(), poll.getEndDate())) {
addOptionsError("poll.endChoiceDate",
- _("pollen.error.poll.endChoiceDate.after.endDate"));
+ _("pollen.error.poll.endChoiceDate.after.endDate"));
}
}
@@ -447,9 +427,10 @@
Set<String> groups,
Set<String> voters,
Set<String> emails) {
-
+
PollType votingListType = poll.getPollType();
- String fieldNamePrefix = "votingList" + votingListType + "_" + votingListNumber;
+ String fieldNamePrefix = "votingList" + votingListType + "_" +
+ votingListNumber;
if (isGroupPoll()) {
@@ -498,8 +479,9 @@
// check there is at least one voter
- List<PersonToList> personToLists = votingList.getPollAccountPersonToList();
-
+ List<PersonToList> personToLists =
+ votingList.getPollAccountPersonToList();
+
if (CollectionUtils.isEmpty(personToLists)) {
// no personToList found for unique votingList 0
@@ -528,7 +510,7 @@
Set<String> emails) {
String fieldNamePrefix = votingListFieldNamePrefix +
- "PersonToList_" + personToListNumber;
+ "PersonToList_" + personToListNumber;
PollAccount pollAccount = personToList.getPollAccount();
@@ -686,20 +668,6 @@
protected Map<Integer, Choice> buildImageChoices() {
Map<Integer, Choice> result = Maps.newTreeMap();
- // push back in parameters stuff from uploaded files
- int index = 0;
-
- for (String fileName : getImageChoiceFileName()) {
- if (fileName != null) {
- parameters.put("imageChoice_" + index + ".name",
- new String[]{fileName});
- parameters.put(
- "imageChoice_" + index + ".location",
- new String[]{getImageChoice().get(index).getAbsolutePath()});
- }
- index++;
- }
-
int maxNumber = 0;
for (String paramName : parameters.keySet()) {
@@ -788,14 +756,6 @@
for (PersonToList toList : personToList) {
personToListMap.put(index++, toList);
}
-
-// String token = DisplayPersonToList.getPersonToListTokenId(
-// votingListTokenId, votingListNumber);
-// if (log.isInfoEnabled()) {
-// log.info("Add " + token + " with " +
-// personToListMap.size() + " personToList");
-// }
-// getPollenSession().putDynamicData(token, personToListMap);
}
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/PollenFileUploadInterceptor.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/PollenFileUploadInterceptor.java 2012-05-18 00:56:32 UTC (rev 3371)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/PollenFileUploadInterceptor.java 2012-05-18 06:52:21 UTC (rev 3372)
@@ -35,22 +35,19 @@
import javax.servlet.http.HttpServletRequest;
import java.io.File;
-import java.util.ArrayList;
import java.util.Enumeration;
-import java.util.List;
import java.util.Locale;
-import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Overrides the default file upload interceptor to be able to match uploaded
* files in specific fields.
- *
+ * <p/>
* We want to put upload files in a list (field is file for example) and then
* fileName in another list but the default interceptor does not accept this
* since it suffix the filename field with FileName...
- *
+ * <p/>
* TODO tchemit 2012-03-05 submit a patch to struts guys to avoid this fork.
*
* @author tchemit <chemit(a)codelutin.com>
@@ -80,6 +77,12 @@
Object action = invocation.getAction();
+ if (!(action instanceof FileUploadAware)) {
+
+ // only used for our purpose
+ return invocation.invoke();
+ }
+
if (action instanceof ValidationAware) {
validation = (ValidationAware) action;
}
@@ -104,6 +107,14 @@
// get the value of this input tag
String inputName = (String) fileParameterNames.nextElement();
+ Matcher matcher1 = FILENAME_PATTERN.matcher(inputName);
+
+ if (!matcher1.matches()) {
+ throw new IllegalStateException(
+ "Uploaded param name must match " + FILENAME_PATTERN);
+ }
+ Integer suffix = Integer.valueOf(matcher1.group(2));
+
// get the content type
String[] contentType = multiWrapper.getContentTypes(inputName);
@@ -114,50 +125,33 @@
if (isNonEmpty(fileName)) {
// get a File object for the uploaded File
File[] files = multiWrapper.getFiles(inputName);
+
if (files != null && files.length > 0) {
- List<File> acceptedFiles = new ArrayList<File>(files.length);
- List<String> acceptedContentTypes = new ArrayList<String>(files.length);
- List<String> acceptedFileNames = new ArrayList<String>(files.length);
- Matcher matcher1 = FILENAME_PATTERN.matcher(inputName);
-
- String contentTypeName;
- String fileNameName;
- if (matcher1.matches()) {
- String prefix = matcher1.group(1);
- String suffix = matcher1.group(2);
- contentTypeName = prefix + "ContentType[" + suffix + "]";
- fileNameName = prefix + "FileName[" + suffix + "]";
- } else {
- contentTypeName = inputName + "ContentType";
- fileNameName = inputName + "FileName";
+ if (files.length > 1) {
+ throw new IllegalStateException("Only accept one file to upload for name " + inputName);
}
+ File acceptedFile = null;
+ String acceptedContentType = null;
+ String acceptedFileName = null;
- for (int index = 0; index < files.length; index++) {
- if (acceptFile(action, files[index], fileName[index], contentType[index], inputName, validation, ac.getLocale())) {
- acceptedFiles.add(files[index]);
- acceptedContentTypes.add(contentType[index]);
- acceptedFileNames.add(fileName[index]);
- }
- }
- if (!acceptedFiles.isEmpty()) {
+ if (acceptFile(action, files[0], fileName[0], contentType[0], inputName, validation, ac.getLocale())) {
- if (action instanceof FileUploadAware) {
- FileUploadAware fileUpload = (FileUploadAware) action;
+ acceptedFile = files[0];
+ acceptedContentType = contentType[0];
+ acceptedFileName = fileName[0];
+ }
- fileUpload.setFiles(inputName, acceptedFiles);
- fileUpload.setFileContentTypes(contentTypeName, acceptedContentTypes);
- fileUpload.setFileNames(fileNameName, acceptedFileNames);
+ if (acceptedFile != null) {
- } else {
- Map<String, Object> params = ac.getParameters();
+ FileUploadAware fileUpload = (FileUploadAware) action;
- params.put(inputName, acceptedFiles.toArray(new File[acceptedFiles.size()]));
- params.put(contentTypeName, acceptedContentTypes.toArray(new String[acceptedContentTypes.size()]));
- params.put(fileNameName, acceptedFileNames.toArray(new String[acceptedFileNames.size()]));
- }
+ fileUpload.addFile(suffix, acceptedFile);
+ fileUpload.addFileContentType(suffix, acceptedContentType);
+ fileUpload.addFileName(suffix, acceptedFileName);
+
}
}
} else {
@@ -178,13 +172,6 @@
private static final String DEFAULT_MESSAGE = "no.message.found";
-// private PatternMatcher matcher;
-//
-// @Inject
-// public void setMatcher(PatternMatcher matcher) {
-// this.matcher = matcher;
-// }
-
private boolean isNonEmpty(Object[] objArray) {
boolean result = false;
for (int index = 0; index < objArray.length && !result; index++) {
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp 2012-05-18 00:56:32 UTC (rev 3371)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/createPoll_choices.jsp 2012-05-18 06:52:21 UTC (rev 3372)
@@ -32,21 +32,24 @@
<hr/>
<s:fielderror fieldName="poll.choices"/>
- <s:set id='deleteTitle'><s:text name="pollen.action.pollChoiceDelete"/></s:set>
+ <s:set id='deleteTitle'><s:text
+ name="pollen.action.pollChoiceDelete"/></s:set>
<s:set id='upTitle'><s:text name="pollen.action.pollChoiceUp"/></s:set>
<s:set id='downTitle'><s:text name="pollen.action.pollChoiceDown"/></s:set>
<div id="choicesTEXT" class="choices">
<s:iterator value="textChoices" status="status" var="choice">
<s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
- <s:set name="prefix">textChoice_<s:property value="%{#choiceNumber}"/></s:set>
+ <s:set name="prefix">textChoice_<s:property
+ value="%{#choiceNumber}"/></s:set>
<div id='choicesTEXT_<s:property value="choiceNumber"/>'>
<s:hidden key='%{#prefix}.topiaId' value='%{#choice.topiaId}' label=''/>
<sp:fielderror fieldName="%{#prefix}"/>
<div class="fleft choiceName">
<s:label for="%{#prefix}.name" id="choicesTEXT_label_%{#choiceNumber}"
theme="simple" value=''/>
- <s:textfield cssClass="nameField" id='%{#prefix}.name' key="%{#prefix}.name"
+ <s:textfield cssClass="nameField" id='%{#prefix}.name'
+ key="%{#prefix}.name"
label='' theme="simple" value="%{#choice.name}"
disabled="%{voteStarted}"/>
-
@@ -54,30 +57,33 @@
theme="simple"/>
<%--/div>
<div class="fleft"--%>
- <s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple"
- key="%{#prefix}.description" value="%{#choice.description}"
+ <s:textarea cols="30" id="%{#prefix}.description" label=''
+ theme="simple"
+ key="%{#prefix}.description"
+ value="%{#choice.description}"
disabled="%{voteStarted}"/>
</div>
<s:if test="!voteStarted">
<div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesTEXT_%{#choiceNumber}')">
+ <s:a id='choicesTEXT_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesTEXT_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesTEXT_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a>
+ <s:a href='#'
+ onclick="return deleteChoice('choicesTEXT_%{choiceNumber}')">
<image alt='<s:property value="deleteTitle"/>'
title='<s:property value="deleteTitle"/>'
src="<s:url value='/img/delete.png'/>"></image>
</s:a>
- <%--s:a id='choicesTEXT_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
- </s:a>
- <s:a id='choicesTEXT_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesTEXT_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
</div>
</s:if>
<div class="cleanBoth"></div>
@@ -87,16 +93,19 @@
<div id="choicesDATE" class="choices">
<s:iterator value="dateChoices" status="status" var="choice">
<s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
- <s:set name="prefix">dateChoice_<s:property value="%{#choiceNumber}"/></s:set>
+ <s:set name="prefix">dateChoice_<s:property
+ value="%{#choiceNumber}"/></s:set>
<div id='choicesDATE_<s:property value="choiceNumber"/>'>
<s:hidden key='%{#prefix}.topiaId' id='%{#prefix}.topiaId'
- value='%{#choice.topiaId}' label='' theme="simple" />
+ value='%{#choice.topiaId}' label='' theme="simple"/>
<sp:fielderror fieldName="%{#prefix}"/>
<div class="fleft choiceName">
<s:label for="%{#prefix}.name" id="choicesDATE_label_%{choiceNumber}"
theme="simple" value=''/>
- <sj:datepicker id='%{#prefix}.name' key="%{#prefix}.name" changeMonth="true"
- changeYear="true" labelSeparator="" theme="simple" label=""
+ <sj:datepicker id='%{#prefix}.name' key="%{#prefix}.name"
+ changeMonth="true"
+ changeYear="true" labelSeparator="" theme="simple"
+ label=""
timepicker="true" value="%{#choice.date}"
displayFormat="%{getText('pollen.common.datePickerPattern')}"
disabled="%{voteStarted}"/>
@@ -112,24 +121,25 @@
</div>
<s:if test="!voteStarted">
<div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesDATE_%{choiceNumber}')">
+ <s:a id='choicesDATE_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesDATE_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesDATE_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a>
+ <s:a href='#'
+ onclick="return deleteChoice('choicesDATE_%{choiceNumber}')">
<image alt='<s:property value="deleteTitle"/>'
title='<s:property value="deleteTitle"/>'
src="<s:url value='/img/delete.png'/>"></image>
</s:a>
- <%--s:a id='choicesDATE_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
- </s:a>
- <s:a id='choicesDATE_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesDATE_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
</div>
</s:if>
<div class="cleanBoth"></div>
@@ -139,14 +149,15 @@
<div id="choicesIMAGE" class="choices">
<s:iterator value="imageChoices" status="status" var="choice">
<s:set name="choiceNumber"><s:property value="%{#status.index}"/></s:set>
- <s:set name="prefix">imageChoice_<s:property value="%{#choiceNumber}"/></s:set>
+ <s:set name="prefix">imageChoice_<s:property
+ value="%{#choiceNumber}"/></s:set>
<div id='choicesIMAGE_<s:property value="choiceNumber"/>'>
<s:hidden key='%{#prefix}.topiaId' value='%{#choice.topiaId}' label=''/>
<sp:fielderror fieldName="%{#prefix}"/>
<div class="fleft choiceName">
<s:label for="%{#prefix}.name" id="choicesIMAGE_label_%{choiceNumber}"
theme="simple" value=''/>
- <s:if test="choice.name != ''">
+ <s:if test="#choice.name != null">
<%--Uploaded image--%>
<s:hidden id="%{#prefix}.name" name="%{#prefix}.name"
@@ -160,7 +171,8 @@
</s:if>
<s:else>
<%--New image--%>
- <s:file key='%{#prefix2}' label='' theme="simple" cssClass="nameField"
+ <s:file key='imageChoice[%{#choiceNumber}]' label='' theme="simple"
+ cssClass="nameField"
disabled="%{voteStarted}"/>
</s:else>
-
@@ -168,30 +180,33 @@
theme="simple"/>
</div>
<div class="fleft">
- <s:textarea cols="30" id="%{#prefix}.description" label='' theme="simple"
- key="%{#prefix}.description" value="%{#choice.description}"
+ <s:textarea cols="30" id="%{#prefix}.description" label=''
+ theme="simple"
+ key="%{#prefix}.description"
+ value="%{#choice.description}"
disabled="%{voteStarted}"/>
</div>
<s:if test="!voteStarted">
<div class="fright">
- <s:a href='#' onclick="return deleteChoice('choicesIMAGE_%{choiceNumber}')">
+ <s:a id='choicesIMAGE_down_%{choiceNumber}'
+ cssClass="hidden" href='#'
+ onclick="return downChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="downTitle"/>'
+ title='<s:property value="downTitle"/>'
+ src="<s:url value='/img/1downarrow.png'/>"></image>
+ </s:a>
+ <s:a id='choicesIMAGE_up_%{choiceNumber}' href='#' cssClass="hidden"
+ onclick="return upChoice('choicesIMAGE_%{choiceNumber}')">
+ <image alt='<s:property value="upTitle"/>'
+ title='<s:property value="upTitle"/>'
+ src="<s:url value='/img/1uparrow.png'/>"></image>
+ </s:a>
+ <s:a href='#'
+ onclick="return deleteChoice('choicesIMAGE_%{choiceNumber}')">
<image alt='<s:property value="deleteTitle"/>'
title='<s:property value="deleteTitle"/>'
src="<s:url value='/img/delete.png'/>"></image>
</s:a>
- <%--s:a id='choicesIMAGE_down_%{choiceNumber}'
- cssClass="hidden" href='#'
- onclick="return downChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="downTitle"/>'
- title='<s:property value="downTitle"/>'
- src="<s:url value='/img/1downarrow.png'/>"></image>
- </s:a>
- <s:a id='choicesIMAGE_up_%{choiceNumber}' href='#' cssClass="hidden"
- onclick="return upChoice('choicesIMAGE_%{choiceNumber}')">
- <image alt='<s:property value="upTitle"/>'
- title='<s:property value="upTitle"/>'
- src="<s:url value='/img/1uparrow.png'/>"></image>
- </s:a--%>
</div>
</s:if>
Modified: trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js 2012-05-18 00:56:32 UTC (rev 3371)
+++ trunk/pollen-ui-struts2/src/main/webapp/js/createPoll.js 2012-05-18 06:52:21 UTC (rev 3372)
@@ -303,17 +303,17 @@
//-- Choice methods
//----------------------------------------------------------------------------
-/*function getFirstChoice(containerId) {
- var result = 65535;
+function getFirstChoice(containerId) {
+ var result = 65535;
- getAllChoices(containerId).each(function () {
- var currentChoiceNumber = $(this).data('choiceNumber');
- if (currentChoiceNumber < result) {
- result = currentChoiceNumber;
- }
- });
- return result;
- }*/
+ getAllChoices(containerId).each(function () {
+ var currentChoiceNumber = $(this).data('choiceNumber');
+ if (currentChoiceNumber < result) {
+ result = currentChoiceNumber;
+ }
+ });
+ return result;
+}
function getLastChoice(containerId) {
var result = 0;
@@ -330,13 +330,14 @@
return $("div[id^='" + containerId + "_']");
}
-function prepareChoices(containerId) {
+function prepareChoices(containerId, choicePrefix) {
getAllChoices(containerId).each(function (index) {
var choice = $("#" + containerId + "_" + index);
choice.data('choiceType', containerId);
choice.data('choiceNumber', index);
+ choice.data('choicePrefix', choicePrefix);
});
if (containerId == 'choicesDATE') {
@@ -355,8 +356,8 @@
function updateUpdownActions(containerId) {
-// var firstChoice = getFirstChoice(containerId);
-// var lastChoice = getLastChoice(containerId);
+ var firstChoice = getFirstChoice(containerId);
+ var lastChoice = getLastChoice(containerId);
getAllChoices(containerId).each(function (index) {
@@ -365,28 +366,28 @@
var labelWidget = $('#' + containerId + "_label_" + currentChoiceNumber);
labelWidget.html(datas['choiceText'] + ' ' + (index + 1));
- /*var upWidget = $('#' + containerId + "_up_" + currentChoiceNumber);
- if (firstChoice == currentChoiceNumber) {
- // hide up
- upWidget.addClass('hidden');
- } else {
- //show up
- upWidget.removeClass('hidden');
- }
+ var upWidget = $('#' + containerId + "_up_" + currentChoiceNumber);
+ if (firstChoice == currentChoiceNumber) {
+ // hide up
+ upWidget.addClass('hidden');
+ } else {
+ //show up
+ upWidget.removeClass('hidden');
+ }
- var downWidget = $('#' + containerId + "_down_" + currentChoiceNumber);
- if (lastChoice == currentChoiceNumber) {
- // hide down
- downWidget.addClass('hidden');
- } else {
- //show down
- downWidget.removeClass('hidden');
- }*/
+ var downWidget = $('#' + containerId + "_down_" + currentChoiceNumber);
+ if (lastChoice == currentChoiceNumber) {
+ // hide down
+ downWidget.addClass('hidden');
+ } else {
+ //show down
+ downWidget.removeClass('hidden');
+ }
});
}
-function loadChoice(containerId, url, choiceNumber, nbChoices, tokenId) {
+function loadChoice(containerId, choicePrefix, url, choiceNumber, nbChoices, tokenId) {
if (choiceNumber == -1) {
// to add a new choice
@@ -407,6 +408,7 @@
var choice = $("#" + containerId + "_" + choiceNumber);
choice.data('choiceType', containerId);
choice.data('choiceNumber', choiceNumber);
+ choice.data('choicePrefix', choicePrefix);
if (choiceNumber == nbChoices) {
updateUpdownActions(containerId);
@@ -426,7 +428,7 @@
function addTextChoice(choiceNumber, nbChoices, tokenId) {
loadChoice(
- 'choicesTEXT',
+ 'choicesTEXT', 'textChoice_',
datas['displayTextChoiceUrl'],
choiceNumber, nbChoices, tokenId
);
@@ -434,14 +436,14 @@
function addDateChoice(choiceNumber, nbChoices, tokenId) {
loadChoice(
- 'choicesDATE',
+ 'choicesDATE', 'dateChoice_',
datas['displayDateChoiceUrl'],
choiceNumber, nbChoices, tokenId
);
}
function addImageChoice(choiceNumber, nbChoices, tokenId) {
- loadChoice('choicesIMAGE',
+ loadChoice('choicesIMAGE', 'imageChoice_',
datas['displayImageChoiceUrl'],
choiceNumber, nbChoices, tokenId
);
@@ -467,32 +469,65 @@
return false;
}
-/*function upChoice(choiceId) {
- var choice = $('#' + choiceId);
- var containerId = choice.data('choiceType');
- var choiceNumber = choice.data('choiceNumber');
- console.info("will up [" + containerId + "-" + choiceNumber + "]");
- updateUpdownActions(containerId);
- return false;
- }
+function upChoice(choiceId) {
+ var choice = $('#' + choiceId);
+ var containerId = choice.data('choiceType');
+ var choicePrefix = choice.data('choicePrefix');
+ var choiceNumber = choice.data('choiceNumber');
+ var newChoiceNumber = (choiceNumber - 1);
- function downChoice(choiceId) {
- var choice = $('#' + choiceId);
- var containerId = choice.data('choiceType');
- var choiceNumber = choice.data('choiceNumber');
- console.info("will down [" + containerId + "-" + choiceNumber + "]");
- updateUpdownActions(containerId);
- return false;
- }*/
+ return switchChoices(containerId, choicePrefix, choiceNumber, newChoiceNumber);
+}
+function downChoice(choiceId) {
+ var choice = $('#' + choiceId);
+ var containerId = choice.data('choiceType');
+ var choicePrefix = choice.data('choicePrefix');
+ var choiceNumber = choice.data('choiceNumber');
+ var newChoiceNumber = (choiceNumber + 1);
+
+ return switchChoices(containerId, choicePrefix, choiceNumber, newChoiceNumber);
+}
+
+function switchChoices(containerId, choicePrefix, choiceNumber, newChoiceNumber) {
+
+ console.info("will switch (" + choicePrefix + ") [" + choiceNumber
+ + "] to [" + newChoiceNumber + "]");
+
+ // change topiaId
+ switchValue(choicePrefix, choiceNumber, newChoiceNumber, '.topiaId');
+ // change description
+ switchValue(choicePrefix, choiceNumber, newChoiceNumber, '.description');
+
+ // change name
+ switchValue(choicePrefix, choiceNumber, newChoiceNumber, '.name');
+
+ if ('imageChoice_' == choicePrefix) {
+
+ // change location
+ switchValue(choicePrefix, choiceNumber, newChoiceNumber, '.location');
+ }
+ return false;
+}
+
+function switchValue(choicePrefix, choiceNumber, newChoiceNumber, suffix) {
+ var choiceTI = $('[name="' + choicePrefix + choiceNumber + suffix + '"]');
+ var choiceTIVal = choiceTI.val();
+ var newChoiceTI = $('[name="' + choicePrefix + newChoiceNumber + suffix + '"]');
+ var newChoiceTIVal = newChoiceTI.val();
+ console.info("switch " + choiceTIVal + " to " + newChoiceTIVal);
+ choiceTI.val(newChoiceTIVal);
+ newChoiceTI.val(choiceTIVal);
+}
+
function confirmClose() {
- $('.ui-dialog-title').html(datas['confirmCloseTitle'])
- var dialog = $("#confirmDialog");
- var url = datas['confirmCloseUrl'] + '?'
- + $.param({redirectUrl:datas['confirmCloseRedirectUrl']});
- dialog.load(url);
- dialog.dialog('open');
- return false;
+ $('.ui-dialog-title').html(datas['confirmCloseTitle'])
+ var dialog = $("#confirmDialog");
+ var url = datas['confirmCloseUrl'] + '?'
+ + $.param({redirectUrl:datas['confirmCloseRedirectUrl']});
+ dialog.load(url);
+ dialog.dialog('open');
+ return false;
}
jQuery(document).ready(function () {
@@ -575,9 +610,9 @@
// before loading all choices let's hide everything, it will be shown later
$('.choices').addClass('hidden');
- prepareChoices('choicesTEXT');
- prepareChoices('choicesDATE');
- prepareChoices('choicesIMAGE');
+ prepareChoices('choicesTEXT', 'textChoice_');
+ prepareChoices('choicesDATE', 'dateChoice_');
+ prepareChoices('choicesIMAGE', 'imageChoice_');
prepareVotingLists('votingListRESTRICTED');
prepareVotingLists('votingListGROUP');
@@ -589,7 +624,5 @@
changePollType(datas['pollType']);
- $('.tooltip').tipTip({
- defaultPosition : 'top'
- });
+ $('.tooltip').tipTip({ defaultPosition:'top' });
});
\ No newline at end of file
1
0
r3371 - in trunk/pollen-ui-struts2/src/main: java/org/chorem/pollen/ui/actions/poll java/org/chorem/pollen/ui/security resources/config
by tchemit@users.chorem.org 18 May '12
by tchemit@users.chorem.org 18 May '12
18 May '12
Author: tchemit
Date: 2012-05-18 02:56:32 +0200 (Fri, 18 May 2012)
New Revision: 3371
Url: http://chorem.org/repositories/revision/pollen/3371
Log:
fixes #552: Les anciens liens de sondage avec pagination ne fonctionnent plus
Modified:
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java
trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-05-18 00:54:57 UTC (rev 3370)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollUriIdAction.java 2012-05-18 00:56:32 UTC (rev 3371)
@@ -23,6 +23,8 @@
*/
package org.chorem.pollen.ui.actions.poll;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.ui.actions.PollUriConverter;
import org.chorem.pollen.ui.actions.PollenActionSupport;
@@ -37,21 +39,43 @@
* @since 1.3
*/
public abstract class AbstractPollUriIdAction extends PollenActionSupport {
-
+
public static final String PARAM_POLL_URI = "uriId";
+ public static final String PARAM_POLL_PAGE = "page";
+
private static final long serialVersionUID = 1L;
-
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(AbstractPollUriIdAction.class);
+
private PollUri pollUri;
+ private int page;
+
public final PollUri getUriId() {
return pollUri;
}
public final void setUriId(PollUri pollUri) {
+ if (log.isInfoEnabled()) {
+ log.info("PollUri : " + pollUri.getUri());
+ }
this.pollUri = pollUri;
}
+ public final int getPage() {
+ return page;
+ }
+
+ public final void setPage(int page) {
+ if (log.isInfoEnabled()) {
+ log.info("Page number : " + page);
+ }
+ this.page = page;
+ }
+
public final String getPollId() {
return pollUri != null ? pollUri.getPollId() : null;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-05-18 00:54:57 UTC (rev 3370)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-05-18 00:56:32 UTC (rev 3371)
@@ -93,7 +93,7 @@
private String commentAuthor;
- private String voteSizeMessage;
+// private String voteSizeMessage;
private List<PollResult> results;
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java 2012-05-18 00:54:57 UTC (rev 3370)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java 2012-05-18 00:56:32 UTC (rev 3371)
@@ -52,8 +52,16 @@
public abstract class AbstractPollenAuthorization extends AuthorizationFilter {
+ /**
+ * Pattern to detects uri from a pollen url :
+ * group 1 is action namespace
+ * group 2 is action name
+ * group 3 is pollUri
+ * group 4 is poll page (optional)
+ * group 5 is method (optional)
+ */
public static final Pattern URI_PATTERN =
- Pattern.compile("/.*/(.[^/]+)/(.[^!]+)");
+ Pattern.compile("/(.[^/]+)/(.[^/]+)/(.[^!/]+)(/.[^!/]*){0,1}(!.*){0,1}");
/** Logger. */
private static final Log log =
@@ -84,7 +92,7 @@
PollUri result = null;
if (m.find()) {
- String uriId = m.group(2);
+ String uriId = m.group(3);
result = PollUri.newPollUri(uriId);
}
Modified: trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-05-18 00:54:57 UTC (rev 3370)
+++ trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-05-18 00:56:32 UTC (rev 3371)
@@ -150,6 +150,14 @@
<result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
</action>
+ <!-- vote poll (input) + page number (for future paginated polls) -->
+ <action name="votefor/*/*" method="input"
+ class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
+ <param name="uriId">{1}</param>
+ <param name="page">{2}</param>
+ <result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
+ </action>
+
<!-- vote poll (input) (to fix http://chorem.org/issues/550) -->
<action name="VoteFor/*" method="input"
class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
@@ -157,6 +165,14 @@
<result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
</action>
+ <!-- vote poll (input) + page number (for future paginated polls)(to fix http://chorem.org/issues/550) -->
+ <action name="VoteFor/*/*" method="input"
+ class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
+ <param name="uriId">{1}</param>
+ <param name="page">{2}</param>
+ <result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
+ </action>
+
<!-- add a choice -->
<action name="addChoice/*"
class="org.chorem.pollen.ui.actions.poll.AddChoice">
1
0
18 May '12
Author: tchemit
Date: 2012-05-18 02:54:57 +0200 (Fri, 18 May 2012)
New Revision: 3370
Url: http://chorem.org/repositories/revision/pollen/3370
Log:
refs #550: new urls are not compatible with old (add shiro mapping)
Modified:
trunk/pollen-ui-struts2/src/main/resources/shiro.ini
Modified: trunk/pollen-ui-struts2/src/main/resources/shiro.ini
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/shiro.ini 2012-05-18 00:53:19 UTC (rev 3369)
+++ trunk/pollen-ui-struts2/src/main/resources/shiro.ini 2012-05-18 00:54:57 UTC (rev 3370)
@@ -43,6 +43,7 @@
# is pollAccount (can vote and see result of a poll)
/poll/votefor/**=poll,pollAccess
+/poll/VoteFor/**=poll,pollAccess
/poll/results/**=poll,resultAccess
# is pollCreator (can admin a poll)
1
0
r3369 - trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by tchemit@users.chorem.org 18 May '12
by tchemit@users.chorem.org 18 May '12
18 May '12
Author: tchemit
Date: 2012-05-18 02:53:19 +0200 (Fri, 18 May 2012)
New Revision: 3369
Url: http://chorem.org/repositories/revision/pollen/3369
Log:
no translation of uri
Modified:
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-05-17 23:39:41 UTC (rev 3368)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-05-18 00:53:19 UTC (rev 3369)
@@ -172,7 +172,7 @@
autoOpen="false" modal="true" width="800"/>
<s:form id="voteForm" validate="true">
-<s:hidden key="uriId"/>
+<s:hidden key="uriId" label=''/>
<table id="poll">
<thead>
<tr>
1
0
17 May '12
Author: tchemit
Date: 2012-05-18 01:39:41 +0200 (Fri, 18 May 2012)
New Revision: 3368
Url: http://chorem.org/repositories/revision/pollen/3368
Log:
fixes #550: new urls are not compatible with old
Modified:
trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
Modified: trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-05-17 23:29:28 UTC (rev 3367)
+++ trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-05-17 23:39:41 UTC (rev 3368)
@@ -150,6 +150,13 @@
<result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
</action>
+ <!-- vote poll (input) (to fix http://chorem.org/issues/550) -->
+ <action name="VoteFor/*" method="input"
+ class="org.chorem.pollen.ui.actions.poll.VoteForPoll">
+ <param name="uriId">{1}</param>
+ <result name="input">/WEB-INF/jsp/poll/vote.jsp</result>
+ </action>
+
<!-- add a choice -->
<action name="addChoice/*"
class="org.chorem.pollen.ui.actions.poll.AddChoice">
1
0