r3105 - in branches/pollen-2.0-beta-1: pollen-services/src/main/java/org/chorem/pollen/services 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/interceptors pollen-ui-struts2/src/main/resources pollen-ui-struts2/src/main/resources/config pollen-ui-struts2/src/main/resources/i18n pollen-ui-struts
Author: tchemit Date: 2012-01-23 18:15:11 +0100 (Mon, 23 Jan 2012) New Revision: 3105 Url: http://chorem.org/repositories/revision/pollen/3105 Log: - Introduce admin package - finalize user management Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/CreateUser.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManagePolls.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/UpdateUser.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUser.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/admin/ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/admin/CreateUser-validation.xml branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/admin/UpdateUser-validation.xml Removed: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManagePolls.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManageUsers.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/AbstractCheckInterceptor.java Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserService.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/RegisterUser.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-admin.xml branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-json.xml branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/struts.xml branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/usersList.jsp branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/js/gridHelper.js Modified: branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserService.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserService.java 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-services/src/main/java/org/chorem/pollen/services/UserService.java 2012-01-23 17:15:11 UTC (rev 3105) @@ -25,6 +25,7 @@ import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.pollen.PollenBinderHelper; @@ -80,6 +81,7 @@ } public UserAccount createUser(UserAccount user, + boolean byAdmin, URL url) throws UserLoginAlreadyUsedException, UserEmailAlreadyUsedException { String password = user.getPassword(); // le mot de passe en clair @@ -97,6 +99,12 @@ if (userByEmail != null) { throw new UserEmailAlreadyUsedException(); } + if (byAdmin) { + + // let's generate the new password + password = RandomStringUtils.randomAlphanumeric(8); + } + String encodedPassword = encodePassword(password); userAccount = dao.create( UserAccount.PROPERTY_LOGIN, user.getLogin(), @@ -246,7 +254,7 @@ user.setEmail(getConfiguration().getAdminEmail()); user.setNewPassword(getConfiguration().getAdminPassword()); try { - createUser(user, null); + createUser(user,false, null); if (log.isInfoEnabled()) { log.info(_("pollen.info.admin.created", login)); } Deleted: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManagePolls.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManagePolls.java 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManagePolls.java 2012-01-23 17:15:11 UTC (rev 3105) @@ -1,34 +0,0 @@ -/* - * #%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; - -/** - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class ManagePolls extends PollenActionSupport{ - - private static final long serialVersionUID = 1L; -} Deleted: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManageUsers.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManageUsers.java 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManageUsers.java 2012-01-23 17:15:11 UTC (rev 3105) @@ -1,34 +0,0 @@ -/* - * #%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; - -/** - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public class ManageUsers extends PollenActionSupport{ - - private static final long serialVersionUID = 1L; -} Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/RegisterUser.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/RegisterUser.java 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/RegisterUser.java 2012-01-23 17:15:11 UTC (rev 3105) @@ -72,6 +72,7 @@ getTransaction().commitTransaction(); getPollenSession().setUserAccount(createdUser); + addActionMessage(_("pollen.information.your.are.loggued")); return SUCCESS; } catch (UserLoginAlreadyUsedException e) { addFieldError("user.login", _("pollen.error.user.login.already.used")); Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/CreateUser.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/CreateUser.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/CreateUser.java 2012-01-23 17:15:11 UTC (rev 3105) @@ -0,0 +1,53 @@ +package org.chorem.pollen.ui.actions.admin; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.entity.UserAccountImpl; +import org.chorem.pollen.services.UserEmailAlreadyUsedException; +import org.chorem.pollen.services.UserLoginAlreadyUsedException; +import org.chorem.pollen.services.UserService; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * Create a user informations from users admin screen. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class CreateUser extends PollenActionSupport { + + private static final long serialVersionUID = 1L; + + protected UserAccount createUser; + + public UserAccount getCreateUser() { + if (createUser == null) { + createUser = new UserAccountImpl(); + } + return createUser; + } + + @Override + public String execute() throws Exception { + + Preconditions.checkNotNull(createUser); + + UserService service = newService(UserService.class); + + try { + service.createUser(createUser, true, getApplicationUrl()); + getTransaction().commitTransaction(); + addActionMessage( + _("pollen.information.user.created", createUser.getDisplayName())); + // remove this user, otherwise it will be reused in the user lists + createUser = null; + return SUCCESS; + } catch (UserLoginAlreadyUsedException e) { + addFieldError("createUser.login", _("pollen.error.user.login.already.used")); + } catch (UserEmailAlreadyUsedException e) { + addFieldError("createUser.email", _("pollen.error.user.email.already.used")); + } + + return INPUT; + } +} Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/DeleteUser.java 2012-01-23 17:15:11 UTC (rev 3105) @@ -0,0 +1,45 @@ +package org.chorem.pollen.ui.actions.admin; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.entity.UserAccountImpl; +import org.chorem.pollen.services.UserService; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * Delete a user. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class DeleteUser extends PollenActionSupport { + + private static final long serialVersionUID = 1L; + + protected UserAccount deleteUser; + + public UserAccount getDeleteUser() { + if (deleteUser == null) { + deleteUser = new UserAccountImpl(); + } + return deleteUser; + } + + @Override + public String execute() throws Exception { + + Preconditions.checkNotNull(deleteUser); + + UserService service = newService(UserService.class); + + service.deleteUser(deleteUser.getLogin()); + getTransaction().commitTransaction(); + + addActionMessage( + _("pollen.information.user.deleted", deleteUser.getDisplayName())); + + // remove this user, otherwise it will be reused in the user lists + deleteUser = null; + return SUCCESS; + } +} Copied: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManagePolls.java (from rev 3101, branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManagePolls.java) =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManagePolls.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManagePolls.java 2012-01-23 17:15:11 UTC (rev 3105) @@ -0,0 +1,36 @@ +/* + * #%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.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class ManagePolls extends PollenActionSupport { + + private static final long serialVersionUID = 1L; +} Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManagePolls.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Copied: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java (from rev 3101, branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/ManageUsers.java) =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java 2012-01-23 17:15:11 UTC (rev 3105) @@ -0,0 +1,36 @@ +/* + * #%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.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class ManageUsers extends PollenActionSupport { + + private static final long serialVersionUID = 1L; +} Property changes on: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/ManageUsers.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/UpdateUser.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/UpdateUser.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/admin/UpdateUser.java 2012-01-23 17:15:11 UTC (rev 3105) @@ -0,0 +1,54 @@ +package org.chorem.pollen.ui.actions.admin; + +import com.google.common.base.Preconditions; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.entity.UserAccountImpl; +import org.chorem.pollen.services.UserEmailAlreadyUsedException; +import org.chorem.pollen.services.UserInvalidPasswordException; +import org.chorem.pollen.services.UserService; +import org.chorem.pollen.ui.actions.PollenActionSupport; + +/** + * Update a user informations from users admin screen. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class UpdateUser extends PollenActionSupport { + + private static final long serialVersionUID = 7738596310901970593L; + + protected UserAccount updateUser; + + public UserAccount getUpdateUser() { + if (updateUser == null) { + updateUser = new UserAccountImpl(); + } + return updateUser; + } + + @Override + public String execute() throws Exception { + + Preconditions.checkNotNull(updateUser); + + UserService service = newService(UserService.class); + + try { + service.updateUser(updateUser, null, true); + getTransaction().commitTransaction(); + addActionMessage( + _("pollen.information.user.updated", updateUser.getDisplayName())); + + // remove this user, otherwise it will be reused in the user lists + updateUser = null; + return SUCCESS; + } catch (UserEmailAlreadyUsedException e) { + addFieldError("updateUser.email", _("pollen.error.user.email.already.used")); + } catch (UserInvalidPasswordException e) { + addFieldError("updateUser.password", _("pollen.error.user.invalid.password")); + } + + return INPUT; + } +} Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUser.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUser.java (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetUser.java 2012-01-23 17:15:11 UTC (rev 3105) @@ -0,0 +1,53 @@ +package org.chorem.pollen.ui.actions.json; + +import com.google.common.collect.Maps; +import org.chorem.pollen.entity.UserAccount; +import org.chorem.pollen.services.UserService; +import org.chorem.pollen.ui.actions.PollenActionSupport; +import org.nuiton.util.beans.Binder; +import org.nuiton.util.beans.BinderFactory; + +import java.util.Map; + +/** + * Get user datas (for json purpose). + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public class GetUser extends PollenActionSupport { + private static final long serialVersionUID = 1L; + + private String userId; + + private transient Map<String, Object> user; + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Map<String, Object> getUser() { + return user; + } + + @Override + public String execute() throws Exception { + + UserService userService = newService(UserService.class); + + UserAccount userAccount = userService.getEntityById(UserAccount.class, userId); + + user = Maps.newHashMap(); + + Binder<UserAccount, UserAccount> binder = + BinderFactory.newBinder(UserAccount.class); + user = binder.obtainProperties(userAccount); + user.put("id", userAccount.getTopiaId()); + + return SUCCESS; + } +} Deleted: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/AbstractCheckInterceptor.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/AbstractCheckInterceptor.java 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/AbstractCheckInterceptor.java 2012-01-23 17:15:11 UTC (rev 3105) @@ -1,94 +0,0 @@ -/* - * #%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.interceptors; - -import com.opensymphony.xwork2.ActionInvocation; -import com.opensymphony.xwork2.interceptor.AbstractInterceptor; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.struts2.ServletActionContext; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * Abstract check interceptor. - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public abstract class AbstractCheckInterceptor extends AbstractInterceptor { - - private static final long serialVersionUID = -7169251953113201351L; - - /** Logger. */ - private static final Log log = - LogFactory.getLog(AbstractCheckInterceptor.class); - - /** Where to redirect where user is loggued */ - protected String redirectAction; - - public void setRedirectAction(String redirectAction) { - this.redirectAction = redirectAction; - } - - protected abstract boolean doCheck(ActionInvocation invocation); - - @Override - public String intercept(ActionInvocation invocation) throws Exception { - - boolean check = doCheck(invocation); - - if (!check) { - - String redirectUrl = getRedirectUrl(); - if (log.isInfoEnabled()) { - log.info("Will redirect to " + redirectUrl); - } - redirect(redirectUrl); - - return null; - } - - String result = invocation.invoke(); - return result; - } - - protected String getRedirectUrl() { - return redirectAction; - } - - protected void redirect(String url) throws Exception { - - HttpServletResponse response = ServletActionContext.getResponse(); - HttpServletRequest request = ServletActionContext.getRequest(); - - String path = request.getContextPath(); - if (!url.startsWith("/")) { - path += "/"; - } - response.sendRedirect(path + url); - } - -} Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/interceptors/CheckUserIsAdmin.java 2012-01-23 17:15:11 UTC (rev 3105) @@ -25,8 +25,12 @@ import com.google.common.base.Preconditions; import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.interceptor.AbstractInterceptor; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.chorem.pollen.entity.UserAccount; import org.chorem.pollen.ui.PollenSession; +import org.chorem.pollen.ui.PollenUIUtils; import org.chorem.pollen.ui.actions.PollenActionSupport; /** @@ -35,12 +39,23 @@ * @author tchemit <chemit@codelutin.com> * @since 2.0 */ -public class CheckUserIsAdmin extends AbstractCheckInterceptor { +public class CheckUserIsAdmin extends AbstractInterceptor { private static final long serialVersionUID = 1L; + /** Logger. */ + private static final Log log = LogFactory.getLog(CheckUserIsAdmin.class); + + /** Where to redirect where user is loggued */ + protected String redirectAction; + + public void setRedirectAction(String redirectAction) { + this.redirectAction = redirectAction; + } + @Override - protected boolean doCheck(ActionInvocation invocation) { + public String intercept(ActionInvocation invocation) throws Exception { + PollenActionSupport action = (PollenActionSupport) invocation.getAction(); PollenSession echoBaseSession = action.getPollenSession(); @@ -48,6 +63,23 @@ UserAccount user = echoBaseSession.getUserAccount(); Preconditions.checkNotNull(user, "No user found is session"); - return user.isAdmin(); + boolean check = user.isAdmin(); + + if (!check) { + + if (log.isInfoEnabled()) { + log.info("User not admin try to acces admin section..."); + } + + if (log.isInfoEnabled()) { + log.info("Will redirect to " + redirectAction); + } + PollenUIUtils.redirect(redirectAction); + + return null; + } + + String result = invocation.invoke(); + return result; } } Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-admin.xml =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-admin.xml 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-admin.xml 2012-01-23 17:15:11 UTC (rev 3105) @@ -34,19 +34,40 @@ <default-interceptor-ref name="pollenBasicAdminStack"/> - <!-- add interceptor to be connected --> - <!-- add interceptor to be admin --> - <!-- manage users --> <action name="usersList" method="input" - class="org.chorem.pollen.ui.actions.ManageUsers"> + class="org.chorem.pollen.ui.actions.admin.ManageUsers"> <interceptor-ref name="pollenBasicAdminStack"/> <result name="input">/WEB-INF/jsp/usersList.jsp</result> </action> + <!-- create user --> + <action name="createUser" + class="org.chorem.pollen.ui.actions.admin.CreateUser"> + <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/> + <result name="input">/WEB-INF/jsp/usersList.jsp</result> + <result>/WEB-INF/jsp/usersList.jsp</result> + </action> + + <!-- save user --> + <action name="updateUser" + class="org.chorem.pollen.ui.actions.admin.UpdateUser"> + <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/> + <result name="input">/WEB-INF/jsp/usersList.jsp</result> + <result>/WEB-INF/jsp/usersList.jsp</result> + </action> + + <!-- delete user --> + <action name="deleteUser" + class="org.chorem.pollen.ui.actions.admin.DeleteUser"> + <interceptor-ref name="pollenParamsPrepareParamsAdminStack"/> + <result name="input">/WEB-INF/jsp/usersList.jsp</result> + <result>/WEB-INF/jsp/usersList.jsp</result> + </action> + <!-- manage polls --> <action name="pollsList" method="input" - class="org.chorem.pollen.ui.actions.ManagePolls"> + class="org.chorem.pollen.ui.actions.admin.ManagePolls"> <interceptor-ref name="pollenBasicAdminStack"/> <result name="input">/WEB-INF/jsp/pollsList.jsp</result> </action> Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-json.xml =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/config/struts-json.xml 2012-01-23 17:15:11 UTC (rev 3105) @@ -23,7 +23,6 @@ #L% --> - <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.1.7.dtd"> @@ -35,14 +34,21 @@ <!-- get pagined users --> <action name="getUsers" class="org.chorem.pollen.ui.actions.json.GetUsers"> - <interceptor-ref name="pollenBasicLogguedStack"/> + <interceptor-ref name="pollenBasicAdminStack"/> <result type="json"/> </action> + <!-- get user detail --> + <action name="getUser" + class="org.chorem.pollen.ui.actions.json.GetUser"> + <interceptor-ref name="pollenBasicAdminStack"/> + <result type="json"/> + </action> + <!-- get pagined polls --> <action name="getPolls" class="org.chorem.pollen.ui.actions.json.GetPolls"> - <interceptor-ref name="pollenBasicLogguedStack"/> + <interceptor-ref name="pollenBasicAdminStack"/> <result type="json"/> </action> Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-01-23 17:15:11 UTC (rev 3105) @@ -1,3 +1,8 @@ +pollen.action.create=Create +pollen.action.createUser=Create a new user +pollen.action.delete=Delete +pollen.action.deleteUser=Delete selected user +pollen.action.editUser=Edit selected user pollen.action.login=Log me In pollen.action.modify=Modify pollen.action.register=Register @@ -27,7 +32,12 @@ pollen.fieldset.connexionInformation=Information de connexion pollen.fieldset.login=Login pollen.fieldset.userInformation=Informations de l'utilisateur +pollen.fieldset.userInformation.toCreate=User informations to create +pollen.fieldset.userInformation.toDelete=User informations to delete pollen.information.need.login=You must be logged to access this page. Please fill the form below. +pollen.information.user.created=User %s created. +pollen.information.user.deleted=User %s deleted. +pollen.information.user.updated=User %s updated. pollen.information.your.are.loggued=You are logged. pollen.label.contact.administrator=Send an email to an administrator pollen.legend.login=Login Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-01-23 17:15:11 UTC (rev 3105) @@ -1,3 +1,8 @@ +pollen.action.create=Créer +pollen.action.createUser=Créer un nouvel utilisateur +pollen.action.delete=Supprimer +pollen.action.deleteUser=Supprimer un utilisateur sélectionné +pollen.action.editUser=Editer un utilisateur sélectionné pollen.action.login=M'identifier pollen.action.modify=Modifier pollen.action.register=S'enregistrer @@ -27,7 +32,12 @@ pollen.fieldset.connexionInformation=Information de connexion pollen.fieldset.login=Connexion pollen.fieldset.userInformation=Informations de l'utilisateur +pollen.fieldset.userInformation.toCreate=Informations de l'utilisateur à créer +pollen.fieldset.userInformation.toDelete=Informations de l'utilisateur à supprimer pollen.information.need.login=Vous devez être identifié pour pouvoir accéder à cette page. Veuillez remplir le formulaire ci-dessous. +pollen.information.user.created=L'utilisateur %s a été créé. +pollen.information.user.deleted=L'utilisateur %s a été supprimé. +pollen.information.user.updated=L'utilisateur %s a été mis à jour. pollen.information.your.are.loggued=Vous êtes connecté. pollen.label.contact.administrator=Contacter un administrateur pollen.legend.login=Login Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/admin/CreateUser-validation.xml =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/admin/CreateUser-validation.xml (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/admin/CreateUser-validation.xml 2012-01-23 17:15:11 UTC (rev 3105) @@ -0,0 +1,22 @@ +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="createUser.login"> + + <field-validator type="requiredstring"> + <message key="pollen.error.login.required"/> + </field-validator> + + </field> + + <field name="createUser.email"> + + <field-validator type="requiredstring"> + <message key="pollen.error.email.required"/> + </field-validator> + + </field> + +</validators> Added: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/admin/UpdateUser-validation.xml =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/admin/UpdateUser-validation.xml (rev 0) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/admin/UpdateUser-validation.xml 2012-01-23 17:15:11 UTC (rev 3105) @@ -0,0 +1,22 @@ +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + + <field name="updateUser.login"> + + <field-validator type="requiredstring"> + <message key="pollen.error.login.required"/> + </field-validator> + + </field> + + <field name="updateUser.email"> + + <field-validator type="requiredstring"> + <message key="pollen.error.email.required"/> + </field-validator> + + </field> + +</validators> Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/struts.xml =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/struts.xml 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/resources/struts.xml 2012-01-23 17:15:11 UTC (rev 3105) @@ -71,8 +71,7 @@ <interceptor name="checkUserAdmin" class="org.chorem.pollen.ui.interceptors.CheckUserIsAdmin"> - <param name="loginAction">/notAdmin</param> - <param name="redirectAction">/home</param> + <param name="redirectAction">/notAdmin</param> </interceptor> <!-- basic stack --> @@ -99,6 +98,9 @@ <interceptor-stack name="pollenParamsPrepareParamsStack"> <interceptor-ref name="i18n"/> <interceptor-ref name="paramsPrepareParamsStack"/> + <interceptor-ref name="store"> + <param name="operationMode">STORE</param> + </interceptor-ref> </interceptor-stack> <interceptor-stack name="pollenParamsPrepareParamsLogguedStack"> @@ -114,7 +116,6 @@ </interceptors> - <!-- must be authenticated to perform any actions --> <default-interceptor-ref name="pollenParamsPrepareParamsStack"/> Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-01-23 17:15:11 UTC (rev 3105) @@ -84,12 +84,14 @@ <div class="top_left${pageLogo}"></div> <ul class="top_middle${pageLogo}"> <li> - <s:a action="showUser"> + <s:a action="showUser" namespace="/user"> <s:text name="pollen.menu.preferences"/> </s:a> </li> <li> - <s:a action="logout" namespace="/user"><s:text name="pollen.menu.logout"/></s:a> + <s:a action="logout" namespace="/user"> + <s:text name="pollen.menu.logout"/> + </s:a> </li> </ul> </div> @@ -102,7 +104,7 @@ <div class="dropdown_menu" id="login_menu" style="display: none;"> <div class="top_right${pageLogo}"></div> <div class="top_left${pageLogo}"></div> - <s:form id="connection" action="login" method="POST" namespace="/user"> + <s:form id="connection" method="POST" namespace="/user" action="login"> <ul class="top_middle${pageLogo}"> <li> <label for="connection_login"> @@ -228,7 +230,7 @@ <%--<div t:type="nuiton/feedback" t:id="borderFeedback" t:autoClear="false"/>--%> <s:if test="hasActionMessages()"> - <div class="fb-message"> + <div class="fb-info"> <s:actionmessage/> </div> </s:if> Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/usersList.jsp =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/usersList.jsp 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/usersList.jsp 2012-01-23 17:15:11 UTC (rev 3105) @@ -30,32 +30,165 @@ <h1 class="title${pageLogo}"><s:text name="pollen.title.usersList"/></h1> -<s:url id="loadUrl" action="getUsers" namespace="/json" escapeAmp="false"/> +<s:url id="loadUSers" action="getUsers" namespace="/json" escapeAmp="false"/> -<%--script type="text/javascript"> +<s:url id="loadUser" action="getUser" namespace="/json"/> +<script type="text/javascript"> + jQuery(document).ready(function () { + if ('${createUser}' != '') { + $('#createForm').show(); + } + if ('${updateUser}' != '') { + $('#editForm').show(); + } + if ('${deleteUser}' != '') { + $('#deleteForm').show(); + } + + // listen row selection $.addRowSelectTopic('users'); - $.addClearSelectTopic('users'); - $.addAddRowTopic('users', '${addUrl}'); - $.addSingleRowTopic('users', 'Update', '${editUrl}', 'user.id'); - $.addSingleRowTopic('users', 'Delete', '${delUrl}', 'user.id'); + + // to edit a selected row + $.listenRowTopic('users-editRow', function (event) { + if(!jQuery.struts2_jquery['users']) { + return; + } + var id = jQuery.struts2_jquery['users']['selectedRow']; + jQuery.getJSON("${loadUser}", { "userId":id }, function (result) { + + var user = result.user; + $('#editForm [name="updateUser.topiaId"]').val(user.id); + $('#editForm [name="updateUser.login"]').val(user.login); + $('#editForm [name="updateUser.email"]').val(user.email); + $('#editForm [name="updateUser.firstName"]').val(user.firstName); + $('#editForm [name="updateUser.lastName"]').val(user.lastName); + $('#editForm [name="updateUser.admin"]').prop('checked',false); + $('#editForm [name="updateUser.admin"]').prop('checked',user.admin); + $('#editForm').show(); + $('#createForm').hide(); + $('#deleteForm').hide(); + } + ); + }); + + // to create a new row + $.listenRowTopic('users-addRow', function(event) { + $('#createForm [name="createUser.login"]').val(""); + $('#createForm [name="createUser.email"]').val(""); + $('#createForm [name="createUser.firstName"]').val(""); + $('#createForm [name="createUser.lastName"]').val(""); + $('#createForm [name="createUser.admin"]').prop('checked',false); + $('#editForm').hide(); + $('#deleteForm').hide(); + $('#createForm').show(); + }); + + // to delete the selected row + $.listenRowTopic('users-deleteRow', function(event) { + if(!jQuery.struts2_jquery['users']) { + return; + } + var id = jQuery.struts2_jquery['users']['selectedRow']; + jQuery.getJSON("${loadUser}", { "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.admin"]').prop('checked',false); + $('#deleteForm [name="deleteUser.admin"]').prop('checked',user.admin); + $('#editForm').hide(); + $('#createForm').hide(); + $('#deleteForm').show(); + } + ); + }); }); -</script--%> +</script> -<sjg:grid id="users" dataType="json" href="%{loadUrl}" gridModel="users" +<sjg:grid id="users" dataType="json" href="%{loadUSers}" gridModel="users" pager="true" pagerButtons="true" pagerInput="true" navigator="true" rownumbers="false" autowidth="true" - onSelectRowTopics='users-rowSelect' editinline="true" editurl="%{loadUrl}" + onSelectRowTopics='users-rowSelect' editinline="false" onCompleteTopics='users-cleanSelect' navigatorEdit="false" navigatorDelete="false" navigatorSearch="false" navigatorRefresh="false" navigatorAdd="false" viewrecords="true" - rowList="10,15,20,50,100" rowNum="10"> + 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' }}"> + <sjg:gridColumn name="id" title="id" hidden="true"/> - <sjg:gridColumn name="login" title='%{getText("pollen.common.login")}' sortable="false" editable="true"/> - <sjg:gridColumn name="firstName" title='%{getText("pollen.common.firstName")}' sortable="false" editable="true"/> - <sjg:gridColumn name="lastName" title='%{getText("pollen.common.lastName")}' sortable="false" editable="true"/> - <sjg:gridColumn name="email" title='%{getText("pollen.common.email")}' sortable="false" editable="true"/> - <sjg:gridColumn name="admin" title='%{getText("pollen.common.admin")}' sortable="false" width="100" formatter="checkbox" editable="true" edittype="checkbox"/> + <sjg:gridColumn name="login" title='%{getText("pollen.common.login")}' + sortable="false"/> + <sjg:gridColumn name="firstName" title='%{getText("pollen.common.firstName")}' + sortable="false"/> + <sjg:gridColumn name="lastName" title='%{getText("pollen.common.lastName")}' + sortable="false"/> + <sjg:gridColumn name="email" title='%{getText("pollen.common.email")}' + sortable="false"/> + <sjg:gridColumn name="admin" title='%{getText("pollen.common.admin")}' + sortable="false" width="100" formatter="checkbox" + editable="true" /> </sjg:grid> + +<br/> + +<s:form id='editForm' method="POST" namespace="/admin" cssClass="hidden"> + + <s:hidden key="updateUser.topiaId" label=""/> + <s:hidden key="updateUser.login" label=""/> + + <fieldset> + <legend><s:text name="pollen.fieldset.userInformation"/></legend> + <s:textfield key="updateUser.email" label="%{getText('pollen.common.email')}" + required="true"/> + <s:textfield key="updateUser.firstName" + label="%{getText('pollen.common.firstName')}"/> + <s:textfield key="updateUser.lastName" + label="%{getText('pollen.common.lastName')}"/> + <s:checkbox key="updateUser.admin" label="%{getText('pollen.common.admin')}"/> + </fieldset> + <br/> + <s:submit action="updateUser" key="pollen.action.validate" align="center"/> + +</s:form> + +<s:form id='createForm' method="POST" namespace="/admin" cssClass="hidden"> + + <fieldset> + <legend><s:text name="pollen.fieldset.userInformation.toCreate"/></legend> + <s:textfield key="createUser.login" label="%{getText('pollen.common.login')}" required="true"/> + <s:textfield key="createUser.email" label="%{getText('pollen.common.email')}" required="true"/> + <s:textfield key="createUser.firstName" label="%{getText('pollen.common.firstName')}"/> + <s:textfield key="createUser.lastName" label="%{getText('pollen.common.lastName')}"/> + <s:checkbox key="createUser.admin" label="%{getText('pollen.common.admin')}"/> + </fieldset> + <br/> + <s:submit action="createUser" key="pollen.action.create" align="center"/> +</s:form> + +<s:form id='deleteForm' method="POST" namespace="/admin" cssClass="hidden"> + + <s:hidden key="deleteUser.topiaId" label=""/> + <s:hidden key="deleteUser.login" label=""/> + + <fieldset> + <legend><s:text name="pollen.fieldset.userInformation.toDelete"/></legend> + <s:textfield key="deleteUser.login" label="%{getText('pollen.common.login')}" required="true" disabled="true"/> + <s:textfield key="deleteUser.email" label="%{getText('pollen.common.email')}" required="true" disabled="true"/> + <s:textfield key="deleteUser.firstName" label="%{getText('pollen.common.firstName')}" disabled="true"/> + <s:textfield key="deleteUser.lastName" label="%{getText('pollen.common.lastName')}" disabled="true"/> + <s:checkbox key="deleteUser.admin" label="%{getText('pollen.common.admin')}" disabled="true"/> + </fieldset> + <br/> + <s:submit action="deleteUser" key="pollen.action.delete" align="center"/> +</s:form> + + Modified: branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/js/gridHelper.js =================================================================== --- branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/js/gridHelper.js 2012-01-23 17:09:06 UTC (rev 3104) +++ branches/pollen-2.0-beta-1/pollen-ui-struts2/src/main/webapp/js/gridHelper.js 2012-01-23 17:15:11 UTC (rev 3105) @@ -55,13 +55,40 @@ }, {id:gridId, callback:callback}); }, - addAddRowTopic:function (gridId, url) { + listenRowTopic:function (topic, callback) { + $.subscribe(topic, function (event) { + var callback = event.data.callback; + if (callback) { + callback(event); + } + }, {callback:callback}); + }, + + addAddRowTopic:function (gridId, callback) { $.subscribe(gridId + '-rowAdd', function (event) { - var url = event.data.url; - window.location = url; - }, {id:gridId, url:url}); + var callback = event.data.callback; + if (callback) { + callback(event); + } + }, {id:gridId, callback:callback}); }, + addDeleteRowTopic:function (gridId, callback) { + $.subscribe(gridId + '-rowDelete', function (event) { + var callback = event.data.callback; + if (callback) { + callback(event); + } + }, {id:gridId, callback:callback}); + }, + +// addAddRowTopic:function (gridId, url) { +// $.subscribe(gridId + '-rowAdd', function (event) { +// var url = event.data.url; +// window.location = url; +// }, {id:gridId, url:url}); +// }, + addSingleRowTopic:function (gridId, action, url, parameterName) { $.subscribe(gridId + '-row' + action, function (event) { var gridId = event.data.id; @@ -145,10 +172,18 @@ return $(document).addClearSelectTopic(gridId, callback); }, - addAddRowTopic:function (gridId, url) { - return $(document).addAddRowTopic(gridId, url); + addAddRowTopic:function (gridId, callback) { + return $(document).addAddRowTopic(gridId, callback); }, + listenRowTopic:function (topic, callback) { + return $(document).listenRowTopic(topic, callback); + }, + + addDeleteRowTopic:function (gridId, callback) { + return $(document).addDeleteRowTopic(gridId, callback); + }, + addSingleRowTopic:function (gridId, action, url, parameterName) { return $(document).addSingleRowTopic(gridId, action, url, parameterName); },
participants (1)
-
tchemit@users.chorem.org