This is an automated email from the git hooks/post-receive script. New commit to branch feature/882 in repository chorem. See http://git.chorem.org/chorem.git commit 53491077788febb3be71bdd7edce0828ea27ec2d Author: kootox <jean.couteau@gmail.com> Date: Wed Feb 4 18:20:06 2015 +0100 refs #882 : complete note CRUD in companies slot --- .../webmotion/actions/crm/CompaniesAction.java | 58 ++++++++++++++++++-- chorem-webmotion/src/main/resources/mapping | 10 ++++ .../webapp/WEB-INF/jsp/crm/cards/addNoteCard.jsp | 59 ++++++++++++++++++++ .../webapp/WEB-INF/jsp/crm/cards/editNoteCard.jsp | 63 ++++++++++++++++++++++ .../webapp/WEB-INF/jsp/crm/cards/noteInfoCard.jsp | 33 ++++++++++++ .../webapp/WEB-INF/jsp/crm/cards/notesListCard.jsp | 8 +-- .../src/main/webapp/WEB-INF/jsp/crm/companies.jsp | 4 +- .../src/main/webapp/WEB-INF/jsp/crm/company.jsp | 4 +- 8 files changed, 231 insertions(+), 8 deletions(-) diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CompaniesAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CompaniesAction.java index f584114..e179857 100644 --- a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CompaniesAction.java +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CompaniesAction.java @@ -4,11 +4,10 @@ import org.chorem.ChoremClient; import org.chorem.entities.*; import org.debux.webmotion.server.WebMotionController; import org.debux.webmotion.server.render.Render; -import org.debux.webmotion.server.render.RenderView; import org.nuiton.wikitty.query.WikittyQuery; import org.nuiton.wikitty.query.WikittyQueryMaker; -import javax.servlet.http.HttpServletRequest; +import java.util.Date; import java.util.List; public class CompaniesAction extends WebMotionController { @@ -22,7 +21,7 @@ public class CompaniesAction extends WebMotionController { //list all the companies WikittyQuery companiesQuery = new WikittyQueryMaker().exteq(Company.EXT_COMPANY) - .end().addSortAscending(Company.ELEMENT_FIELD_COMPANY_NAME).setLimit(WikittyQuery.MAX);; + .end().addSortAscending(Company.ELEMENT_FIELD_COMPANY_NAME).setLimit(WikittyQuery.MAX); List<Company> companies = client.findAllByQuery(Company.class, companiesQuery).getAll(); //get the first company info to init the page @@ -181,6 +180,59 @@ public class CompaniesAction extends WebMotionController { "contactDetails", contactDetails); } + + /////////////////////////////////////////////////////////////////////////////////////////////////////// + // // + // NOTES // + // // + /////////////////////////////////////////////////////////////////////////////////////////////////////// + + public Render editNote(ChoremClient client, String note_id, String id){ + Note note = client.restore(Note.class, note_id); + return renderView("crm/cards/editNoteCard.jsp", + "note", note); + } + + public Render updateNote(ChoremClient client, String id, String note_id, Date date, String title, String content){ + Note note = client.restore(Note.class, note_id); + note.setDate(date); + note.setTitle(title); + note.setContent(content); + note = client.store(note); + return renderView("crm/cards/noteInfoCard.jsp", + "note", note); + } + + public Render deleteNote(ChoremClient client, String id, String note_id){ + client.delete(note_id); + return viewCompany(client, id); + } + + public Render viewNote(ChoremClient client, String id, String note_id){ + Note note = client.restore(Note.class, note_id); + return renderView("crm/cards/noteInfoCard.jsp", + "note", note); + } + + public Render addNoteForm(String id){ + return renderView("crm/cards/addNoteCard.jsp", + "companyId", id); + } + + public Render addNote(ChoremClient client, String id, Date date, String title, String content){ + Note note = new NoteImpl(); + note.setDate(date); + note.setTitle(title); + note.setContent(content); + note.setTarget(id); + client.store(note); + List<Note> notes = listNotes(client, id); + Company company = client.restore(Company.class, id); + return renderView("crm/cards/notesListCard.jsp", + "company", company, + "notes", notes); + } + protected List<Note> listNotes(ChoremClient client, String companyId) { WikittyQuery notesQuery = new WikittyQueryMaker().and() .exteq(Note.EXT_NOTE) diff --git a/chorem-webmotion/src/main/resources/mapping b/chorem-webmotion/src/main/resources/mapping index bd4c17e..661b799 100644 --- a/chorem-webmotion/src/main/resources/mapping +++ b/chorem-webmotion/src/main/resources/mapping @@ -107,14 +107,24 @@ GET /crm/companies/{id} action:crm.CompaniesAction.viewCompany POST /crm/companies/{id} action:crm.CompaniesAction.updateCompany GET /crm/companies/{id}/edit action:crm.CompaniesAction.editCompany POST /crm/companies/{id}/delete action:crm.CompaniesAction.deleteCompany + GET /crm/companies/{id}/contactDetails/add action:crm.CompaniesAction.addContactDetailsForm POST /crm/companies/{id}/contactDetails/add action:crm.CompaniesAction.addContactDetails POST /crm/companies/{id}/contactDetails/{cd_id} action:crm.CompaniesAction.updateContactDetails GET /crm/companies/{id}/contactDetails/{cd_id}/edit action:crm.CompaniesAction.editContactDetails POST /crm/companies/{id}/contactDetails/{cd_id}/delete action:crm.CompaniesAction.deleteContactDetails + +GET /crm/companies/{id}/note/add action:crm.CompaniesAction.addNoteForm +POST /crm/companies/{id}/note/add action:crm.CompaniesAction.addNote +GET /crm/companies/{id}/note/{note_id} action:crm.CompaniesAction.viewNote +POST /crm/companies/{id}/note/{note_id} action:crm.CompaniesAction.updateNote +GET /crm/companies/{id}/note/{note_id}/edit action:crm.CompaniesAction.editNote +POST /crm/companies/{id}/note/{note_id}/delete action:crm.CompaniesAction.deleteNote + GET /crm/employees/{id} action:crm.CompaniesAction.viewEmployee + GET /rest/project/projects?page={page}&count={count} action:project.ProjectsAction.findAllProjects page=1,count=10 GET /project/projects view:projects/projects.jsp GET /project/editProject.html view:projects/editProject.html diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/addNoteCard.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/addNoteCard.jsp new file mode 100644 index 0000000..424e1c8 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/addNoteCard.jsp @@ -0,0 +1,59 @@ +<%@page contentType="text/html" pageEncoding="UTF-8"%> + +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + +<form id="editForm" class="form-horizontal" method="POST" + action="<c:url value="/crm/companies/${companyId}/note/add"/>" + data-pjax="#notesListCard"> +<div class="modal-header"> + + <div class="btn-group pull-left"> + <button class="btn btn-danger" data-dismiss="modal"> + Cancel + </button> + </div> + + <div class="btn-group pull-right"> + <input type="submit" id="editForm-success" class="btn btn-success" data-dismiss="modal" value="Save"> + </div> + <h3 class="modal-title"> + Ajouter une note + </h3> + +</div> +<div class="modal-body"> + <div class="form-group"> + <label class="col-xs-3 control-label">Date</label> + <div class="col-xs-9"> + <input type="date" name="date" class="form-control" placeholder="Date" + value="${note.date}"> + </div> + </div> + <div class="form-group"> + <label class="col-xs-3 control-label">Titre</label> + <div class="col-xs-9"> + <input type="text" name="title" class="form-control" placeholder="Titre" + value="${note.title}"> + </div> + </div> + <div class="form-group"> + <label class="col-xs-3 control-label">Contenu</label> + <div class="col-xs-9"> + <textarea name="content" class="form-control" placeholder="Contenu" + value="${note.content}"/> + </div> + </div> + +</div> +</form> + +<div class="modal-footer"> +</div> + +<script type="text/javascript"> + $(document).ready(function() { + $("#editForm-success").click(function() { + $("#editForm").submit(); + }); + }); +</script> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/editNoteCard.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/editNoteCard.jsp new file mode 100644 index 0000000..4d40566 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/editNoteCard.jsp @@ -0,0 +1,63 @@ +<%@page contentType="text/html" pageEncoding="UTF-8"%> + +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %> + +<form id="editForm" class="form-horizontal" method="POST" + action="<c:url value="/crm/companies/${note.target}/note/${note.wikittyId}"/>" + data-pjax="#listDetails"> +<div class="modal-header"> + + <div class="btn-group pull-left"> + <button class="btn btn-danger" data-dismiss="modal"> + Cancel + </button> + </div> + + <div class="btn-group pull-right"> + <input type="submit" id="editForm-success" class="btn btn-success" data-dismiss="modal" value="Save"> + </div> + <h3 class="modal-title"> + Éditer une note + </h3> + +</div> +<div class="modal-body"> + <div class="form-group"> + <label class="col-xs-3 control-label">Date</label> + <div class="col-xs-9"> + <input type="date" name="date" class="form-control" placeholder="Date" + value="<f:formatDate value="${note.date}" pattern="dd/MM/yyyy" />"> + </div> + </div> + <div class="form-group"> + <label class="col-xs-3 control-label">Titre</label> + <div class="col-xs-9"> + <input type="text" name="title" class="form-control" placeholder="Titre" + value="${note.title}"> + </div> + </div> + <div class="form-group"> + <label class="col-xs-3 control-label">Contenu</label> + <div class="col-xs-9"> + <textarea name="content" class="form-control" placeholder="Contenu">${note.content}</textarea> + </div> + </div> + +</div> +</form> + +<div class="modal-footer"> + <form method="POST" action="<c:url value="/crm/companies/${note.target}/note/${note.wikittyId}/delete"/>" + data-pjax="#listDetails" onsubmit="return confirm('Are you sure you want to delete?');"> + <input type="submit" class="btn btn-danger btn-block" value="Supprimer la note"> + </form> +</div> + +<script type="text/javascript"> + $(document).ready(function() { + $("#editForm-success").click(function() { + $("#editForm").submit(); + }); + }); +</script> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/noteInfoCard.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/noteInfoCard.jsp new file mode 100644 index 0000000..f6b4f8b --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/noteInfoCard.jsp @@ -0,0 +1,33 @@ +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %> + +<div class="panel panel-default"> + + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Note</h3> + + <div class="btn-group pull-right"> + <a class="btn btn-primary" href="<c:url value="/crm/companies/${note.target}/note/${note.wikittyId}/edit"/>" + data-toggle="modal" data-target="#editModal"> + <i class="fa fa-pencil"></i><span>Edit</span> + </a> + </div> + + </div> + + <div class="list-group"> + <div class="list-group-item"> + <p class="list-group-item-text">Titre</p> + <h4 class="list-group-item-heading">${note.title} </h4> + </div> + <div class="list-group-item"> + <p class="list-group-item-text">Date</p> + <h4 class="list-group-item-heading"><f:formatDate value="${note.date}" pattern="dd/MM/yyyy" /> </h4> + </div> + <div class="list-group-item"> + <p class="list-group-item-text">Contenu</p> + <h4 class="list-group-item-heading">${note.content} </h4> + </div> + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/notesListCard.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/notesListCard.jsp index 5cfe10d..ba0c610 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/notesListCard.jsp +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/notesListCard.jsp @@ -1,4 +1,6 @@ <%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %> <div class="panel panel-default"> @@ -6,7 +8,7 @@ <h3 class="panel-title pull-left">Notes</h3> <div class="btn-group pull-right"> - <a class="btn btn-primary" href="#" + <a class="btn btn-primary" href="<c:url value="/crm/companies/${company.wikittyId}/note/add"/>" data-toggle="modal" data-target="#editModal"> <i class="fa fa-plus"></i> @@ -19,9 +21,9 @@ <div class="list-group"> <c:forEach var="note" items="${notes}"> - <a class="list-group-item" href="#"> + <a class="list-group-item pjax" href="<c:url value="/crm/companies/${company.wikittyId}/note/${note.wikittyId}"/>"> <h4 class="list-group-item-heading">${note.title}</h4> - <p class="list-group-item-text">${note.date}</p> + <p class="list-group-item-text"><f:formatDate value="${note.date}" pattern="dd/MM/yyyy" /></p> </a> </c:forEach> diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/companies.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/companies.jsp index 2300c86..28c3e04 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/companies.jsp +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/companies.jsp @@ -83,7 +83,9 @@ </div> <!-- notes card --> - <%@include file="cards/notesListCard.jsp" %> + <div id="notesListCard"> + <%@include file="cards/notesListCard.jsp" %> + </div> <!--employees card --> <%@include file="cards/employeesListCard.jsp" %> diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/company.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/company.jsp index 3a39518..035d92c 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/company.jsp +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/company.jsp @@ -11,7 +11,9 @@ </div> <!-- notes card --> -<%@include file="cards/notesListCard.jsp" %> +<div id="notesListCard"> + <%@include file="cards/notesListCard.jsp" %> +</div> <!--employees card --> <%@include file="cards/employeesListCard.jsp" %> \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.