r3229 - in branches/pollen-1.2.6-struts2: pollen-persistence/src/main/java/org/chorem/pollen/business/persistence pollen-services/src/main/java/org/chorem/pollen/bean pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user po
Author: tchemit Date: 2012-04-02 19:30:25 +0200 (Mon, 02 Apr 2012) New Revision: 3229 Url: http://chorem.org/repositories/revision/pollen/3229 Log: - use same behaviour for actions in grids - fix EditPoll action (need to add the correct PollUri convertor) - add svn properties + headers Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/Confirm.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Confirm.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteList.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/CreatePoll-conversion.properties branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/confirmDeleteUser.jsp branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/confirmDeleteFavoriteList.jsp branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/confirmDeletePollAccount.jsp Modified: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PersonToListDAOImpl.java branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/ChoiceHelper.java branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/FileUploadAware.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators.xml branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js Modified: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PersonToListDAOImpl.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PersonToListDAOImpl.java 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PersonToListDAOImpl.java 2012-04-02 17:30:25 UTC (rev 3229) @@ -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.business.persistence; import java.util.List; Property changes on: branches/pollen-1.2.6-struts2/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PersonToListDAOImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/ChoiceHelper.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/ChoiceHelper.java 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/ChoiceHelper.java 2012-04-02 17:30:25 UTC (rev 3229) @@ -1,3 +1,26 @@ +/* + * #%L + * Pollen :: Services + * + * $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.bean; import com.google.common.base.Function; Property changes on: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/ChoiceHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-services/src/main/java/org/chorem/pollen/bean/PollUri.java 2012-04-02 17:30:25 UTC (rev 3229) @@ -26,14 +26,18 @@ import com.google.common.base.Preconditions; import org.apache.commons.lang3.StringUtils; +import java.io.Serializable; + /** * TODO * * @author tchemit <chemit@codelutin.com> * @since 1.2.6 */ -public class PollUri { +public class PollUri implements Serializable { + private static final long serialVersionUID = 1L; + public static PollUri newPollUri(String uri) { PollUri result = new PollUri(); Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/FileUploadAware.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/FileUploadAware.java 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/FileUploadAware.java 2012-04-02 17:30:25 UTC (rev 3229) @@ -1,3 +1,26 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $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.ui.actions; import java.io.File; Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/FileUploadAware.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/Confirm.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/Confirm.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/Confirm.java 2012-04-02 17:30:25 UTC (rev 3229) @@ -0,0 +1,97 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $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.ui.actions.admin; + +import org.apache.commons.lang.StringUtils; +import org.chorem.pollen.business.persistence.Poll; +import org.chorem.pollen.business.persistence.UserAccount; +import org.chorem.pollen.services.impl.PollService; +import org.chorem.pollen.services.impl.UserService; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * Action for confirmation + * + * @author tchemit <chemit@codelutin.com> + * @since 1.2.6 + */ +public class Confirm extends PollenActionSupport { + + private static final long serialVersionUID = 1L; + + protected String userId; + + protected String pollId; + + protected UserAccount user; + + protected Poll poll; + + protected String redirectUrl; + + public void setRedirectUrl(String redirectUrl) { + this.redirectUrl = redirectUrl; + } + + public void setUserId(String userId) { + this.userId = userId; + } + public void setPollId(String pollId) { + this.pollId = pollId; + } + + public String getRedirectUrl() { + return redirectUrl; + } + + public UserAccount getUser() { + return user; + } + + public Poll getPoll() { + return poll; + } + + @Override + public String execute() throws Exception { + + if (StringUtils.isNotEmpty(userId)) { + + // load user + UserService service = newService(UserService.class); + + user = service.getEntityById(UserAccount.class, userId); + } + + if (StringUtils.isNotEmpty(pollId)) { + + // load poll + PollService servcie = newService(PollService.class); + + poll = servcie.getPollByPollId(pollId); + } + + return SUCCESS; + } +} Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/Confirm.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java 2012-04-02 17:30:25 UTC (rev 3229) @@ -0,0 +1,82 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $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.ui.actions.admin; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.business.persistence.UserAccount; +import org.chorem.pollen.services.exceptions.UserNotFoundException; +import org.chorem.pollen.services.impl.UserService; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * Delete a selected user. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.2.6 + */ +public class DeleteUser extends PollenActionSupport { + + private static final long serialVersionUID = 1L; + + protected String userId; + + protected String redirectUrl; + + public void setRedirectUrl(String redirectUrl) { + this.redirectUrl = redirectUrl; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getRedirectUrl() { + return redirectUrl; + } + + public String execute() throws Exception { + + Preconditions.checkNotNull(userId); + + UserService service = newService(UserService.class); + + String result = INPUT; + + try { + UserAccount user = + service.getEntityById(UserAccount.class, userId); + + service.deleteUser(userId); + getTransaction().commitTransaction(); + addActionMessage( + _("pollen.information.user.deleted", user.getDisplayName())); + + result = SUCCESS; + } catch (UserNotFoundException e) { + addFieldError("deleteUser.login", + _("pollen.error.user.not.found")); + } + return result; + } +} Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java 2012-04-02 17:30:25 UTC (rev 3229) @@ -28,7 +28,6 @@ import org.chorem.pollen.services.exceptions.UserEmailAlreadyUsedException; import org.chorem.pollen.services.exceptions.UserInvalidPasswordException; import org.chorem.pollen.services.exceptions.UserLoginAlreadyUsedException; -import org.chorem.pollen.services.exceptions.UserNotFoundException; import org.chorem.pollen.services.impl.UserService; import org.chorem.pollen.ui.actions.PollenActionSupport; @@ -60,9 +59,9 @@ return getUser(); } - public UserAccount getDeleteUser() { - return getUser(); - } +// public UserAccount getDeleteUser() { +// return getUser(); +// } public String getAction() { return action; @@ -129,28 +128,28 @@ return result; } - public String delete() throws Exception { - - Preconditions.checkNotNull(user); - - UserService service = newService(UserService.class); - - String result = INPUT; - - try { - service.deleteUser(user.getTopiaId()); - getTransaction().commitTransaction(); - addActionMessage( - _("pollen.information.user.deleted", user.getDisplayName())); - - // remove this user, otherwise it will be reused in the user lists - user = null; - action = null; - result = SUCCESS; - } catch (UserNotFoundException e) { - addFieldError("deleteUser.login", - _("pollen.error.user.not.found")); - } - return result; - } +// public String delete() throws Exception { +// +// Preconditions.checkNotNull(user); +// +// UserService service = newService(UserService.class); +// +// String result = INPUT; +// +// try { +// service.deleteUser(user.getTopiaId()); +// getTransaction().commitTransaction(); +// addActionMessage( +// _("pollen.information.user.deleted", user.getDisplayName())); +// +// // remove this user, otherwise it will be reused in the user lists +// user = null; +// action = null; +// result = SUCCESS; +// } catch (UserNotFoundException e) { +// addFieldError("deleteUser.login", +// _("pollen.error.user.not.found")); +// } +// return result; +// } } Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUsers.java 2012-04-02 17:30:25 UTC (rev 3229) @@ -23,6 +23,7 @@ */ package org.chorem.pollen.ui.actions.json; +import com.google.common.collect.Sets; import org.chorem.pollen.business.persistence.UserAccount; import org.chorem.pollen.entities.PollenBinderHelper; import org.chorem.pollen.services.impl.UserService; @@ -30,6 +31,7 @@ import java.util.List; import java.util.Map; +import java.util.Set; /** * Obtain paginated users. @@ -74,6 +76,7 @@ List<UserAccount> allUsers = userService.getUsers(pager); + UserAccount userAccount = getPollenUserAccount(); users = new Map[allUsers.size()]; Binder<UserAccount, UserAccount> binder = PollenBinderHelper.getSimpleTopiaBinder(UserAccount.class); @@ -83,9 +86,24 @@ user ); map.put("id", user.getTopiaId()); + Set<String> functions = getUserFunctions(userAccount, user); + map.put("functions", functions); + users[index++] = map; } return SUCCESS; } + + protected Set<String> getUserFunctions(UserAccount connectedUser, UserAccount user) { + Set<String> result = Sets.newHashSet(); + result.add("edit"); + if (!user.equals(connectedUser)) { + + // can not delete current connected user + + result.add("delete"); + } + return result; + } } Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AddChoice.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java 2012-04-02 17:30:25 UTC (rev 3229) @@ -55,6 +55,8 @@ private static final String PREFIX_PERSON_TO_LIST = "personToList_%d_%d"; + private static final long serialVersionUID = 1L; + protected PollUri pollUri; public final PollUri getUriId() { Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Confirm.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Confirm.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Confirm.java 2012-04-02 17:30:25 UTC (rev 3229) @@ -0,0 +1,96 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $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.ui.actions.user; + +import org.apache.commons.lang.StringUtils; +import org.chorem.pollen.business.persistence.PersonList; +import org.chorem.pollen.business.persistence.PollAccount; +import org.chorem.pollen.services.impl.FavoriteService; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * Action for confirmation + * + * @author tchemit <chemit@codelutin.com> + * @since 1.2.6 + */ +public class Confirm extends PollenActionSupport { + + private static final long serialVersionUID = 1L; + + protected String favoriteListId; + + protected String pollAccountId; + + protected PersonList favoriteList; + + protected PollAccount pollAccount; + + protected String redirectUrl; + + public void setRedirectUrl(String redirectUrl) { + this.redirectUrl = redirectUrl; + } + + public void setPollAccountId(String pollAccountId) { + this.pollAccountId = pollAccountId; + } + + public void setFavoriteListId(String favoriteListId) { + this.favoriteListId = favoriteListId; + } + + public String getRedirectUrl() { + return redirectUrl; + } + + public PersonList getFavoriteList() { + return favoriteList; + } + + public PollAccount getPollAccount() { + return pollAccount; + } + + @Override + public String execute() throws Exception { + + FavoriteService service = newService(FavoriteService.class); + + if (StringUtils.isNotEmpty(favoriteListId)) { + + // load favorite list + favoriteList = service.getEntityById(PersonList.class, + favoriteListId); + } + + if (StringUtils.isNotEmpty(pollAccountId)) { + + // load poll account + pollAccount = service.getEntityById(PollAccount.class, + pollAccountId); + } + return SUCCESS; + } +} Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/Confirm.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteList.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteList.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteList.java 2012-04-02 17:30:25 UTC (rev 3229) @@ -0,0 +1,85 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $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.ui.actions.user; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.business.persistence.PersonList; +import org.chorem.pollen.services.exceptions.UserNotFoundException; +import org.chorem.pollen.services.impl.FavoriteService; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * Delete a selected favorite list for the connected user. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.2.6 + */ +public class DeleteFavoriteList extends PollenActionSupport { + + private static final long serialVersionUID = 1L; + + protected String favoriteListId; + + protected String redirectUrl; + + public void setRedirectUrl(String redirectUrl) { + this.redirectUrl = redirectUrl; + } + + public void setFavoriteListId(String favoriteListId) { + this.favoriteListId = favoriteListId; + } + + public String getRedirectUrl() { + return redirectUrl; + } + + public String execute() throws Exception { + + Preconditions.checkNotNull(favoriteListId); + + String result = INPUT; + + try { + FavoriteService service = newService(FavoriteService.class); + + PersonList favoriteList = service.getEntityById( + PersonList.class, favoriteListId); + + PersonList deletedFavoritedList = service.deleteFavoriteList( + getPollenUserAccount(), favoriteList); + + getTransaction().commitTransaction(); + + addActionMessage(_("pollen.information.favoriteList.deleted", + deletedFavoritedList.getName())); + + result = SUCCESS; + } catch (UserNotFoundException e) { + addFieldError("deleteUser.login", + _("pollen.error.user.not.found")); + } + return result; + } +} Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeleteFavoriteList.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java 2012-04-02 17:30:25 UTC (rev 3229) @@ -0,0 +1,86 @@ +/* + * #%L + * Pollen :: UI (strust2) + * + * $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.ui.actions.user; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.business.persistence.PersonList; +import org.chorem.pollen.business.persistence.PollAccount; +import org.chorem.pollen.services.impl.FavoriteService; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * Delete a selected favorite list for the connected user. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.2.6 + */ +public class DeletePollAccount extends PollenActionSupport { + + private static final long serialVersionUID = 1L; + + protected String favoriteListId; + + protected String pollAccountId; + + protected String redirectUrl; + + public void setRedirectUrl(String redirectUrl) { + this.redirectUrl = redirectUrl; + } + + public void setFavoriteListId(String favoriteListId) { + this.favoriteListId = favoriteListId; + } + + public void setPollAccountId(String pollAccountId) { + this.pollAccountId = pollAccountId; + } + + public String getRedirectUrl() { + return redirectUrl; + } + + public String execute() throws Exception { + + Preconditions.checkNotNull(pollAccountId); + + FavoriteService service = newService(FavoriteService.class); + + PersonList favoriteList = service.getEntityById(PersonList.class, + favoriteListId); + + PollAccount pollAccount = service.getEntityById(PollAccount.class, + pollAccountId); + + service.removePollAccountToFavoriteList(favoriteList, pollAccount); + + getTransaction().commitTransaction(); + + addActionMessage( + _("pollen.information.pollAccount.removedFromFavoriteList", + pollAccount.getVotingId())); + + return SUCCESS; + } +} Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/user/DeletePollAccount.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-admin.xml 2012-04-02 17:30:25 UTC (rev 3229) @@ -62,11 +62,18 @@ <result>/WEB-INF/jsp/admin/usersList.jsp</result> </action> + <!-- confirm delete user --> + <action name="confirmDeleteUser" + class="org.chorem.pollen.ui.actions.admin.Confirm"> + <result>/WEB-INF/jsp/admin/confirmDeleteUser.jsp</result> + </action> + <!-- delete user --> - <action name="delete" method="delete" - class="org.chorem.pollen.ui.actions.admin.ManageUsers"> - <result name="input">/WEB-INF/jsp/admin/usersList.jsp</result> - <result>/WEB-INF/jsp/admin/usersList.jsp</result> + <action name="deleteUser" + class="org.chorem.pollen.ui.actions.admin.DeleteUser"> + <!--<result name="input">/WEB-INF/jsp/admin/usersList.jsp</result>--> + <result type="redirect2"/> + <!--<result>/WEB-INF/jsp/admin/usersList.jsp</result>--> </action> </package> Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-04-02 17:30:25 UTC (rev 3229) @@ -39,11 +39,6 @@ <param name="actionName">votefor/${uriId}</param> </result-type> - <result-type name="redirect2" - class="org.apache.struts2.dispatcher.ServletRedirectResult"> - <param name="location">${redirectUrl}</param> - <param name="prependServletContext">false</param> - </result-type> </result-types> <!-- create poll --> Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/config/struts-user.xml 2012-04-02 17:30:25 UTC (rev 3229) @@ -79,12 +79,19 @@ <result>/WEB-INF/jsp/user/favoriteLists.jsp</result> </action> + <!-- confirm delete favorite list --> + <action name="confirmDeleteFavoriteList" + class="org.chorem.pollen.ui.actions.user.Confirm"> + <result>/WEB-INF/jsp/user/confirmDeleteFavoriteList.jsp</result> + </action> + <!-- delete favorite list --> - <action name="deleteFavoriteList" method="delete" - class="org.chorem.pollen.ui.actions.user.ManageFavoriteLists"> + <action name="deleteFavoriteList" + class="org.chorem.pollen.ui.actions.user.DeleteFavoriteList"> <interceptor-ref name="pollenParamsPrepareParamsStack"/> - <result name="input">/WEB-INF/jsp/user/favoriteLists.jsp</result> - <result>/WEB-INF/jsp/user/favoriteLists.jsp</result> + <!--<result name="input">/WEB-INF/jsp/user/favoriteLists.jsp</result>--> + <result type="redirect2"/> + <!--<result>/WEB-INF/jsp/user/favoriteLists.jsp</result>--> </action> <!-- edit favorite list --> @@ -110,12 +117,19 @@ <result>/WEB-INF/jsp/user/favoriteList.jsp</result> </action> + <!-- confirm delete poll account from a favorite list --> + <action name="confirmDeletePollAccount" + class="org.chorem.pollen.ui.actions.user.Confirm"> + <result>/WEB-INF/jsp/user/confirmDeletePollAccount.jsp</result> + </action> + <!-- remove poll account from a favorite list --> - <action name="removePollAccount" method="delete" - class="org.chorem.pollen.ui.actions.user.ManageFavoriteList"> + <action name="deletePollAccount" + class="org.chorem.pollen.ui.actions.user.DeletePollAccount"> <interceptor-ref name="pollenParamsPrepareParamsStack"/> - <result name="input">/WEB-INF/jsp/user/favoriteList.jsp</result> - <result>/WEB-INF/jsp/user/favoriteList.jsp</result> + <!--<result name="input">/WEB-INF/jsp/user/favoriteList.jsp</result>--> + <!--<result>/WEB-INF/jsp/user/favoriteList.jsp</result>--> + <result type="redirect2"/> </action> <!-- display createds polls --> Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-04-02 17:30:25 UTC (rev 3229) @@ -183,7 +183,9 @@ pollen.information.confirmClonePoll=Confirm clone of poll\: pollen.information.confirmClosePoll=Confirm close of poll\: pollen.information.confirmDeleteChoice=Confirm delete of choice %s +pollen.information.confirmDeleteFavoriteList=Confirm delete of favorite list\: pollen.information.confirmDeletePoll=Confirm delete of poll\: +pollen.information.confirmDeleteUser=Confirm delete of user %s pollen.information.confirmDeleteVote=Confirm delete of vote for %s pollen.information.favoriteList.created=Favorite list %s created. pollen.information.favoriteList.deleted=Favorite list %s deleted. Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-04-02 17:30:25 UTC (rev 3229) @@ -189,9 +189,12 @@ pollen.info.poll.updated=Sondage mise à jour 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 \: pollen.information.confirmDeletePoll=Confirmer la suppression du sondage \: +pollen.information.confirmDeletePollAccount=Confirmer la suppression du votant \: pollen.information.confirmDeletePollChoice=Confirmer la suppression du choix %s pollen.information.confirmDeletePollVote=Confirmer la suppression du vote de %s +pollen.information.confirmDeleteUser=Confirmer la suppression de l'utilisateur \: pollen.information.favoriteList.created=La liste %s a été créée. pollen.information.favoriteList.deleted=La liste %s a été supprimée. pollen.information.irreversible.operation=Attention, Cette opération est irréversible. Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/CreatePoll-conversion.properties =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/CreatePoll-conversion.properties (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/CreatePoll-conversion.properties 2012-04-02 17:30:25 UTC (rev 3229) @@ -0,0 +1,24 @@ +### +# #%L +# Pollen :: UI (strust2) +# +# $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% +### +uriId=org.chorem.pollen.ui.actions.PollUriConverter \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/poll/CreatePoll-conversion.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/resources/struts.xml 2012-04-02 17:30:25 UTC (rev 3229) @@ -57,6 +57,12 @@ <param name="namespace">/</param> <param name="actionName">home</param> </result-type> + + <result-type name="redirect2" + class="org.apache.struts2.dispatcher.ServletRedirectResult"> + <param name="location">${redirectUrl}</param> + <param name="prependServletContext">false</param> + </result-type> </result-types> <interceptors> Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators.xml =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators.xml 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators.xml 2012-04-02 17:30:25 UTC (rev 3229) @@ -29,6 +29,8 @@ <pattern>/images/*</pattern> <pattern>/config-browser/*</pattern> <pattern>/json/*</pattern> + <pattern>/user/confirm*</pattern> + <pattern>/admin/confirm*</pattern> <pattern>/poll/confirm*</pattern> <pattern>/poll/display*</pattern> <pattern>/poll/selectPersonListTo*</pattern> Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/confirmDeleteUser.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/confirmDeleteUser.jsp (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/confirmDeleteUser.jsp 2012-04-02 17:30:25 UTC (rev 3229) @@ -0,0 +1,56 @@ +<%-- + #%L + Pollen :: UI (strust2) + + $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% + --%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<script type="text/javascript"> + function cancel() { + $('#confirmDialog').dialog('close'); + return false; + } +</script> +<s:form method="POST" namespace="/admin"> + <fieldset class="ui-widget-content ui-corner-all"> + + <s:hidden key="redirectUrl" label=''/> + <s:hidden key="userId" value='%{user.topiaId}' label=''/> + + <s:text name="pollen.information.confirmDeleteUser"/> + <div align="center" style="padding-top: 1em;"> + "<strong><s:property value="user.displayName"/></strong>" + </div> + <br/> + + <div style="padding-top: 1em;"> + <strong> + <s:text name="pollen.information.irreversible.operation"/> + </strong> + </div> + <hr/> + <div align="right"> + <s:submit onclick="return cancel();" theme="simple" + key="pollen.action.cancel"/> + <s:submit key="pollen.action.delete" theme="simple" action="deleteUser"/> + </div> + </fieldset> +</s:form> \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/confirmDeleteUser.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp 2012-04-02 17:30:25 UTC (rev 3229) @@ -24,6 +24,7 @@ <%@page contentType="text/html" pageEncoding="UTF-8" %> <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %> +<%@ taglib prefix="sj" uri="/struts-jquery-tags" %> <script type="text/javascript" src="<s:url value='/js/gridHelper.js' />"></script> @@ -39,11 +40,17 @@ <s:set var="user" value="%{#session.pollenSession.userAccount}"/> <script type="text/javascript"> + + var redirectUrl = '<s:url namespace="/admin" action="usersList"/>'; + var deleteTitle = '<s:text name="pollen.action.deleteUser"/>'; + var deleteUrl = '<s:url action="confirmDeleteUser" namespace="/admin"/>'; + var loadUserUrl = '<s:url action="getUser" namespace="/json"/>'; + var editImg = '<s:url value='/img/edit.png'/>'; + var editTitle = '<s:text name="pollen.action.editUser"/>'; + var deleteImg = '<s:url value='/img/delete.png'/>'; + jQuery(document).ready(function () { - initUsersPage( - '${action}', - '<s:url action="getUser" namespace="/json"/>' - ); + initUsersPage('${action}', '${user.topiaId}'); }); </script> @@ -57,69 +64,70 @@ navigatorAdd="false" viewrecords="true" rowList="10,15,20,50,100" rowNum="10" navigatorExtraButtons="{ - add: { title: '%{getText(\"pollen.action.createUser\")}', icon: 'ui-icon-plus', topic: 'users-addRow' }, - edit: { title: '%{getText(\"pollen.action.editUser\")}', icon: 'ui-icon-pencil', topic: 'users-editRow' }, - delete:{ title: '%{getText(\"pollen.action.deleteUser\")}', icon: 'ui-icon-trash', topic: 'users-deleteRow' }}"> + add: { title: '%{getText(\"pollen.action.createUser\")}', icon: 'ui-icon-plus', topic: 'users-addRow' }}"> <sjg:gridColumn name="id" title="id" hidden="true"/> <sjg:gridColumn name="login" title='%{getText("pollen.common.login")}'/> - <sjg:gridColumn name="firstName" title='%{getText("pollen.common.firstName")}'/> + <sjg:gridColumn name="firstName" + title='%{getText("pollen.common.firstName")}'/> <sjg:gridColumn name="lastName" title='%{getText("pollen.common.lastName")}'/> <sjg:gridColumn name="email" title='%{getText("pollen.common.email")}'/> - <sjg:gridColumn name="administrator" width="100" formatter="checkbox" - title='%{getText("pollen.common.administrator")}' /> + <sjg:gridColumn name="administrator" width="20" formatter="checkbox" + title='%{getText("pollen.common.administrator")}'/> + <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}' + formatter="userFunctions" width="40" sortable="false"/> </sjg:grid> <br/> -<s:form id='createForm' method="POST" namespace="/admin" cssClass="hidden userForm"> +<s:form id='createForm' method="POST" namespace="/admin" + cssClass="hidden userForm"> <s:hidden name="action" value="create"/> <fieldset> <legend><s:text name="pollen.fieldset.userInformation.toCreate"/></legend> - <s:textfield key="createUser.login" label="%{getText('pollen.common.login')}" required="true" size="40"/> - <s:textfield key="createUser.email" label="%{getText('pollen.common.email')}" required="true" size="40"/> - <s:textfield key="createUser.firstName" label="%{getText('pollen.common.firstName')}" size="40"/> - <s:textfield key="createUser.lastName" label="%{getText('pollen.common.lastName')}" size="40"/> - <s:checkbox key="createUser.administrator" label="%{getText('pollen.common.administrator')}"/> + <s:textfield key="createUser.login" + label="%{getText('pollen.common.login')}" required="true" + size="40"/> + <s:textfield key="createUser.email" + label="%{getText('pollen.common.email')}" required="true" + size="40"/> + <s:textfield key="createUser.firstName" + label="%{getText('pollen.common.firstName')}" size="40"/> + <s:textfield key="createUser.lastName" + label="%{getText('pollen.common.lastName')}" size="40"/> + <s:checkbox key="createUser.administrator" + label="%{getText('pollen.common.administrator')}"/> </fieldset> <br/> <s:submit action="create" key="pollen.action.create" align="center"/> </s:form> -<s:form id='editForm' method="POST" namespace="/admin" cssClass="hidden userForm"> +<s:form id='editForm' method="POST" namespace="/admin" + cssClass="hidden userForm"> <s:hidden name="action" value="edit"/> <s:hidden key="editUser.topiaId" label=""/> <fieldset> <legend><s:text name="pollen.fieldset.userInformation.toUpdate"/></legend> - <s:textfield key="editUser.login" label="%{getText('pollen.common.login')}" required="true" readonly="true" size="40"/> - <s:textfield key="editUser.email" label="%{getText('pollen.common.email')}" required="true" size="40"/> - <s:textfield key="editUser.firstName" label="%{getText('pollen.common.firstName')}" size="40"/> - <s:textfield key="editUser.lastName" label="%{getText('pollen.common.lastName')}" size="40"/> - <s:checkbox key="editUser.administrator" label="%{getText('pollen.common.administrator')}"/> + <s:textfield key="editUser.login" label="%{getText('pollen.common.login')}" + required="true" readonly="true" size="40"/> + <s:textfield key="editUser.email" label="%{getText('pollen.common.email')}" + required="true" size="40"/> + <s:textfield key="editUser.firstName" + label="%{getText('pollen.common.firstName')}" size="40"/> + <s:textfield key="editUser.lastName" + label="%{getText('pollen.common.lastName')}" size="40"/> + <s:checkbox key="editUser.administrator" + label="%{getText('pollen.common.administrator')}"/> </fieldset> <br/> <s:submit action="edit" key="pollen.action.validate" align="center"/> </s:form> -<s:form id='deleteForm' method="POST" namespace="/admin" cssClass="hidden userForm"> +<sj:dialog id="confirmDialog" autoOpen="false" modal="true" width="500"/> - <s:hidden name="action" value="delete"/> - <s:hidden key="deleteUser.topiaId" label=""/> - <fieldset> - <legend><s:text name="pollen.fieldset.userInformation.toDelete"/></legend> - <s:textfield key="deleteUser.login" label="%{getText('pollen.common.login')}" required="true" readonly="true" size="40"/> - <s:textfield key="deleteUser.email" label="%{getText('pollen.common.email')}" required="true" readonly="true" size="40"/> - <s:textfield key="deleteUser.firstName" label="%{getText('pollen.common.firstName')}" readonly="true" size="40"/> - <s:textfield key="deleteUser.lastName" label="%{getText('pollen.common.lastName')}" readonly="true" size="40"/> - <s:checkbox key="deleteUser.administrator" label="%{getText('pollen.common.administrator')}" disabled="true"/> - </fieldset> - <br/> - <s:submit action="delete" key="pollen.action.delete" align="center"/> -</s:form> - Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/confirmDeleteFavoriteList.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/confirmDeleteFavoriteList.jsp (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/confirmDeleteFavoriteList.jsp 2012-04-02 17:30:25 UTC (rev 3229) @@ -0,0 +1,56 @@ +<%-- + #%L + Pollen :: UI (strust2) + + $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% + --%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<script type="text/javascript"> + function cancel() { + $('#confirmDialog').dialog('close'); + return false; + } +</script> +<s:form method="POST" namespace="/user"> + <fieldset class="ui-widget-content ui-corner-all"> + + <s:hidden key="redirectUrl" label=''/> + <s:hidden key="favoriteListId" value='%{favoriteList.topiaId}' label=''/> + + <s:text name="pollen.information.confirmDeleteFavoriteList"/> + <div align="center" style="padding-top: 1em;"> + "<strong><s:property value="favoriteList.name"/></strong>" + </div> + <br/> + + <div style="padding-top: 1em;"> + <strong><s:text + name="pollen.information.irreversible.operation"/></strong> + </div> + <hr/> + <div align="right"> + <s:submit onclick="return cancel();" theme="simple" + key="pollen.action.cancel"/> + <s:submit key="pollen.action.delete" theme="simple" + action="deleteFavoriteList"/> + </div> + </fieldset> +</s:form> \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/confirmDeleteFavoriteList.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/confirmDeletePollAccount.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/confirmDeletePollAccount.jsp (rev 0) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/confirmDeletePollAccount.jsp 2012-04-02 17:30:25 UTC (rev 3229) @@ -0,0 +1,57 @@ +<%-- + #%L + Pollen :: UI (strust2) + + $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% + --%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<script type="text/javascript"> + function cancel() { + $('#confirmDialog').dialog('close'); + return false; + } +</script> +<s:form method="POST" namespace="/user"> + <fieldset class="ui-widget-content ui-corner-all"> + + <s:hidden key="redirectUrl" label=''/> + <s:hidden key="favoriteListId" value='%{favoriteList.topiaId}' label=''/> + <s:hidden key="pollAccountId" value='%{pollAccount.topiaId}' label=''/> + + <s:text name="pollen.information.confirmDeletePollAccount"/> + <div align="center" style="padding-top: 1em;"> + "<strong><s:property value="pollAccount.votingId"/></strong>" + </div> + <br/> + + <div style="padding-top: 1em;"> + <strong><s:text + name="pollen.information.irreversible.operation"/></strong> + </div> + <hr/> + <div align="right"> + <s:submit onclick="return cancel();" theme="simple" + key="pollen.action.cancel"/> + <s:submit key="pollen.action.delete" theme="simple" + action="deletePollAccount"/> + </div> + </fieldset> +</s:form> \ No newline at end of file Property changes on: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/confirmDeletePollAccount.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteList.jsp 2012-04-02 17:30:25 UTC (rev 3229) @@ -24,6 +24,7 @@ <%@page contentType="text/html" pageEncoding="UTF-8" %> <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %> +<%@ taglib prefix="sj" uri="/struts-jquery-tags" %> <script type="text/javascript" src="<s:url value='/js/gridHelper.js' />"></script> @@ -35,14 +36,24 @@ <s:param name="favoriteListId" value="%{favoriteList.topiaId}"/> </s:url> +<s:url id="editPollAccounts" action="editPollAccount" namespace="/user"> + <s:param name="favoriteListId" value="%{favoriteList.topiaId}"/> +</s:url> + <script type="text/javascript"> + var favoriteListId = '<s:property value="favoriteList.topiaId"/>'; + var redirectUrl = '${editPollAccounts}'; + var deleteTitle = '<s:text name="pollen.action.deletePollAccount"/>'; + var deleteUrl = '<s:url action="confirmDeletePollAccount" namespace="/user" />'; + var loadPollActionUrl = '<s:url action="getFavoriteListPollAccount" namespace="/json"/>'; + var editImg = '<s:url value='/img/edit.png'/>'; + var editTitle = '<s:text name="pollen.action.editPollAccount"/>'; + var deleteImg = '<s:url value='/img/delete.png'/>'; + jQuery(document).ready(function () { - initFavoritePage( - '${action}', - '<s:url action="getFavoriteListPollAccount" namespace="/json"/>' - ); + initFavoritePage('${action}'); }); </script> @@ -67,13 +78,14 @@ navigatorAdd="false" viewrecords="true" rowList="10,15,20,50,100" rowNum="10" navigatorExtraButtons="{ - add: { title: '%{getText(\"pollen.action.createPollAccount\")}', icon: 'ui-icon-plus', topic: 'pollAccounts-addRow' }, - edit: { title: '%{getText(\"pollen.action.editPollAccount\")}', icon: 'ui-icon-pencil', topic: 'pollAccounts-editRow' }, - delete:{ title: '%{getText(\"pollen.action.deletePollAccount\")}', icon: 'ui-icon-trash', topic: 'pollAccounts-deleteRow'}}"> + add: { title: '%{getText(\"pollen.action.createPollAccount\")}', icon: 'ui-icon-plus', topic: 'pollAccounts-addRow' }}"> <sjg:gridColumn name="id" title="id" hidden="true"/> <sjg:gridColumn name="votingId" title='%{getText("pollen.common.name")}'/> <sjg:gridColumn name="email" title='%{getText("pollen.common.email")}'/> + <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}' + formatter="favoriteListFunctions" width="40" + sortable="false"/> </sjg:grid> <br/> @@ -119,31 +131,11 @@ align="center"/> </s:form> -<s:form id='deleteForm' method="POST" namespace="/user" - cssClass="hidden pollAccountForm"> - - <s:hidden name="action" value="delete"/> - <s:hidden key="deletePollAccount.topiaId" label=""/> - <s:hidden key="favoriteListId" label=""/> - - <fieldset> - <legend> - <s:text name="pollen.fieldset.pollAccount.toDeleteFromFavoriteList"/> - </legend> - <s:textfield key="deletePollAccount.votingId" required="true" size="40" - label="%{getText('pollen.common.name')}" readonly="true"/> - <s:textfield key="deletePollAccount.email" required="true" readonly="true" - label="%{getText('pollen.common.email')}" size="40"/> - </fieldset> - <br/> - - <s:submit action="removePollAccount" key="pollen.action.delete" - align="center"/> -</s:form> - <br/> <s:form method="POST" namespace="/user"> <s:submit action="favoriteLists" key="pollen.action.backToFavoriteLists" align="center"/> </s:form> + +<sj:dialog id="confirmDialog" autoOpen="false" modal="true" width="500"/> \ No newline at end of file Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/user/favoriteLists.jsp 2012-04-02 17:30:25 UTC (rev 3229) @@ -24,6 +24,7 @@ <%@page contentType="text/html" pageEncoding="UTF-8" %> <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %> +<%@ taglib prefix="sj" uri="/struts-jquery-tags" %> <script type="text/javascript" src="<s:url value='/js/gridHelper.js' />"></script> @@ -38,12 +39,17 @@ <script type="text/javascript"> + var redirectUrl = '<s:url namespace="/user" action="favoriteLists"/>'; + var deleteTitle = '<s:text name="pollen.action.deleteFavoriteList"/>'; + var deleteUrl = '<s:url action="confirmDeleteFavoriteList" namespace="/user"/>'; + var loadUserUrl = '<s:url action="getFavoriteList" namespace="/json"/>'; + var editImg = '<s:url value='/img/edit.png'/>'; + var editTitle = '<s:text name="pollen.action.editFavoriteList"/>'; + var deleteImg = '<s:url value='/img/delete.png'/>'; + jQuery(document).ready(function () { - initFavoritesPage( - '${action}', - '<s:url action="getFavoriteList" namespace="/json"/>' - ); + initFavoritesPage('${action}'); }); </script> @@ -57,14 +63,15 @@ navigatorSearch="false" navigatorRefresh="false" navigatorAdd="false" rowList="10,15,20,50,100" rowNum="10" navigatorExtraButtons="{ - add: { title: '%{getText(\"pollen.action.createFavoriteList\")}', icon: 'ui-icon-plus', topic: 'favoriteLists-addRow' }, - edit: { title: '%{getText(\"pollen.action.editFavoriteList\")}', icon: 'ui-icon-pencil', topic: 'favoriteLists-editRow' }, - delete:{ title: '%{getText(\"pollen.action.deleteFavoriteList\")}', icon: 'ui-icon-trash', topic: 'favoriteLists-deleteRow'}}"> + add: { title: '%{getText(\"pollen.action.createFavoriteList\")}', icon: 'ui-icon-plus', topic: 'favoriteLists-addRow' }}"> <sjg:gridColumn name="id" title="id" hidden="true"/> <sjg:gridColumn name="name" title='%{getText("pollen.common.name")}'/> <sjg:gridColumn name="nbAccounts" title='%{getText("pollen.common.nbAccounts")}'/> + <sjg:gridColumn name="functions" title='%{getText("pollen.common.functions")}' + formatter="favoriteListsFunctions" width="40" + sortable="false"/> </sjg:grid> <br/> @@ -87,32 +94,13 @@ align="center"/> </s:form> -<s:form id='deleteForm' method="POST" namespace="/user" - cssClass="hidden favoriteForm"> +<s:form id='editForm' method="POST" namespace="/user" theme="simple" + action="editFavoriteList" cssClass="hidden"> - <s:hidden name="action" value="delete"/> - <s:hidden key="deleteFavoriteList.topiaId" label=""/> - - <fieldset> - <legend> - <s:text name="pollen.fieldset.userFavoriteList.toDelete"/> - </legend> - <s:textfield key="deleteFavoriteList.name" required="true" readonly="true" - size="40" label="%{getText('pollen.common.name')}"/> - </fieldset> - <br/> - <s:submit action="deleteFavoriteList" key="pollen.action.delete" - align="center"/> -</s:form> - -<s:form id='editForm' method="POST" namespace="/user" - action="editFavoriteList" theme="simple" - cssClass="hidden"> - <s:hidden key="favoriteListId" label=""/> <s:submit action="editFavoriteList"/> </s:form> +<sj:dialog id="confirmDialog" autoOpen="false" modal="true" width="500"/> - Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteList.js 2012-04-02 17:30:25 UTC (rev 3229) @@ -26,12 +26,17 @@ $('#createForm').show(); } else if (action == 'edit') { $('#editForm').show(); - } else if (action == 'delete') { - $('#deleteForm').show(); } // listen row selection - $.addRowSelectTopic('pollAccounts'); + $.addRowSelectTopic('pollAccounts', function () { + if (action != '') { + // come back from action + action = ''; + return; + } + $(".pollAccountForm").hide(); + }); $.addClearSelectTopic('pollAccounts', function () { if (action != '') { @@ -50,50 +55,50 @@ $('#editForm').hide(); $('#createForm').show(); }); +} - // to edit the selected row - $.listenRowTopic('pollAccounts-editRow', function (event) { - var id = $.getSelectedId('pollAccounts'); - if (!id) { +function favoriteListFunctions(cellvalue, options, rowObject) { - // no row selected - return; - } + var id = rowObject.id; - jQuery.getJSON(loadPollActionUrl, { "pollAccountId":id }, - function (result) { + var result = ""; - var pollAccount = result.pollAccount; - $('#editForm [name="editPollAccount.topiaId"]').val(pollAccount.id); - $('#editForm [name="editPollAccount.votingId"]').val(pollAccount.votingId); - $('#editForm [name="editPollAccount.email"]').val(pollAccount.email); - $('#deleteForm').hide(); - $('#createForm').hide(); - $('#editForm').show(); - } - ); - }); + var script = 'return editPollAccount("' + id + '");'; + result += formatLinkByScript(script, editImg, "Edit", editTitle); - // to delete the selected row - $.listenRowTopic('pollAccounts-deleteRow', function (event) { - var id = $.getSelectedId('pollAccounts'); - if (!id) { + script = 'return confirmDelete("' + id + '");'; + result += formatLinkByScript(script, deleteImg, "Delete", deleteTitle); + return result; +} - // no row selected - return; - } +function formatLinkByScript(script, image, imageAlt, imageTitle) { + return "<a href='#' onclick='" + script + "'><image alt='" + imageAlt + "' title='" + imageTitle + "' src='" + image + "'> </a>"; +} - jQuery.getJSON(loadPollActionUrl, { "pollAccountId":id }, - function (result) { +// to edit the selected row +function editPollAccount(id) { - var pollAccount = result.pollAccount; - $('#deleteForm [name="deletePollAccount.topiaId"]').val(pollAccount.id); - $('#deleteForm [name="deletePollAccount.votingId"]').val(pollAccount.votingId); - $('#deleteForm [name="deletePollAccount.email"]').val(pollAccount.email); - $('#editForm').hide(); - $('#createForm').hide(); - $('#deleteForm').show(); - } - ); - }); + jQuery.getJSON( + loadPollActionUrl, { "pollAccountId":id }, function (result) { + + var pollAccount = result.pollAccount; + $('#editForm [name="editPollAccount.topiaId"]').val(pollAccount.id); + $('#editForm [name="editPollAccount.votingId"]').val(pollAccount.votingId); + $('#editForm [name="editPollAccount.email"]').val(pollAccount.email); + $('#deleteForm').hide(); + $('#createForm').hide(); + $('#editForm').show(); + } + ); +} + +function confirmDelete(id) { + $('.ui-dialog-title').html(deleteTitle) + var dialog = $("#confirmDialog"); + var url = deleteUrl + '?' + $.param({favoriteListId:favoriteListId, + pollAccountId:id, + redirectUrl:redirectUrl}); + dialog.load(url); + dialog.dialog('open'); + return false; } \ No newline at end of file Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/favoriteLists.js 2012-04-02 17:30:25 UTC (rev 3229) @@ -21,16 +21,21 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -function initFavoritesPage(action, loadFavoriteList) { +function initFavoritesPage(action) { if (action == 'create') { $('#createForm').show(); - } else if (action == 'delete') { - $('#deleteForm').show(); } // listen row selection - $.addRowSelectTopic('favoriteLists'); + $.addRowSelectTopic('favoriteLists', function () { + if (action != '') { + // come back from action + action = ''; + return; + } + $(".userForm").hide(); + }); $.addClearSelectTopic('favoriteLists', function () { if (action != '') { @@ -51,34 +56,38 @@ $('#deleteForm').hide(); $('#createForm').show(); }); +} - // to edit a selected row - $.listenRowTopic('favoriteLists-editRow', function (event) { - var id = $.getSelectedId('favoriteLists'); - if (!id) { - // no row selected - return; - } +function favoriteListsFunctions(cellvalue, options, rowObject) { - $('#editForm [name="favoriteListId"]').val(id); - $('#editForm').submit(); - }); + var id = rowObject.id; - // to delete the selected row - $.listenRowTopic('favoriteLists-deleteRow', function (event) { - var id = $.getSelectedId('favoriteLists'); - if (!id) { - // no row selected - return; - } - jQuery.getJSON(loadFavoriteList, { favoriteListId:id }, - function (result) { - var user = result.favoriteList; - $('#deleteForm [name="deleteFavoriteList.topiaId"]').val(user.id); - $('#deleteForm [name="deleteFavoriteList.name"]').val(user.name); - $('#createForm').hide(); - $('#deleteForm').show(); - } - ); - }); + var result = ""; + + var script = 'return editFavoriteList("' + id + '");'; + result += formatLinkByScript(script, editImg, "Edit", editTitle); + + script = 'return confirmDelete("' + id + '");'; + result += formatLinkByScript(script, deleteImg, "Delete", deleteTitle); + return result; +} + +function formatLinkByScript(script, image, imageAlt, imageTitle) { + return "<a href='#' onclick='" + script + "'><image alt='" + imageAlt + "' title='" + imageTitle + "' src='" + image + "'> </a>"; +} + +function editFavoriteList(id) { + $('#editForm [name="favoriteListId"]').val(id); + $('#editForm').submit(); + return false; +} + +function confirmDelete(id) { + $('.ui-dialog-title').html(deleteTitle) + var dialog = $("#confirmDialog"); + var url = deleteUrl + '?' + $.param({favoriteListId:id, + redirectUrl:redirectUrl}); + dialog.load(url); + dialog.dialog('open'); + return false; } \ No newline at end of file Modified: branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js =================================================================== --- branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js 2012-04-02 16:42:38 UTC (rev 3228) +++ branches/pollen-1.2.6-struts2/pollen-ui-struts2/src/main/webapp/js/usersList.js 2012-04-02 17:30:25 UTC (rev 3229) @@ -21,7 +21,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ -function initUsersPage(action, loadUserUrl) { +function initUsersPage(action, userId) { if (action == 'create') { $('#createForm').show(); @@ -29,12 +29,16 @@ if (action == 'edit') { $('#editForm').show(); } - if (action == 'delete') { - $('#deleteForm').show(); - } // listen row selection - $.addRowSelectTopic('users'); + $.addRowSelectTopic('users', function () { + if (action != '') { + // come back from action + action = ''; + return; + } + $(".userForm").hide(); + }); $.addClearSelectTopic('users', function () { if (action != '') { @@ -58,65 +62,54 @@ $('#deleteForm').hide(); $('#createForm').show(); }); +} - // to edit a selected row - $.listenRowTopic('users-editRow', function (event) { - var id = $.getSelectedId('users'); - if (!id) { +function userFunctions(cellvalue, options, rowObject) { - // no user selected - return; - } - $('#editForm .errorMessage').hide(); - jQuery.getJSON(loadUserUrl, { "userId":id }, function (result) { + var id = rowObject.id; - var user = result.user; - $('#editForm [name="editUser.topiaId"]').val(user.id); - $('#editForm [name="editUser.login"]').val(user.login); - $('#editForm [name="editUser.email"]').val(user.email); - $('#editForm [name="editUser.firstName"]').val(user.firstName); - $('#editForm [name="editUser.lastName"]').val(user.lastName); - $('#editForm [name="editUser.administrator"]').prop('checked', false); - $('#editForm [name="editUser.administrator"]').prop('checked', user.administrator); - $('#editForm').show(); - $('#createForm').hide(); - $('#deleteForm').hide(); - } - ); - }); + var result = ""; - // to delete the selected row - $.listenRowTopic('users-deleteRow', function (event) { - var id = $.getSelectedId('users'); - if (!id) { + if (cellvalue.indexOf('edit') > -1) { + var script = 'return editUser("' + id + '");' + result += formatLinkByScript(script, editImg, "Edit", editTitle) + } + if (cellvalue.indexOf('delete') > -1) { + var script = 'return confirmDelete("' + id + '");' + result += formatLinkByScript(script, deleteImg, "Delete", deleteTitle) + } + return result; +} - // no user selected - return; - } +function formatLinkByScript(script, image, imageAlt, imageTitle) { + return "<a href='#' onclick='" + script + "'><image alt='" + imageAlt + "' title='" + imageTitle + "' src='" + image + "'> </a>"; +} - var userId = '${user.topiaId}'; +function editUser(id) { + $('#editForm .errorMessage').hide(); + jQuery.getJSON( + loadUserUrl, { "userId":id }, function (result) { - if (id == userId) { + var user = result.user; + $('#editForm [name="editUser.topiaId"]').val(user.id); + $('#editForm [name="editUser.login"]').val(user.login); + $('#editForm [name="editUser.email"]').val(user.email); + $('#editForm [name="editUser.firstName"]').val(user.firstName); + $('#editForm [name="editUser.lastName"]').val(user.lastName); + $('#editForm [name="editUser.administrator"]').prop('checked', false); + $('#editForm [name="editUser.administrator"]').prop('checked', user.administrator); + $('#editForm').show(); + $('#createForm').hide(); + } + ); + return false; +} - // can not delete connected user - return; - } - $('#deleteForm .errorMessage').hide(); - - jQuery.getJSON(loadUserUrl, { "userId":id }, function (result) { - - var user = result.user; - $('#deleteForm [name="deleteUser.topiaId"]').val(user.id); - $('#deleteForm [name="deleteUser.login"]').val(user.login); - $('#deleteForm [name="deleteUser.email"]').val(user.email); - $('#deleteForm [name="deleteUser.firstName"]').val(user.firstName); - $('#deleteForm [name="deleteUser.lastName"]').val(user.lastName); - $('#deleteForm [name="deleteUser.administrator"]').prop('checked', false); - $('#deleteForm [name="deleteUser.administrator"]').prop('checked', user.administrator); - $('#editForm').hide(); - $('#createForm').hide(); - $('#deleteForm').show(); - } - ); - }); -} \ No newline at end of file +function confirmDelete(id) { + $('.ui-dialog-title').html(deleteTitle) + var dialog = $("#confirmDialog"); + var url = deleteUrl + '?' + $.param({userId:id, redirectUrl:redirectUrl}); + dialog.load(url); + dialog.dialog('open'); + return false; +}
participants (1)
-
tchemit@users.chorem.org