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 1942c9560a4fec497777fe4bd8f215945b3b8398 Author: kootox <jean.couteau@gmail.com> Date: Tue Feb 3 10:45:20 2015 +0100 refs #882 : Can now edit companies --- .../webmotion/actions/crm/CompaniesAction.java | 52 +++-- chorem-webmotion/src/main/resources/mapping | 5 +- .../WEB-INF/jsp/crm/cards/companyInfoCard.jsp | 6 +- .../jsp/crm/cards/contactDetailsListCard.jsp | 2 - .../WEB-INF/jsp/crm/cards/editCompanyCard.jsp | 56 +++++ .../WEB-INF/jsp/crm/cards/employeesListCard.jsp | 2 - .../webapp/WEB-INF/jsp/crm/cards/notesListCard.jsp | 48 ++--- .../src/main/webapp/WEB-INF/jsp/crm/companies.jsp | 238 +++++++-------------- .../src/main/webapp/WEB-INF/jsp/crm/company2.jsp | 2 + 9 files changed, 210 insertions(+), 201 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 ab0c2ad..82ea60b 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 @@ -12,20 +12,18 @@ import org.nuiton.wikitty.query.WikittyQueryMaker; import java.util.List; -/** - * Created by couteau on 28/01/15. - */ public class CompaniesAction extends WebMotionController { /** - * Rend le graphe des devis envoyés par mois + * Render the company screen (company list + first company displayed) * - * @param client - * @return + * @param client ChoremClient to fetch data + * @return the page */ public Render listCompanies(ChoremClient client) { //list all the companies - WikittyQuery companiesQuery = new WikittyQueryMaker().exteq(Company.EXT_COMPANY).end(); + WikittyQuery companiesQuery = new WikittyQueryMaker().exteq(Company.EXT_COMPANY) + .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 @@ -55,26 +53,54 @@ public class CompaniesAction extends WebMotionController { "notes", notes); } - public List<Note> listNotes(ChoremClient client, String companyId) { + /** + * Render the modal form content to edit companies + * @param client ChoremClient to fetch data + * @param id the company to edit id + * @return the modal form content + */ + public Render editCompany(ChoremClient client, String id) { + Company company = client.restore(Company.class, id); + return renderView("crm/cards/editCompanyCard.jsp", + "company", company); + } + + /** + * Save the edited company + * @param client ChoremClient to fetch data + * @param id the company to edit id + * @param name the new name + * @param type the new type + * @return the modal form content + */ + public Render updateCompany(ChoremClient client, String id, String name, String type) { + Company company = client.restore(Company.class, id); + company.setName(name); + company.setType(type); + client.store(company); + return listCompanies(client); + } + + protected List<Note> listNotes(ChoremClient client, String companyId) { WikittyQuery notesQuery = new WikittyQueryMaker().and() .exteq(Note.EXT_NOTE) - .eq(Note.FQ_FIELD_NOTE_TARGET, companyId).end(); + .eq(Note.FQ_FIELD_NOTE_TARGET, companyId).end().setLimit(WikittyQuery.MAX);; List<Note> notes = client.findAllByQuery(Note.class, notesQuery).getAll(); return notes; } - public List<ContactDetails> listContactDetails(ChoremClient client, String companyId) { + protected List<ContactDetails> listContactDetails(ChoremClient client, String companyId) { WikittyQuery contactDetailsQuery = new WikittyQueryMaker().and() .exteq(ContactDetails.EXT_CONTACTDETAILS) - .eq(ContactDetails.FQ_FIELD_CONTACTDETAILS_TARGET, companyId).end(); + .eq(ContactDetails.FQ_FIELD_CONTACTDETAILS_TARGET, companyId).end().setLimit(WikittyQuery.MAX);; List<ContactDetails> contactDetails = client.findAllByQuery(ContactDetails.class, contactDetailsQuery).getAll(); return contactDetails; } - public List<Employee> listEmployee(ChoremClient client, String companyId) { + protected List<Employee> listEmployee(ChoremClient client, String companyId) { WikittyQuery employeesQuery = new WikittyQueryMaker().and() .exteq(Employee.EXT_EMPLOYEE) - .eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).end(); + .eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, companyId).end().setLimit(WikittyQuery.MAX);; List<Employee> employees = client.findAllByQuery(Employee.class, employeesQuery).getAll(); return employees; } diff --git a/chorem-webmotion/src/main/resources/mapping b/chorem-webmotion/src/main/resources/mapping index f813fca..8d10522 100644 --- a/chorem-webmotion/src/main/resources/mapping +++ b/chorem-webmotion/src/main/resources/mapping @@ -14,6 +14,7 @@ default.render=org.debux.webmotion.server.render.DefaultRender * /sales/funnel/partial/* DecoratorFilter.decorate wmDecoratorNo=true * /crm/export DecoratorFilter.decorate wmDecoratorNo=true * /crm/companies/* DecoratorFilter.decorate wmDecoratorNo=true +* /crm/companies DecoratorFilter.decorate wmDecoratorNo=true * /project/editProject.html DecoratorFilter.decorate wmDecoratorNo=true * /financial/expenseAccounts/expenseAccountEntryEdit.html DecoratorFilter.decorate wmDecoratorNo=true * /hr/employeeEdit/json/* DecoratorFilter.decorate wmDecoratorNo=true @@ -95,7 +96,9 @@ GET /* DecoratorFilter.decorate * /crm/quotation/edit/{id} action:crm.QuotationAction.edit * /crm/export action:crm.ExportAction.exportContactBase * /crm/companies action:crm.CompaniesAction.listCompanies -* /crm/companies/{id} action:crm.CompaniesAction.viewCompany +GET /crm/companies/{id} action:crm.CompaniesAction.viewCompany +POST /crm/companies/{id} action:crm.CompaniesAction.updateCompany +* /crm/companies/{id}/edit action:crm.CompaniesAction.editCompany * /crm/companies/add action:crm.CompaniesAction.addCompany GET /rest/project/projects?page={page}&count={count} action:project.ProjectsAction.findAllProjects page=1,count=10 diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/companyInfoCard.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/companyInfoCard.jsp index 3c90b3d..36c0066 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/companyInfoCard.jsp +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/companyInfoCard.jsp @@ -6,7 +6,7 @@ <h3 class="panel-title pull-left">Informations</h3> <div class="btn-group pull-right"> - <a class="btn btn-primary" href="#" data-toggle="modal" data-target="#editModal"> + <a class="btn btn-primary" href="<c:url value="/crm/companies/${company.wikittyId}/edit"/>" data-toggle="modal" data-target="#editModal"> <i class="fa fa-pencil"></i><span>Edit</span> </a> </div> @@ -16,11 +16,11 @@ <div class="list-group"> <div class="list-group-item"> <p class="list-group-item-text">Nom</p> - <h4 class="list-group-item-heading">${company.name}</h4> + <h4 class="list-group-item-heading">${company.name} </h4> </div> <div class="list-group-item"> <p class="list-group-item-text">Type</p> - <h4 class="list-group-item-heading">${company.type}</h4> + <h4 class="list-group-item-heading">${company.type} </h4> </div> </div> </div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/contactDetailsListCard.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/contactDetailsListCard.jsp index 241cbb8..3f42b1e 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/contactDetailsListCard.jsp +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/contactDetailsListCard.jsp @@ -1,7 +1,5 @@ <%@page contentType="text/html" pageEncoding="UTF-8"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - <div class="panel panel-default"> <div class="panel-heading clearfix"> diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/editCompanyCard.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/editCompanyCard.jsp new file mode 100644 index 0000000..9c9c40c --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/editCompanyCard.jsp @@ -0,0 +1,56 @@ +<%@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/${company.wikittyId}"/>" data-pjax="#main"> +<div class="modal-header"> + + <div class="btn-group pull-left"> + <button for="submit-form" 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"> + Edit Company + </h3> + +</div> +<div class="modal-body"> + <input type="hidden" name="_method" value="put"> + <div class="form-group"> + <label class="col-xs-3 control-label">Nom</label> + <div class="col-xs-9"> + <input type="text" name="name" class="form-control" placeholder="Nom de la société" + value="${company.name}"> + </div> + </div> + <div class="form-group"> + <label class="col-xs-3 control-label">Type</label> + <div class="col-xs-9"> + <input type="text" name="type" class="form-control" placeholder="Type de société" + value="${company.type}"> + </div> + </div> + +</div> +</form> + +<div class="modal-footer"> + <button type="button" class="btn btn-danger btn-block" + onclick="bootcards.confirmDelete('company'); return false;"> + <i class="fa fa-trash-o"></i> + Delete Company + </button> +</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/employeesListCard.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/employeesListCard.jsp index 1b918df..2349739 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/employeesListCard.jsp +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/cards/employeesListCard.jsp @@ -1,7 +1,5 @@ <%@page contentType="text/html" pageEncoding="UTF-8"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - <div id="contactCard"> <div class="panel panel-default"> 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 78606e3..5cfe10d 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,36 +1,34 @@ <%@page contentType="text/html" pageEncoding="UTF-8"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> - <div class="panel panel-default"> - <div class="panel-heading clearfix"> - <h3 class="panel-title pull-left">Notes</h3> + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Notes</h3> - <div class="btn-group pull-right"> - <a class="btn btn-primary" href="#" - data-toggle="modal" - data-target="#editModal"> - <i class="fa fa-plus"></i> - <span>Add</span> - </a> - </div> + <div class="btn-group pull-right"> + <a class="btn btn-primary" href="#" + data-toggle="modal" + data-target="#editModal"> + <i class="fa fa-plus"></i> + <span>Add</span> + </a> + </div> - </div> + </div> - <div class="list-group"> + <div class="list-group"> - <c:forEach var="note" items="${notes}"> - <a class="list-group-item" href="#"> - <h4 class="list-group-item-heading">${note.title}</h4> - <p class="list-group-item-text">${note.date}</p> - </a> - </c:forEach> + <c:forEach var="note" items="${notes}"> + <a class="list-group-item" href="#"> + <h4 class="list-group-item-heading">${note.title}</h4> + <p class="list-group-item-text">${note.date}</p> + </a> + </c:forEach> - </div> + </div> - <div class="panel-footer"> - <small class="pull-left">List Card Footer</small> - </div> + <div class="panel-footer"> + <small class="pull-left">List Card Footer</small> + </div> - </div> \ No newline at end of file +</div> \ No newline at end of file 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 33934e5..9650231 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 @@ -24,169 +24,97 @@ <head> <link href="https://cdnjs.cloudflare.com/ajax/libs/bootcards/1.1.0/css/bootcards-desktop..." rel="stylesheet"> <link href="https://netdna.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet" /> + <script src="//code.jquery.com/jquery-2.1.3.min.js"></script> </head> <body> - <div class="container bootcards-container push-right"> - - <div class="row"> - - <!-- left list column --> - <div class="col-sm-5 bootcards-list" id="list" data-title="Companies"> - <div class="panel panel-default"> - <div class="panel-body"> - <div class="search-form"> - <div class="row"> - <div class="col-xs-9"> - <div class="form-group"> - <input type="text" class="form-control" placeholder="Search Companies..."> - <i class="fa fa-search"></i> - </div> - </div> - <div class="col-xs-3"> - <a class="btn btn-primary btn-block" href="#" onclick="bootcards.hideOffCanvasMenu()" > - <i class="fa fa-plus"></i> - <span>Add</span> - </a> - </div> - </div> - </div> - </div><!--panel body--> - - <div class="list-group"> - - <c:forEach var="company" items="${companies}"> - <a class="list-group-item pjax" href="<c:url value="/crm/companies/${company.wikittyId}"/>""> - <i class="fa fa-3x fa-building-o pull-left"></i> - <h4 class="list-group-item-heading">${company.name}</h4> - <p class="list-group-item-text">${company.type} </p> - </a> - </c:forEach> - - </div><!--list-group--> - </div><!--panel--> - - </div><!--list--> - - <!--list details column--> - <div id='listDetails' class="col-sm-7 bootcards-cards hidden-xs"> - - <!-- company info card --> - <%@include file="cards/companyInfoCard.jsp" %> - - <!-- contact details card --> - <%@include file="cards/contactDetailsListCard.jsp" %> - - <!-- notes card --> - <%@include file="cards/notesListCard.jsp" %> - - <!--employees card --> - <%@include file="cards/employeesListCard.jsp" %> - - - </div><!--list-details--> - - </div><!--row--> - - - </div><!--container--> + <div class="container bootcards-container" id="main"> + + <div class="row"> + + <div class="col-sm-6 bootcards-list" id="list" data-title="Companies"> + <div class="panel panel-default"> + <div class="panel-body"> + <div class="search-form"> + <div class="row"> + <div class="col-xs-9"> + <div class="form-group"> + <input type="text" class="form-control" placeholder="Search Companies..."> + <i class="fa fa-search"></i> + </div> + </div> + <div class="col-xs-3"> + <a class="btn btn-primary btn-block" href="/companies/add" + data-toggle="modal" + data-target="#editModal"> + <i class="fa fa-plus"></i> + <span>Add</span> + </a> + </div> + </div> + </div> + </div> + <div class="list-group"> + <c:forEach var="company" items="${companies}"> + <a class="list-group-item pjax" href="<c:url value="/crm/companies/${company.wikittyId}"/>"> + <i class="fa fa-3x fa-building-o pull-left"></i> + <h4 class="list-group-item-heading">${company.name}</h4> + <p class="list-group-item-text">${company.type} </p> + </a> + </c:forEach> + + </div> + <div class="panel-footer"> + <small class="pull-left">Built with Bootcards - Detailed List</small> + </div> + </div> + </div> + + + <div class="col-sm-6 bootcards-cards hidden-xs" id="listDetails"> + + <!-- company info card --> + <%@include file="cards/companyInfoCard.jsp" %> + + <!-- contact details card --> + <%@include file="cards/contactDetailsListCard.jsp" %> + + <!-- notes card --> + <%@include file="cards/notesListCard.jsp" %> + + <!--employees card --> + <%@include file="cards/employeesListCard.jsp" %> + + </div> + </div> + + + </div> + + <!-- Load the required JavaScript libraries --> + <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script> + <script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> + + <script src="//cdnjs.cloudflare.com/ajax/libs/jquery.pjax/1.9.2/jquery.pjax.min.js"></script> + <script src="//cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.3/fastclick.min.js"></script> + + <!-- Bootcards JS file --> + <script src="https://cdnjs.cloudflare.com/ajax/libs/bootcards/1.1.0/js/bootcards.js"></script> - <!--edit contact modal--> - <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModal" aria-hidden="true"> + <!--modals--> + <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModal" aria-hidden="true"> + <div class="modal-dialog"> + <div class="modal-content"></div> + </div> + </div> + <div class="modal fade" id="docsModal" tabindex="-1" role="dialog" aria-labelledby="docsModal" aria-hidden="true"> <div class="modal-dialog"> - <div class="modal-content"> - - <form class="form-horizontal" method="POST" action="/contacts/{{contact.id}}" data-pjax="#main"> - - <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"> - <button class="btn btn-success" data-dismiss="modal"> - <i class="fa fa-check"></i>Save - </button> - </div> - - <h4 class="modal-title"> - Edit Contact - </h4> - </div> - - <div class="modal-body"> - <input type="hidden" name="companyId" value="{{contact.companyId}}"> - <input type="hidden" name="_method" value="put"> - <div class="form-group"> - <label class="col-xs-4 control-label">First Name</label> - <div class="col-xs-8"> - <input type="text" name="firstName" class="form-control" placeholder="First Name" - value="Sofia"> - </div> - </div> - <div class="form-group"> - <label class="col-xs-4 control-label">Last Name</label> - <div class="col-xs-8"> - <input type="text" name="lastName" class="form-control" placeholder="Last Name" - value="Acey"> - </div> - </div> - <div class="form-group"> - <label class="col-xs-4 control-label">Company</label> - <div class="col-xs-8"> - <input type="text" name="department" class="form-control" placeholder="Department" - value="Masung Corp."> - </div> - </div> - <div class="form-group"> - <label class="col-xs-4 control-label">Phone</label> - <div class="col-xs-8"> - <input type="text" name="phone" class="form-control" - placeholder="Phone" - value="+1 650-555-0055"> - </div> - </div> - <div class="form-group"> - <label class="col-xs-4 control-label">Email</label> - <div class="col-xs-8"> - <input type="email" name="email" class="form-control" placeholder="Email" - value="Sofia.Acey@masung.com"> - </div> - </div> - - </div> - </form> - - <div class="modal-footer"> - <button type="button" class="btn btn-danger btn-block" - onclick="bootcards.confirmDelete('contact'); return false;"> - <i class="fa fa-trash-o"></i> - Delete Contact - </button> - </div> - - </div><!--modal-content--> + <div class="modal-content"></div> </div> - </div><!--modal--> - - <!-- Bootstrap & jQuery core JavaScript - ================================================== --> - <!-- Placed at the end of the document so the pages load faster --> - <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> - <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.pjax/1.9.2/jquery.pjax.min.js"></script> - <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script> - - <!-- Bootcards JS --> - <script src="https://cdnjs.cloudflare.com/ajax/libs/bootcards/1.1.0/js/bootcards.js"></script> - - <!--recommended: FTLabs FastClick library--> - <script src="https://cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.3/fastclick.min.js"></script> + </div> - <script type="text/javascript"> + <script type="text/javascript"> /* * Initialize Bootcards. diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/company2.jsp b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/company2.jsp index 972664c..2f734d3 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/company2.jsp +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/company2.jsp @@ -1,5 +1,7 @@ <%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + <!-- company info card --> <%@include file="cards/companyInfoCard.jsp" %> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.