Author: ymartel Date: 2012-07-03 11:46:27 +0200 (Tue, 03 Jul 2012) New Revision: 203 Url: http://chorem.org/repositories/revision/chorem/203 Log: fix #673 add button in Person \& Employee view to add a Contact detail Added: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/LinkAction.java trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/person/ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/person/view.jsp Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java trunk/chorem-webmotion/src/main/resources/mapping trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/employee/view.jsp Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java =================================================================== --- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-07-02 16:56:13 UTC (rev 202) +++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-07-03 09:46:27 UTC (rev 203) @@ -30,7 +30,6 @@ import org.apache.commons.logging.LogFactory; import org.chorem.ChoremClient; import org.chorem.ChoremConfigOption; -import org.chorem.entities.Attachment; import org.debux.webmotion.server.WebMotionController; import org.debux.webmotion.server.call.Call; import org.debux.webmotion.server.call.UploadFile; @@ -451,30 +450,6 @@ return renderView(StringUtils.lowerCase(extension) + "/edit.jsp", "wikitty", w); } - public Render addAttachment(ChoremClient client, String wikittyId) { - log.debug("add attachment for : " + wikittyId); - Wikitty w = client.restore(wikittyId, ".*"); - - Wikitty attachment = new WikittyImpl(); - - LinkedHashSet<WikittyExtension> exts = new LinkedHashSet<WikittyExtension>(); - - // Load Attachment extension, and potential dependencies - List<String> extensionNames = Arrays.asList(Attachment.EXT_ATTACHMENT); - List<WikittyExtension> newExts = - client.restoreExtensionAndDependenciesLastVesion(extensionNames); - attachment.addExtension(newExts); - - // As we want to edit a wikitty by its extensions, we should edit the required extensions too - // Add the extension and required ones in the list of extensions to display - exts.addAll(newExts); - // Show all wikitty if no extension were mentioned - exts.addAll(attachment.getExtensions()); - - attachment.setField(Attachment.EXT_ATTACHMENT, Attachment.FIELD_ATTACHMENT_TARGET, w); - return renderView("edit.jsp", "wikitty", attachment, "extensions", exts); - } - public Render save(ChoremClient client, String id, String[] extension, Call call) { log.debug("save: " + id); Wikitty w = client.restore(id); Added: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/LinkAction.java =================================================================== --- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/LinkAction.java (rev 0) +++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/LinkAction.java 2012-07-03 09:46:27 UTC (rev 203) @@ -0,0 +1,81 @@ +package org.chorem.webmotion.actions; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.ChoremClient; +import org.chorem.entities.Attachment; +import org.chorem.entities.ContactDetails; +import org.debux.webmotion.server.WebMotionController; +import org.debux.webmotion.server.render.Render; +import org.nuiton.wikitty.entities.Wikitty; +import org.nuiton.wikitty.entities.WikittyExtension; +import org.nuiton.wikitty.entities.WikittyImpl; + +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.List; + +/** + * Regroup the action that links an object with an other + * + * @author ymartel <martel@codelutin.com> + */ +public class LinkAction extends WebMotionController { + + static private Log log = LogFactory.getLog(LinkAction.class); + + public Render addAttachment(ChoremClient client, String wikittyId) { + if (log.isDebugEnabled()) { + log.debug("add attachment for : " + wikittyId); + } + + // Prepare attachment + Wikitty attachment = new WikittyImpl(); + + // Load Attachment extension, and potential dependencies + List<String> extensionNames = Arrays.asList(Attachment.EXT_ATTACHMENT); + List<WikittyExtension> newExts = + client.restoreExtensionAndDependenciesLastVesion(extensionNames); + attachment.addExtension(newExts); + + // As we want to edit a wikitty by its extensions, we should edit the required extensions too + // Add the extension and required ones in the list of extensions to display + LinkedHashSet<WikittyExtension> exts = new LinkedHashSet<WikittyExtension>(); + exts.addAll(newExts); + // Show all wikitty if no extension were mentioned + exts.addAll(attachment.getExtensions()); + + // Link target Wikitty + Wikitty linkedWikitty = client.restore(wikittyId, ".*"); + attachment.setField(Attachment.EXT_ATTACHMENT, Attachment.FIELD_ATTACHMENT_TARGET, linkedWikitty); + + return renderView("edit.jsp", "wikitty", attachment, "extensions", exts); + } + + public Render addContactDetails(ChoremClient client, String wikittyId) { + if (log.isDebugEnabled()) { + log.debug("add contact drtails for : " + wikittyId); + } + Wikitty w = client.restore(wikittyId, ".*"); + + Wikitty attachment = new WikittyImpl(); + + LinkedHashSet<WikittyExtension> exts = new LinkedHashSet<WikittyExtension>(); + + // Load Attachment extension, and potential dependencies + List<String> extensionNames = Arrays.asList(ContactDetails.EXT_CONTACTDETAILS); + List<WikittyExtension> newExts = + client.restoreExtensionAndDependenciesLastVesion(extensionNames); + attachment.addExtension(newExts); + + // As we want to edit a wikitty by its extensions, we should edit the required extensions too + // Add the extension and required ones in the list of extensions to display + exts.addAll(newExts); + // Show all wikitty if no extension were mentioned + exts.addAll(attachment.getExtensions()); + + attachment.setField(ContactDetails.EXT_CONTACTDETAILS, ContactDetails.FIELD_CONTACTDETAILS_TARGET, w); + return renderView("edit.jsp", "wikitty", attachment, "extensions", exts); + } + +} Modified: trunk/chorem-webmotion/src/main/resources/mapping =================================================================== --- trunk/chorem-webmotion/src/main/resources/mapping 2012-07-02 16:56:13 UTC (rev 202) +++ trunk/chorem-webmotion/src/main/resources/mapping 2012-07-03 09:46:27 UTC (rev 203) @@ -15,10 +15,12 @@ * / view:index.jsp * /wikitty/{extension}/search action:GenericAction.search * /wikitty/Employee/view/{id} action:GenericAction.extensionView extension=Employee +* /wikitty/Person/view/{id} action:GenericAction.extensionView extension=Person * /wikitty/{extension}/view/{id} action:GenericAction.view * /wikitty/Company/edit/{id} action:GenericAction.extensionEdit extension=Company * /wikitty/{extension}/edit/{id} action:GenericAction.edit -* /wikitty/{wikittyId}/Attachment/edit/new action:GenericAction.addAttachment +* /wikitty/{wikittyId}/Attachment/edit/new action:LinkAction.addAttachment +* /wikitty/{wikittyId}/ContactDetails/edit/new action:LinkAction.addContactDetails * /wikitty/{extension}/delete/{id} action:GenericAction.delete * /wikitty/search action:GenericAction.search * /wikitty/searchRelated?id={query} action:GenericAction.search Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/employee/view.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/employee/view.jsp 2012-07-02 16:56:13 UTC (rev 202) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/employee/view.jsp 2012-07-03 09:46:27 UTC (rev 203) @@ -54,7 +54,7 @@ <a class="btn btn-success" href="<c:url value="/wikitty/${wikitty.id}/Attachment/edit/new"/>"><i class="icon-plus icon-white"></i> Add Attachment</a> </p> <p> - <a class="btn btn-success" href="<c:url value="/wikitty/ContactDetails/edit/new"/>"><i class="icon-plus icon-white"></i> Add Contact Details</a> + <a class="btn btn-success" href="<c:url value="/wikitty/${wikitty.id}/ContactDetails/edit/new"/>"><i class="icon-plus icon-white"></i> Add Contact Details</a> </p> <div class="container"> Added: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/person/view.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/person/view.jsp (rev 0) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/person/view.jsp 2012-07-03 09:46:27 UTC (rev 203) @@ -0,0 +1,53 @@ +<%-- + #%L + Chorem webmotion + $Id:$ + $HeadURL:$ + %% + Copyright (C) 2011 - 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" pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="/WEB-INF/wikitty.tld" prefix="w"%> + +<p> + <c:if test="${not empty wikitty}"> + <a class="btn btn-success" href="<c:url value="/wikitty/view/${wikitty.id}"/>"><i class="icon-list icon-white"></i> View all extension</a> + <a class="btn btn-success" href="<c:url value="/wikitty/edit/${wikitty.id}"/>"><i class="icon-pencil icon-white"></i> Edit object</a> + <a class="btn btn-danger" href="<c:url value="/wikitty/delete/${wikitty.id}?wmDecoratorNo=true"/>"><i class="icon-trash icon-white"></i> Delete object</a> + </c:if> +</p> + + <dl><dt><a href="<c:url value="/wikitty/Person/search"/>">Personne</a> + <a class="btn btn-success btn-mini" href="<c:url value="/wikitty/Person/edit/${wikitty.id}"/>"><i class="icon-pencil icon-white"></i> Edit</a> + <a class="btn btn-danger btn-mini" href="<c:url value="/wikitty/delete/${wikitty.id}?extension=Person&wmDecoratorNo=true"/>"><i class="icon-trash icon-white"></i> Delete</a></dt> + <dd><w:display wikitty="${wikitty}" fqfield="Person.firstName"/></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Person.lastName"/></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Person.birthDate"/></dd> + <dd><w:display wikitty="${wikitty}" fqfield="Person.diploma"/></dd> + </dl> + + <p> + <a class="btn btn-success" href="<c:url value="/wikitty/${wikitty.id}/Attachment/edit/new"/>"><i class="icon-plus icon-white"></i> Add Attachment</a> + </p> + <p> + <a class="btn btn-success" href="<c:url value="/wikitty/${wikitty.id}/ContactDetails/edit/new"/>"><i class="icon-plus icon-white"></i> Add Contact Details</a> + </p> + +<div class="container"> + <jsp:include page="/wikitty/searchRelated?id=${wikitty.id}"/> +</div>