branch feature/882-angular created (now 89ebbb7)
This is an automated email from the git hooks/post-receive script. New change to branch feature/882-angular in repository chorem. See http://git.chorem.org/chorem.git at 89ebbb7 refs #882 : Add date picker on invoices This branch includes the following new commits: new e0f1a75 refs #882 : Initiate CRM using bootcards and angular. Working nice on easy stuff. new abacf7d refs #882 : Working companies CRUD, but parasite refreshs to be dealt with new 5cd6b7a refs #882 : Better refresh/requests management for company CRUD new 9c120d2 refs #882 : filter case insensitive new 56dd045 refs #882 : Now got notes and employees displayed on company detail panel new 2cc12ef refs #882 : Note CRUD on companies screen new b74fe5c refs #882 : ContactDetails CRUD from company info new 3cd452c refs #882 : Adds employees CRUD reusing notes and contact details card new a5f63dc refs #882 : Remove useless footers new a258442 refs #882 : deal with invoices on companies new 89ebbb7 refs #882 : Add date picker on invoices The 11 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 89ebbb7927cf0c5f74baf123ca2ebd8ab3cb97c4 Author: kootox <jean.couteau@gmail.com> Date: Thu Mar 19 10:57:09 2015 +0100 refs #882 : Add date picker on invoices commit a258442dae7587b56c50d91aa9a7f2a2c57db361 Author: kootox <jean.couteau@gmail.com> Date: Wed Mar 11 16:17:35 2015 +0100 refs #882 : deal with invoices on companies commit a5f63dcaecb0f1334ef6b907990da330e1a681b7 Author: kootox <jean.couteau@gmail.com> Date: Tue Mar 10 16:43:59 2015 +0100 refs #882 : Remove useless footers commit 3cd452c834b5556332cef0d36a3d39e894082eee Author: kootox <jean.couteau@gmail.com> Date: Tue Mar 10 16:07:17 2015 +0100 refs #882 : Adds employees CRUD reusing notes and contact details card commit b74fe5c6af1644cbd227abb4871bc5419e86923e Author: kootox <jean.couteau@gmail.com> Date: Thu Mar 5 15:51:04 2015 +0100 refs #882 : ContactDetails CRUD from company info commit 2cc12ef17d27a63e582cf9d051e14bed98fba930 Author: kootox <jean.couteau@gmail.com> Date: Thu Mar 5 14:49:02 2015 +0100 refs #882 : Note CRUD on companies screen commit 56dd045646370eb1ac0a2c82bc8674944939fcb1 Author: kootox <jean.couteau@gmail.com> Date: Wed Mar 4 16:02:44 2015 +0100 refs #882 : Now got notes and employees displayed on company detail panel commit 9c120d28bcce1ed8e31ec74b5e868b5aac560283 Author: kootox <jean.couteau@gmail.com> Date: Wed Mar 4 14:50:48 2015 +0100 refs #882 : filter case insensitive commit 5cd6b7a7949d23fbddf55cf9039fca2f5173cf9d Author: kootox <jean.couteau@gmail.com> Date: Wed Mar 4 14:33:29 2015 +0100 refs #882 : Better refresh/requests management for company CRUD commit abacf7db1aa21d2a75413ec193a01e02abea47df Author: kootox <jean.couteau@gmail.com> Date: Wed Mar 4 12:20:57 2015 +0100 refs #882 : Working companies CRUD, but parasite refreshs to be dealt with commit e0f1a75ecab7601c6e35b02d15d0424fc11b4974 Author: kootox <jean.couteau@gmail.com> Date: Tue Mar 3 11:19:00 2015 +0100 refs #882 : Initiate CRM using bootcards and angular. Working nice on easy stuff. -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/882-angular in repository chorem. See http://git.chorem.org/chorem.git commit abacf7db1aa21d2a75413ec193a01e02abea47df Author: kootox <jean.couteau@gmail.com> Date: Wed Mar 4 12:20:57 2015 +0100 refs #882 : Working companies CRUD, but parasite refreshs to be dealt with --- .../webmotion/actions/crm/CompaniesAction.java | 34 +++++- .../chorem/webmotion/actions/crm/CompanyDTO.java | 8 ++ chorem-webmotion/src/main/resources/mapping | 6 + .../main/webapp/WEB-INF/jsp/crm/angularTest.html | 88 +-------------- .../jsp/crm/partials/companyCreateCard.html | 43 ++++++++ .../WEB-INF/jsp/crm/partials/companyEditCard.html | 46 ++++++++ .../WEB-INF/jsp/crm/partials/companyInfoCard.html | 29 +++++ .../WEB-INF/jsp/crm/partials/companyPanel.html | 13 +++ .../jsp/crm/partials/contactDetailsListCard.html | 29 +++++ chorem-webmotion/src/main/webapp/js/crm.js | 122 +++++++++++++++++---- 10 files changed, 314 insertions(+), 104 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 3ff8f91..59bdaed 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 @@ -2,6 +2,7 @@ package org.chorem.webmotion.actions.crm; import org.chorem.ChoremClient; import org.chorem.entities.Company; +import org.chorem.entities.CompanyImpl; import org.debux.webmotion.server.WebMotionController; import org.debux.webmotion.server.render.Render; import org.nuiton.wikitty.query.WikittyQuery; @@ -20,7 +21,8 @@ public class CompaniesAction extends WebMotionController { //recuperation des contact details WikittyQuery companiesQuery = new WikittyQueryMaker().and() .exteq(Company.EXT_COMPANY) - .end().setLimit(WikittyQuery.MAX); + .end().setLimit(WikittyQuery.MAX) + .addSortAscending(Company.ELEMENT_FIELD_COMPANY_NAME); WikittyQueryResult<Company> companies = client.findAllByQuery(Company.class, @@ -35,4 +37,34 @@ public class CompaniesAction extends WebMotionController { return renderJSON(companyDTOs); } + public Render getCompany(ChoremClient client, String id) { + Company company = client.restore(Company.class, id); + CompanyDTO companyDTO = new CompanyDTO(company); + + return renderJSON(companyDTO); + } + + public Render updateCompany(ChoremClient client, String id, CompanyDTO companyDTO) { + Company company = client.restore(Company.class, id); + company.setName(companyDTO.getName()); + company.setType(companyDTO.getType()); + client.store(company); + + return renderSuccess(); + } + + public Render createCompany(ChoremClient client, CompanyDTO companyDTO) { + Company company = new CompanyImpl(); + company.setName(companyDTO.getName()); + company.setType(companyDTO.getType()); + client.store(company); + return renderJSON(company.getWikittyId()); + } + + public Render deleteCompany(ChoremClient client, String id) { + client.delete(id); + + return renderSuccess(); + } + } diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CompanyDTO.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CompanyDTO.java index 7e57379..f10acdc 100644 --- a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CompanyDTO.java +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CompanyDTO.java @@ -13,6 +13,14 @@ public class CompanyDTO { protected String type; + public CompanyDTO () { + } + + public CompanyDTO(String name, String type) { + this.name = name; + this.type = type; + } + public CompanyDTO (Company company) { this.name = company.getName(); this.type = company.getType(); diff --git a/chorem-webmotion/src/main/resources/mapping b/chorem-webmotion/src/main/resources/mapping index 0fd0413..a6c90d5 100644 --- a/chorem-webmotion/src/main/resources/mapping +++ b/chorem-webmotion/src/main/resources/mapping @@ -96,7 +96,13 @@ GET /* DecoratorFilter.decorate * /crm/export action:crm.ExportAction.exportContactBase GET /crm/companies.html view:crm/angularTest.html GET /crm/companies action:crm.CompaniesAction.listCompanies +GET /crm/companies/{id} action:crm.CompaniesAction.getCompany +POST /crm/companies/{id} action:crm.CompaniesAction.updateCompany +PUT /crm/companies/add action:crm.CompaniesAction.createCompany + +DELETE /crm/companies/{id} action:crm.CompaniesAction.deleteCompany GET /crm/companies/{id}/contactDetails action:crm.ContactDetailsAction.listContactDetails +GET /crm/partials/{page} view:crm/partials/{page} GET /rest/project/projects?page={page}&count={count} action:project.ProjectsAction.findAllProjects page=1,count=10 GET /project/projects view:projects/projects.jsp diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html index 5624d4a..daec9fe 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html @@ -7,6 +7,7 @@ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> + <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-route.js"></script> <script src="/chorem/js/crm.js"></script> <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" /> @@ -30,7 +31,7 @@ </div> </div> <div class="col-xs-3"> - <a class="btn btn-primary btn-block" href="#"> + <a class="btn btn-primary btn-block" href="#/companies/add"> <i class="fa fa-plus"></i> <span>Add</span> </a> @@ -40,8 +41,8 @@ </div> <div class="list-group"> - <a class="list-group-item" href="#" - ng-repeat="company in filteredCompanies | orderBy:'name' " + <a class="list-group-item" href="#/companies/{{company.wikittyId}}" + ng-repeat="company in filteredCompanies" ng-class="{'active':isCompanySelected(company)}" ng-click="setCompanySelected(company)"> <i class="fa fa-3x fa-building-o pull-left"></i> @@ -59,87 +60,8 @@ </div> - <div class="col-sm-6 bootcards-cards" id="listDetails" ng-controller="CompanyDetailsController"> - <!-- company info card --> - <div id="companyCard"> - - <div class="panel panel-default"> - <div class="panel-heading clearfix"> - <h3 class="panel-title pull-left">Détails de la société</h3> - <div class="btn-group pull-right visible-xs"> - <a class="btn btn-primary" href="#" - data-toggle="modal" - data-target="#editModal"> - <i class="fa fa-pencil"></i> - <span>Edit</span> - </a> - </div> - <a class="btn btn-primary pull-right hidden-xs" href="#" - data-toggle="modal" - data-target="#editModal"> - <i class="fa fa-pencil"></i> - <span>Edit</span> - </a> - </div> - <div class="list-group"> - <div class="list-group-item"> - <i class="fa fa-2x fa-building-o pull-left"></i> - <label>Nom</label> - <h4 class="list-group-item-heading">{{company.name}}</h4> - </div> - <div class="list-group-item"> - <label>Type</label> - <h4 class="list-group-item-heading">{{company.type}}</h4> - </div> - </div> - <div class="panel-footer"> - <small class="pull-left"> </small> - </div> - </div> - - </div> - - <!-- contact details card --> - <div id="contactDetailsListCard"> - - <div class="panel panel-default"> - <div class="panel-heading clearfix"> - <h3 class="panel-title pull-left">Moyens de contact</h3> - <div class="btn-group pull-right visible-xs"> - <a class="btn btn-primary" href="#" - data-toggle="modal" - data-target="#editModal"> - <i class="fa fa-pencil"></i> - <span>Edit</span> - </a> - </div> - <a class="btn btn-primary pull-right hidden-xs" href="#" - data-toggle="modal" - data-target="#editModal"> - <i class="fa fa-pencil"></i> - <span>Edit</span> - </a> - </div> - <div class="list-group"> - <div class="list-group-item" - ng-repeat="contact in contactDetails"> - <label>{{contact.type}} - {{contact.name}}</label> - <h4 class="list-group-item-heading">{{contact.value}}</h4> - </div> - </div> - <div class="panel-footer"> - <small class="pull-left"> </small> - </div> - </div> - </div> - - <!-- notes card --> - <div id="notesListCard"> - <%@include file="cards/notesListCard.jsp" %> - </div> + <div class="col-sm-6 bootcards-cards" id="listDetails" ng-view> - <!--employees card --> - <%@include file="cards/employeesListCard.jsp" %> </div> </div> diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyCreateCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyCreateCard.html new file mode 100644 index 0000000..f384092 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyCreateCard.html @@ -0,0 +1,43 @@ +<div class="panel panel-default"> + + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Créer une entreprise</h3> + <div class="btn-group pull-right"> + <button class="btn btn-danger" ng-click="cancel()"> + <i class="fa fa-times"></i> + Annuler + </button> + <button class="btn btn-success" ng-click="saveCompany()"> + <i class="fa fa-check"></i> + Sauver + </button> + </div> + </div> + + <div class="modal-body"> + <form class="form-horizontal"> + <div class="form-group"> + <label class="col-xs-3 control-label">Nom</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="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" class="form-control" ng-model="company.type"> + </div> + </div> + + </form> + </div> + + <div class="modal-footer"> + + </div> + + <div class="panel-footer"> + + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyEditCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyEditCard.html new file mode 100644 index 0000000..74ff087 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyEditCard.html @@ -0,0 +1,46 @@ +<div class="panel panel-default"> + + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Éditer une entreprise</h3> + <div class="btn-group pull-right"> + <button class="btn btn-danger" ng-click="cancel()"> + <i class="fa fa-times"></i> + Annuler + </button> + <button class="btn btn-success" ng-click="saveCompany()"> + <i class="fa fa-check"></i> + Sauver + </button> + </div> + </div> + + <div class="modal-body"> + <form class="form-horizontal"> + <div class="form-group"> + <label class="col-xs-3 control-label">Nom</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="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" class="form-control" ng-model="company.type"> + </div> + </div> + + </form> + </div> + + <div class="modal-footer"> + <button class="btn btn-danger btn-block" ng-click="deleteCompany()"> + <i class="fa fa-trash-o"></i> + Supprimer la société + </button> + </div> + + <div class="panel-footer"> + + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyInfoCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyInfoCard.html new file mode 100644 index 0000000..e6bc455 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyInfoCard.html @@ -0,0 +1,29 @@ +<div class="panel panel-default"> + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Détails de la société</h3> + <div class="btn-group pull-right visible-xs"> + <a class="btn btn-primary" href="#/companies/{{company.wikittyId}}/edit"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <a class="btn btn-primary pull-right hidden-xs" href="#/companies/{{company.wikittyId}}/edit"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <div class="list-group"> + <div class="list-group-item"> + <i class="fa fa-2x fa-building-o pull-left"></i> + <label>Nom</label> + <h4 class="list-group-item-heading">{{company.name}}</h4> + </div> + <div class="list-group-item"> + <label>Type</label> + <h4 class="list-group-item-heading">{{company.type}}</h4> + </div> + </div> + <div class="panel-footer"> + <small class="pull-left"> </small> + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyPanel.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyPanel.html new file mode 100644 index 0000000..86a1f7e --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyPanel.html @@ -0,0 +1,13 @@ +<!-- company info card --> +<ng-include src="'partials/companyInfoCard.html'"></ng-include> + +<!-- contact details card --> +<ng-include src="'partials/contactDetailsListCard.html'"></ng-include> + +<!-- notes card --> +<div id="notesListCard"> + <%@include file="cards/notesListCard.jsp" %> +</div> + +<!--employees card --> +<%@include file="cards/employeesListCard.jsp" %> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsListCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsListCard.html new file mode 100644 index 0000000..39b54b9 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsListCard.html @@ -0,0 +1,29 @@ +<div class="panel panel-default"> + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Moyens de contact</h3> + <div class="btn-group pull-right visible-xs"> + <a class="btn btn-primary" href="#" + data-toggle="modal" + data-target="#editModal"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <a class="btn btn-primary pull-right hidden-xs" href="#" + data-toggle="modal" + data-target="#editModal"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <div class="list-group"> + <div class="list-group-item" + ng-repeat="contact in contactDetails"> + <label>{{contact.type}} - {{contact.name}}</label> + <h4 class="list-group-item-heading">{{contact.value}}</h4> + </div> + </div> + <div class="panel-footer"> + <small class="pull-left"> </small> + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/js/crm.js b/chorem-webmotion/src/main/webapp/js/crm.js index 95cb0ae..041252d 100644 --- a/chorem-webmotion/src/main/webapp/js/crm.js +++ b/chorem-webmotion/src/main/webapp/js/crm.js @@ -1,25 +1,41 @@ -var crmTest = angular.module('crmTest', []); +var crmTest = angular.module('crmTest', ['ngRoute']); -crmTest.factory('sharedService', function($rootScope){ - var sharedService = {}; +crmTest.config(['$routeProvider', + function($routeProvider){ + $routeProvider. - sharedService.company = ''; + when('/companies', { + templateUrl:'partials/companyPanel.html', + controller:'CompanyDetailController'}). - sharedService.broadcastCompanySelected = function (company) { - this.company = company; - $rootScope.$broadcast('companySelected'); - } + when('/companies/add', { + templateUrl:'partials/companyCreateCard.html', + controller:'CompanyCreateController'}). - return sharedService; + when('/companies/:companyId', { + templateUrl:'partials/companyPanel.html', + controller:'CompanyDetailController'}). -}); + when('/companies/:companyId/edit', { + templateUrl:'partials/companyEditCard.html', + controller:'CompanyEditController'}); + }]); -crmTest.controller('CompanyListController', function ($scope, $http, sharedService) { +crmTest.controller('CompanyListController', function ($scope, $http, $location, $route, $routeParams) { $http.get('companies').success(function(data){ $scope.companies = data; - $scope.companySelected=$scope.companies[0]; - sharedService.broadcastCompanySelected($scope.companySelected); + if ($routeParams.companyId){ + //company selected + //$scope.companySelected=$scope.companies[0]; + $location.path('companies/'+$routeParams.companyId); + $route.reload(); + } else { + $scope.companySelected=$scope.companies[0]; + $location.path('companies/'+$scope.companySelected.wikittyId); + $route.reload(); + } + $scope.updateList(); }); @@ -33,7 +49,6 @@ crmTest.controller('CompanyListController', function ($scope, $http, sharedServi $scope.setCompanySelected=function(selectedCompany){ $scope.companySelected = selectedCompany; - sharedService.broadcastCompanySelected(selectedCompany); }; $scope.isCompanySelected=function(selectedCompany){ @@ -52,21 +67,88 @@ crmTest.controller('CompanyListController', function ($scope, $http, sharedServi }); -crmTest.controller('CompanyDetailsController', function ($scope, $http, sharedService){ - $scope.company = ''; +crmTest.controller('CompanyDetailController', function ($scope, $http, $routeParams){ - $scope.contactDetails = ''; + //get back id from params + $scope.companyId = $routeParams.companyId; - $scope.$on('companySelected', function(){ - $scope.company=sharedService.company; + //get company data + $http.get('companies/'+$scope.companyId).success(function(data){ + $scope.company = data; $scope.updateContactDetails(); }); +//init values with empty data for no angular marking + $scope.company = ''; + $scope.contactDetails = ''; + + //get back contact details for the company $scope.updateContactDetails=function(){ - $http.get('companies/'+$scope.company.wikittyId+"/contactDetails").success(function(data){ + $http.get('companies/'+$scope.companyId+"/contactDetails").success(function(data){ $scope.contactDetails = data; }); + }; + +}); + +crmTest.controller('CompanyEditController', function ($scope, $http, $routeParams, $location, $route) { + + //get back id from params + $scope.companyId = $routeParams.companyId; + //get company data + $http.get('companies/'+$scope.companyId).success(function(data){ + $scope.company = data; + }); + + $scope.saveCompany = function(){ + + $http({ + method : 'POST', + url : 'companies/'+$scope.companyId, + data : $.param($scope.company), // pass in data as strings + headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) + }) + .success(function(data) { + $location.path('companies/'+$scope.companyId); + $route.reload(); + }); }; + $scope.cancel = function(){ + $location.path('companies/'+$scope.companyId); + $route.reload(); + } + + $scope.deleteCompany = function(){ + if(confirm('Are you sure you want to delete?')){ + $http.delete('companies/'+$scope.companyId).success(function(data){ + $location.path('companies'); + $route.reload(); + }); + } + } + +}); + +crmTest.controller('CompanyCreateController', function ($scope, $http, $location, $route) { + + $scope.saveCompany = function(){ + $http({ + method : 'PUT', + url : 'companies/add', + data : $.param($scope.company), // pass in data as strings + headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) + }) + .success(function(data) { + $location.path('companies/'+data); + $route.reload(); + }); + }; + + $scope.cancel = function(){ + $location.path('companies/'); + $route.reload(); + } + }); \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/882-angular in repository chorem. See http://git.chorem.org/chorem.git commit 5cd6b7a7949d23fbddf55cf9039fca2f5173cf9d Author: kootox <jean.couteau@gmail.com> Date: Wed Mar 4 14:33:29 2015 +0100 refs #882 : Better refresh/requests management for company CRUD --- .../webmotion/actions/crm/CompaniesAction.java | 13 +- .../main/webapp/WEB-INF/jsp/crm/angularTest.html | 12 +- chorem-webmotion/src/main/webapp/js/crm.js | 150 +++++++++++++-------- 3 files changed, 111 insertions(+), 64 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 59bdaed..ab617a8 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 @@ -48,17 +48,22 @@ public class CompaniesAction extends WebMotionController { Company company = client.restore(Company.class, id); company.setName(companyDTO.getName()); company.setType(companyDTO.getType()); - client.store(company); + company = client.store(company); - return renderSuccess(); + companyDTO = new CompanyDTO(company); + + return renderJSON(companyDTO); } public Render createCompany(ChoremClient client, CompanyDTO companyDTO) { Company company = new CompanyImpl(); company.setName(companyDTO.getName()); company.setType(companyDTO.getType()); - client.store(company); - return renderJSON(company.getWikittyId()); + company = client.store(company); + + companyDTO = new CompanyDTO(company); + + return renderJSON(companyDTO); } public Render deleteCompany(ChoremClient client, String id) { diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html index daec9fe..47f07bc 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html @@ -17,8 +17,8 @@ <body> <div class="container bootcards-container" id="main"> - <div class="row"> - <div class="col-sm-6 bootcards-list" id="list" ng-controller="CompanyListController"> + <div class="row" ng-controller="CompanyListController"> + <div class="col-sm-6 bootcards-list" id="list"> <div class="panel panel-default"> <div class="panel-body"> <div class="search-form"> @@ -26,7 +26,7 @@ <div class="col-xs-9"> <div class="form-group"> <input type="text" class="form-control" placeholder="Search Companies..." - ng-model="search" ng-change="updateList()"> + ng-model="search" ng-change="filter()"> <i class="fa fa-search"></i> </div> </div> @@ -42,9 +42,9 @@ <div class="list-group"> <a class="list-group-item" href="#/companies/{{company.wikittyId}}" - ng-repeat="company in filteredCompanies" - ng-class="{'active':isCompanySelected(company)}" - ng-click="setCompanySelected(company)"> + ng-repeat="company in filteredItems" + ng-class="{'active':isItemSelected(company)}" + ng-click="selectItem(company)"> <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> diff --git a/chorem-webmotion/src/main/webapp/js/crm.js b/chorem-webmotion/src/main/webapp/js/crm.js index 041252d..1a3cc17 100644 --- a/chorem-webmotion/src/main/webapp/js/crm.js +++ b/chorem-webmotion/src/main/webapp/js/crm.js @@ -21,108 +21,145 @@ crmTest.config(['$routeProvider', controller:'CompanyEditController'}); }]); +//Should use heritage for next main list controllers crmTest.controller('CompanyListController', function ($scope, $http, $location, $route, $routeParams) { - $http.get('companies').success(function(data){ - $scope.companies = data; - if ($routeParams.companyId){ - //company selected - //$scope.companySelected=$scope.companies[0]; - $location.path('companies/'+$routeParams.companyId); - $route.reload(); - } else { - $scope.companySelected=$scope.companies[0]; - $location.path('companies/'+$scope.companySelected.wikittyId); - $route.reload(); - } + $scope.items = ''; - $scope.updateList(); - }); + $scope.filteredItems = $scope.items; - $scope.companies = ''; + $scope.searchTerm=""; - $scope.filteredCompanies = $scope.companies; + $scope.selectedItem=$scope.items[0]; - $scope.search=""; + $scope.selectItem=function(selectedCompany){ + $scope.selectedItem = selectedCompany; + }; - $scope.companySelected=$scope.companies[0]; + $scope.selectItemById=function(id){ + for (var index in $scope.items) { + var company = $scope.items[index]; + if (company.wikittyId===id){ + $scope.selectedItem=company; + } + } + } - $scope.setCompanySelected=function(selectedCompany){ - $scope.companySelected = selectedCompany; + $scope.isItemSelected=function(selectedCompany){ + return selectedCompany===$scope.selectedItem; }; - $scope.isCompanySelected=function(selectedCompany){ - return selectedCompany===$scope.companySelected; + $scope.filter=function(){ + $scope.filteredItems=[]; + for (var index in $scope.items) { + var company = $scope.items[index]; + if (company.name.indexOf($scope.searchTerm)>-1){ + $scope.filteredItems.push(company); + } + } }; - $scope.updateList=function(){ - $scope.filteredCompanies=[]; - for (var index in $scope.companies) { - var company = $scope.companies[index]; - if (company.name.indexOf($scope.search)>-1){ - $scope.filteredCompanies.push(company); + $scope.updateItem = function(oldItem, newItem) { + for (var index in $scope.items) { + var company = $scope.items[index]; + if (company===oldItem){ + $scope.items[index]=newItem; } } + + $scope.filter(); } -}); + $scope.addItem = function(newItem) { + $scope.items.push(newItem); + $scope.filter(); + } -crmTest.controller('CompanyDetailController', function ($scope, $http, $routeParams){ + $scope.deleteItem = function(oldItem) { + var index = $scope.items.indexOf(oldItem); - //get back id from params - $scope.companyId = $routeParams.companyId; + if (index > -1) { + $scope.items.splice(index, 1); + } - //get company data - $http.get('companies/'+$scope.companyId).success(function(data){ - $scope.company = data; - $scope.updateContactDetails(); - }); + $scope.filter(); + } -//init values with empty data for no angular marking - $scope.company = ''; - $scope.contactDetails = ''; + $scope.refresh=function(){ + $http.get('companies').success(function(data){ + $scope.items = data; + if ($routeParams.companyId){ + //company selected + $scope.selectItemById($routeParams.companyId); + $location.path('companies/'+$routeParams.companyId); + $route.reload(); + } else { + $scope.selectedItem=$scope.items[0]; + $location.path('companies/'+$scope.selectedItem.wikittyId); + $route.reload(); + } + $scope.filter(); + }); + }; + + $scope.refresh(); + +}); + +crmTest.controller('CompanyDetailController', function ($scope, $http, $routeParams){ + + $scope.company=$scope.selectedItem; //get back contact details for the company $scope.updateContactDetails=function(){ - $http.get('companies/'+$scope.companyId+"/contactDetails").success(function(data){ - $scope.contactDetails = data; - }); + if ($scope.company){ + $http.get('companies/'+$scope.company.wikittyId+"/contactDetails").success(function(data){ + $scope.contactDetails = data; + }); + } }; + $scope.updateContactDetails(); + }); crmTest.controller('CompanyEditController', function ($scope, $http, $routeParams, $location, $route) { - //get back id from params - $scope.companyId = $routeParams.companyId; - - //get company data - $http.get('companies/'+$scope.companyId).success(function(data){ - $scope.company = data; - }); + //copy selectedItem to not modify the parent one + $scope.company=$scope.selectedItem; $scope.saveCompany = function(){ $http({ method : 'POST', - url : 'companies/'+$scope.companyId, + url : 'companies/'+$scope.company.wikittyId, data : $.param($scope.company), // pass in data as strings headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) }) .success(function(data) { - $location.path('companies/'+$scope.companyId); + + //update company and selectedItem in parent scope + $scope.updateItem($scope.selectedCompany, data); + $scope.$parent.selectedCompany=data; + + //then reload + $location.path('companies/'+$scope.selectedItem.wikittyId); $route.reload(); }); }; $scope.cancel = function(){ - $location.path('companies/'+$scope.companyId); + $location.path('companies/'+$scope.selectedItem.wikittyId); $route.reload(); } $scope.deleteCompany = function(){ if(confirm('Are you sure you want to delete?')){ - $http.delete('companies/'+$scope.companyId).success(function(data){ + $http.delete('companies/'+$scope.selectedItem.wikittyId).success(function(data){ + + $scope.deleteItem($scope.selectedItem); + $scope.$parent.selectedItem=''; + $location.path('companies'); $route.reload(); }); @@ -141,6 +178,11 @@ crmTest.controller('CompanyCreateController', function ($scope, $http, $location headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) }) .success(function(data) { + + //update company and selectedItem in parent scope + $scope.addItem(data); + $scope.$parent.selectedItem=data; + $location.path('companies/'+data); $route.reload(); }); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/882-angular in repository chorem. See http://git.chorem.org/chorem.git commit 9c120d28bcce1ed8e31ec74b5e868b5aac560283 Author: kootox <jean.couteau@gmail.com> Date: Wed Mar 4 14:50:48 2015 +0100 refs #882 : filter case insensitive --- chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html | 2 +- chorem-webmotion/src/main/webapp/js/crm.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html index 47f07bc..4901e75 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html @@ -26,7 +26,7 @@ <div class="col-xs-9"> <div class="form-group"> <input type="text" class="form-control" placeholder="Search Companies..." - ng-model="search" ng-change="filter()"> + ng-model="searchTerm" ng-change="filter()"> <i class="fa fa-search"></i> </div> </div> diff --git a/chorem-webmotion/src/main/webapp/js/crm.js b/chorem-webmotion/src/main/webapp/js/crm.js index 1a3cc17..e172a06 100644 --- a/chorem-webmotion/src/main/webapp/js/crm.js +++ b/chorem-webmotion/src/main/webapp/js/crm.js @@ -53,7 +53,8 @@ crmTest.controller('CompanyListController', function ($scope, $http, $location, $scope.filteredItems=[]; for (var index in $scope.items) { var company = $scope.items[index]; - if (company.name.indexOf($scope.searchTerm)>-1){ + var regexp = new RegExp($scope.searchTerm,"i"); + if (company.name.match(regexp)){ $scope.filteredItems.push(company); } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/882-angular in repository chorem. See http://git.chorem.org/chorem.git commit 56dd045646370eb1ac0a2c82bc8674944939fcb1 Author: kootox <jean.couteau@gmail.com> Date: Wed Mar 4 16:02:44 2015 +0100 refs #882 : Now got notes and employees displayed on company detail panel --- .../webmotion/actions/crm/EmployeeAction.java | 38 +++++++++ .../chorem/webmotion/actions/crm/EmployeeDTO.java | 91 ++++++++++++++++++++++ .../chorem/webmotion/actions/crm/NoteAction.java | 38 +++++++++ .../org/chorem/webmotion/actions/crm/NoteDTO.java | 72 +++++++++++++++++ .../chorem/webmotion/actions/crm/PersonDTO.java | 48 ++++++++++++ chorem-webmotion/src/main/resources/mapping | 8 +- .../WEB-INF/jsp/crm/partials/companyPanel.html | 6 +- .../jsp/crm/partials/employeesListCard.html | 29 +++++++ .../WEB-INF/jsp/crm/partials/notesListCard.html | 28 +++++++ chorem-webmotion/src/main/webapp/js/crm.js | 20 +++++ 10 files changed, 373 insertions(+), 5 deletions(-) diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/EmployeeAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/EmployeeAction.java new file mode 100644 index 0000000..a9a04b1 --- /dev/null +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/EmployeeAction.java @@ -0,0 +1,38 @@ +package org.chorem.webmotion.actions.crm; + +import org.chorem.ChoremClient; +import org.chorem.entities.Employee; +import org.debux.webmotion.server.WebMotionController; +import org.debux.webmotion.server.render.Render; +import org.nuiton.wikitty.query.WikittyQuery; +import org.nuiton.wikitty.query.WikittyQueryMaker; +import org.nuiton.wikitty.query.WikittyQueryResult; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by couteau on 04/03/15. + */ +public class EmployeeAction extends WebMotionController{ + + public Render listEmployees(ChoremClient client, String id) { + //recuperation des notes + WikittyQuery employeesQuery = new WikittyQueryMaker().and() + .exteq(Employee.EXT_EMPLOYEE) + .eq(Employee.FQ_FIELD_EMPLOYEE_COMPANY, id) + .end().setLimit(WikittyQuery.MAX); + + WikittyQueryResult<String> employeesIds = client.findAllByQuery(employeesQuery); + + List<Employee> employees = client.restore(Employee.class, employeesIds.getAll(),"Company.person"); + + List<EmployeeDTO> employeeDTOs = new ArrayList<>(); + + for (Employee employee:employees){ + employeeDTOs.add(new EmployeeDTO(employee)); + } + + return renderJSON(employeeDTOs); + } +} diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/EmployeeDTO.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/EmployeeDTO.java new file mode 100644 index 0000000..0e699aa --- /dev/null +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/EmployeeDTO.java @@ -0,0 +1,91 @@ +package org.chorem.webmotion.actions.crm; + +import org.chorem.entities.Company; +import org.chorem.entities.Employee; +import org.chorem.entities.Person; + +/** + * Created by couteau on 04/03/15. + */ +public class EmployeeDTO { + + String wikittyId; + + String companyId; + + CompanyDTO company; + + String personId; + + PersonDTO person; + + String description; + + public EmployeeDTO() { + } + + public EmployeeDTO(Employee employee){ + this.companyId = employee.getCompany(); + this.personId = employee.getPerson(); + this.description = employee.getDescription(); + this.wikittyId = employee.getWikittyId(); + + Company company = employee.getCompany(false); + if (company != null) { + this.company = new CompanyDTO(company); + } + + Person person = employee.getPerson(false); + if (person != null) { + this.person = new PersonDTO(person); + } + } + + public String getCompanyId() { + return companyId; + } + + public void setCompanyId(String companyId) { + this.companyId = companyId; + } + + public String getPersonId() { + return personId; + } + + public void setPersonId(String personId) { + this.personId = personId; + } + + public CompanyDTO getCompany() { + return company; + } + + public void setCompany(CompanyDTO company) { + this.company = company; + } + + public PersonDTO getPerson() { + return person; + } + + public void setPerson(PersonDTO person) { + this.person = person; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getWikittyId() { + return wikittyId; + } + + public void setWikittyId(String wikittyId) { + this.wikittyId = wikittyId; + } +} diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/NoteAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/NoteAction.java new file mode 100644 index 0000000..5dff8c3 --- /dev/null +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/NoteAction.java @@ -0,0 +1,38 @@ +package org.chorem.webmotion.actions.crm; + +import org.chorem.ChoremClient; +import org.chorem.entities.Note; +import org.debux.webmotion.server.WebMotionController; +import org.debux.webmotion.server.render.Render; +import org.nuiton.wikitty.query.WikittyQuery; +import org.nuiton.wikitty.query.WikittyQueryMaker; +import org.nuiton.wikitty.query.WikittyQueryResult; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by couteau on 04/03/15. + */ +public class NoteAction extends WebMotionController{ + + public Render listNotes(ChoremClient client, String id) { + //recuperation des notes + WikittyQuery notesQuery = new WikittyQueryMaker().and() + .exteq(Note.EXT_NOTE) + .eq(Note.FQ_FIELD_NOTE_TARGET, id) + .end().setLimit(WikittyQuery.MAX); + + WikittyQueryResult<Note> notes = + client.findAllByQuery(Note.class, + notesQuery); + + List<NoteDTO> noteDTOs = new ArrayList<>(); + + for (Note note:notes.getAll()){ + noteDTOs.add(new NoteDTO(note)); + } + + return renderJSON(noteDTOs); + } +} diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/NoteDTO.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/NoteDTO.java new file mode 100644 index 0000000..b87b4bb --- /dev/null +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/NoteDTO.java @@ -0,0 +1,72 @@ +package org.chorem.webmotion.actions.crm; + +import org.chorem.entities.Note; + +import java.util.Date; + +/** + * Created by couteau on 04/03/15. + */ +public class NoteDTO { + + String wikittyId; + + String target; + + String content; + + Date date; + + String title; + + public NoteDTO() { + } + + public NoteDTO(Note note){ + this.target = note.getTarget(); + this.content = note.getContent(); + this.date = note.getDate(); + this.title = note.getTitle(); + this.wikittyId = note.getWikittyId(); + } + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getWikittyId() { + return wikittyId; + } + + public void setWikittyId(String wikittyId) { + this.wikittyId = wikittyId; + } +} diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/PersonDTO.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/PersonDTO.java new file mode 100644 index 0000000..d93324b --- /dev/null +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/PersonDTO.java @@ -0,0 +1,48 @@ +package org.chorem.webmotion.actions.crm; + +import org.chorem.entities.Person; + +/** + * Created by couteau on 04/03/15. + */ +public class PersonDTO { + + protected String wikittyId; + + protected String firstName; + + protected String lastName; + + public PersonDTO() { + } + + public PersonDTO(Person person) { + this.firstName = person.getFirstName(); + this.lastName = person.getLastName(); + this.wikittyId = person.getWikittyId(); + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getWikittyId() { + return wikittyId; + } + + public void setWikittyId(String wikittyId) { + this.wikittyId = wikittyId; + } +} diff --git a/chorem-webmotion/src/main/resources/mapping b/chorem-webmotion/src/main/resources/mapping index a6c90d5..bc14900 100644 --- a/chorem-webmotion/src/main/resources/mapping +++ b/chorem-webmotion/src/main/resources/mapping @@ -95,13 +95,19 @@ GET /* DecoratorFilter.decorate * /crm/quotation/edit/{id} action:crm.QuotationAction.edit * /crm/export action:crm.ExportAction.exportContactBase GET /crm/companies.html view:crm/angularTest.html + GET /crm/companies action:crm.CompaniesAction.listCompanies GET /crm/companies/{id} action:crm.CompaniesAction.getCompany POST /crm/companies/{id} action:crm.CompaniesAction.updateCompany PUT /crm/companies/add action:crm.CompaniesAction.createCompany +DELETE /crm/companies/{id} action:crm.CompaniesAction.deleteCompany -DELETE /crm/companies/{id} action:crm.CompaniesAction.deleteCompany GET /crm/companies/{id}/contactDetails action:crm.ContactDetailsAction.listContactDetails + +GET /crm/companies/{id}/notes action:crm.NoteAction.listNotes + +GET /crm/companies/{id}/employees action:crm.EmployeeAction.listEmployees + GET /crm/partials/{page} view:crm/partials/{page} 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/partials/companyPanel.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyPanel.html index 86a1f7e..bcf7732 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyPanel.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyPanel.html @@ -5,9 +5,7 @@ <ng-include src="'partials/contactDetailsListCard.html'"></ng-include> <!-- notes card --> -<div id="notesListCard"> - <%@include file="cards/notesListCard.jsp" %> -</div> +<ng-include src="'partials/notesListCard.html'"></ng-include> <!--employees card --> -<%@include file="cards/employeesListCard.jsp" %> \ No newline at end of file +<ng-include src="'partials/employeesListCard.html'"></ng-include> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html new file mode 100644 index 0000000..6a0bc09 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html @@ -0,0 +1,29 @@ +<div class="panel panel-default"> + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Employés</h3> + <div class="btn-group pull-right visible-xs"> + <a class="btn btn-primary" href="#" + data-toggle="modal" + data-target="#editModal"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <a class="btn btn-primary pull-right hidden-xs" href="#" + data-toggle="modal" + data-target="#editModal"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <div class="list-group"> + <div class="list-group-item" + ng-repeat="employee in employees"> + <label>{{note.date}}</label> + <h4 class="list-group-item-heading">{{employee.person.firstName}} {{employee.person.lastName}}</h4> + </div> + </div> + <div class="panel-footer"> + <small class="pull-left"> </small> + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/notesListCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/notesListCard.html new file mode 100644 index 0000000..13069bd --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/notesListCard.html @@ -0,0 +1,28 @@ +<div class="panel panel-default"> + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Notes</h3> + <div class="btn-group pull-right visible-xs"> + <a class="btn btn-primary" href="#" + data-toggle="modal" + data-target="#editModal"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <a class="btn btn-primary pull-right hidden-xs" href="#" + data-toggle="modal" + data-target="#editModal"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <div class="list-group"> + <div class="list-group-item" ng-repeat="note in notes"> + <label>{{note.date}}</label> + <h4 class="list-group-item-heading">{{note.title}}</h4> + </div> + </div> + <div class="panel-footer"> + <small class="pull-left"> </small> + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/js/crm.js b/chorem-webmotion/src/main/webapp/js/crm.js index e172a06..001603c 100644 --- a/chorem-webmotion/src/main/webapp/js/crm.js +++ b/chorem-webmotion/src/main/webapp/js/crm.js @@ -120,7 +120,27 @@ crmTest.controller('CompanyDetailController', function ($scope, $http, $routePar } }; + //get back notes for the company + $scope.updateNotes=function(){ + if ($scope.company){ + $http.get('companies/'+$scope.company.wikittyId+"/notes").success(function(data){ + $scope.notes = data; + }); + } + }; + + //get back employees for the company + $scope.updateEmployees=function(){ + if ($scope.company){ + $http.get('companies/'+$scope.company.wikittyId+"/employees").success(function(data){ + $scope.employees = data; + }); + } + }; + $scope.updateContactDetails(); + $scope.updateNotes(); + $scope.updateEmployees(); }); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/882-angular in repository chorem. See http://git.chorem.org/chorem.git commit 2cc12ef17d27a63e582cf9d051e14bed98fba930 Author: kootox <jean.couteau@gmail.com> Date: Thu Mar 5 14:49:02 2015 +0100 refs #882 : Note CRUD on companies screen --- .../chorem/webmotion/actions/crm/NoteAction.java | 42 ++++++++++ chorem-webmotion/src/main/resources/mapping | 4 + .../WEB-INF/jsp/crm/partials/noteCreateCard.html | 47 +++++++++++ .../WEB-INF/jsp/crm/partials/noteDetailCard.html | 33 ++++++++ .../WEB-INF/jsp/crm/partials/noteEditCard.html | 50 ++++++++++++ .../WEB-INF/jsp/crm/partials/notesListCard.html | 20 ++--- chorem-webmotion/src/main/webapp/js/crm.js | 94 +++++++++++++++++++++- 7 files changed, 276 insertions(+), 14 deletions(-) diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/NoteAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/NoteAction.java index 5dff8c3..a2bcc70 100644 --- a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/NoteAction.java +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/NoteAction.java @@ -2,6 +2,7 @@ package org.chorem.webmotion.actions.crm; import org.chorem.ChoremClient; import org.chorem.entities.Note; +import org.chorem.entities.NoteImpl; import org.debux.webmotion.server.WebMotionController; import org.debux.webmotion.server.render.Render; import org.nuiton.wikitty.query.WikittyQuery; @@ -35,4 +36,45 @@ public class NoteAction extends WebMotionController{ return renderJSON(noteDTOs); } + + public Render getNote(ChoremClient client, String id) { + Note note = client.restore(Note.class, id); + + NoteDTO noteDTO = new NoteDTO(note); + + return renderJSON(noteDTO); + + } + + public Render createNote(ChoremClient client, NoteDTO noteDTO) { + Note note = new NoteImpl(); + note.setTarget(noteDTO.getTarget()); + note.setContent(noteDTO.getContent()); + note.setTitle(noteDTO.getTitle()); + note.setDate(noteDTO.getDate()); + note = client.store(note); + + noteDTO = new NoteDTO(note); + + return renderJSON(noteDTO); + } + + + public Render updateNote(ChoremClient client, String id, NoteDTO noteDTO) { + Note note = client.restore(Note.class, id); + note.setTitle(noteDTO.getTitle()); + note.setDate(noteDTO.getDate()); + note.setContent(noteDTO.getContent()); + note = client.store(note); + + noteDTO = new NoteDTO(note); + + return renderJSON(noteDTO); + } + + public Render deleteNote(ChoremClient client, String id) { + client.delete(id); + + return renderSuccess(); + } } diff --git a/chorem-webmotion/src/main/resources/mapping b/chorem-webmotion/src/main/resources/mapping index bc14900..774a512 100644 --- a/chorem-webmotion/src/main/resources/mapping +++ b/chorem-webmotion/src/main/resources/mapping @@ -105,6 +105,10 @@ DELETE /crm/companies/{id} action:crm.CompaniesAction.deleteCompa GET /crm/companies/{id}/contactDetails action:crm.ContactDetailsAction.listContactDetails GET /crm/companies/{id}/notes action:crm.NoteAction.listNotes +PUT /crm/notes/add action:crm.NoteAction.createNote +POST /crm/notes/{id} action:crm.NoteAction.updateNote +GET /crm/notes/{id} action:crm.NoteAction.getNote +DELETE /crm/notes/{id} action:crm.NoteAction.deleteNote GET /crm/companies/{id}/employees action:crm.EmployeeAction.listEmployees diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteCreateCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteCreateCard.html new file mode 100644 index 0000000..dc1dd95 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteCreateCard.html @@ -0,0 +1,47 @@ +<div class="panel panel-default"> + + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Créer une note pour {{company.name}}</h3> + <div class="btn-group pull-right"> + <button class="btn btn-danger" ng-click="cancel()"> + <i class="fa fa-times"></i> + Annuler + </button> + <button class="btn btn-success" ng-click="saveNote()"> + <i class="fa fa-check"></i> + Sauver + </button> + </div> + </div> + + <div class="modal-body"> + <form class="form-horizontal"> + <div class="form-group"> + <label class="col-xs-3 control-label">Titre</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="note.title"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Date</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="note.date"> + </div> + </div> + + + <div class="form-group"> + <label class="col-xs-3 control-label">Contenu</label> + <div class="col-xs-9"> + <textarea class="form-control" ng-model="note.content"/> + </div> + </div> + + </form> + </div> + + <div class="panel-footer"> + + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteDetailCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteDetailCard.html new file mode 100644 index 0000000..538e79e --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteDetailCard.html @@ -0,0 +1,33 @@ +<div class="panel panel-default"> + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Détails de la note</h3> + <div class="btn-group pull-right visible-xs"> + <a class="btn btn-primary" href="#/companies/{{company.wikittyId}}/edit"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <a class="btn btn-primary pull-right hidden-xs" href="#/companies/{{company.wikittyId}}/notes/{{note.wikittyId}}/edit"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <div class="list-group"> + <div class="list-group-item"> + <i class="fa fa-2x fa-file-text-o pull-left"></i> + <label>Titre</label> + <h4 class="list-group-item-heading">{{note.title}}</h4> + </div> + <div class="list-group-item"> + <label>Date</label> + <h4 class="list-group-item-heading">{{note.date |date:'dd/MM:yyy'}}</h4> + </div> + <div class="list-group-item"> + <label>Description</label> + <h4 class="list-group-item-heading">{{note.content}}</h4> + </div> + </div> + <div class="panel-footer"> + <small class="pull-left"> </small> + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteEditCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteEditCard.html new file mode 100644 index 0000000..8ca1c6c --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteEditCard.html @@ -0,0 +1,50 @@ +<div class="panel panel-default"> + + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Éditer une note</h3> + <div class="btn-group pull-right"> + <button class="btn btn-danger" ng-click="cancel()"> + <i class="fa fa-times"></i> + Annuler + </button> + <button class="btn btn-success" ng-click="saveNote()"> + <i class="fa fa-check"></i> + Sauver + </button> + </div> + </div> + + <div class="modal-body"> + <form class="form-horizontal"> + <div class="form-group"> + <label class="col-xs-3 control-label">Titre</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="note.title"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Date</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="note.date"> + </div> + </div> + + + <div class="form-group"> + <label class="col-xs-3 control-label">Contenu</label> + <div class="col-xs-9"> + <textarea class="form-control" ng-model="note.content"></textarea> + </div> + </div> + + </form> + </div> + + <div class="panel-footer"> + <button class="btn btn-danger btn-block" ng-click="deleteNote()"> + <i class="fa fa-trash-o"></i> + Supprimer la note + </button> + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/notesListCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/notesListCard.html index 13069bd..a89bd60 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/notesListCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/notesListCard.html @@ -2,25 +2,21 @@ <div class="panel-heading clearfix"> <h3 class="panel-title pull-left">Notes</h3> <div class="btn-group pull-right visible-xs"> - <a class="btn btn-primary" href="#" - data-toggle="modal" - data-target="#editModal"> + <a class="btn btn-primary" href="#/companies/{{company.wikittyId}}/notes/add"> <i class="fa fa-pencil"></i> - <span>Edit</span> + <span>Ajouter</span> </a> </div> - <a class="btn btn-primary pull-right hidden-xs" href="#" - data-toggle="modal" - data-target="#editModal"> - <i class="fa fa-pencil"></i> - <span>Edit</span> + <a class="btn btn-primary pull-right hidden-xs" href="#/companies/{{company.wikittyId}}/notes/add"> + <i class="fa fa-plus"></i> + <span>Ajouter</span> </a> </div> <div class="list-group"> - <div class="list-group-item" ng-repeat="note in notes"> - <label>{{note.date}}</label> + <a class="list-group-item" ng-repeat="note in notes" href="#/companies/{{company.wikittyId}}/notes/{{note.wikittyId}}"/> <h4 class="list-group-item-heading">{{note.title}}</h4> - </div> + <label>{{note.date | date : dd/MM/yyy}}</label> + </a> </div> <div class="panel-footer"> <small class="pull-left"> </small> diff --git a/chorem-webmotion/src/main/webapp/js/crm.js b/chorem-webmotion/src/main/webapp/js/crm.js index 001603c..ea67517 100644 --- a/chorem-webmotion/src/main/webapp/js/crm.js +++ b/chorem-webmotion/src/main/webapp/js/crm.js @@ -18,7 +18,19 @@ crmTest.config(['$routeProvider', when('/companies/:companyId/edit', { templateUrl:'partials/companyEditCard.html', - controller:'CompanyEditController'}); + controller:'CompanyEditController'}). + + when('/companies/:companyId/notes/add', { + templateUrl:'partials/noteCreateCard.html', + controller:'NoteCreateController'}). + + when('/companies/:companyId/notes/:noteId', { + templateUrl:'partials/noteDetailCard.html', + controller:'NoteDetailController'}). + + when('/companies/:companyId/notes/:noteId/edit', { + templateUrl:'partials/noteEditCard.html', + controller:'NoteEditController'}); }]); //Should use heritage for next main list controllers @@ -214,4 +226,82 @@ crmTest.controller('CompanyCreateController', function ($scope, $http, $location $route.reload(); } -}); \ No newline at end of file +}); + +crmTest.controller('NoteCreateController', function ($scope, $http, $location, $route) { + + $scope.company = $scope.selectedItem; + + //$scope.note.target = $scope.company.wikittyId; + + $scope.saveNote = function(){ + $scope.note.target=$scope.company.wikittyId; + $http({ + method : 'PUT', + url : 'notes/add', + data : $.param($scope.note), // pass in data as strings + headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) + }) + .success(function(data) { + $location.path('companies/'+data); + $route.reload(); + }); + }; + + $scope.cancel = function(){ + $location.path('companies/'); + $route.reload(); + } + +}); + +crmTest.controller('NoteDetailController', function ($scope, $http, $routeParams){ + + $scope.company=$scope.selectedItem; + + $http.get('notes/'+$routeParams.noteId).success(function(data){ + $scope.note = data; + }); + +}); + +crmTest.controller('NoteEditController', function ($scope, $http, $routeParams, $location, $route) { + + //copy selectedItem to not modify the parent one + $scope.company=$scope.selectedItem; + + $http.get('notes/'+$routeParams.noteId).success(function(data){ + $scope.note = data; + }); + + $scope.saveNote = function(){ + + $http({ + method : 'POST', + url : 'notes/'+$scope.note.wikittyId, + data : $.param($scope.note), // pass in data as strings + headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) + }) + .success(function(data) { + //then reload + $location.path('companies/'+$scope.selectedItem.wikittyId); + $route.reload(); + }); + }; + + $scope.cancel = function(){ + $location.path('companies/'+$scope.selectedItem.wikittyId); + $route.reload(); + } + + $scope.deleteNote = function(){ + if(confirm('Are you sure you want to delete?')){ + $http.delete('notes/'+$scope.note.wikittyId).success(function(data){ + + $location.path('companies'); + $route.reload(); + }); + } + } + +}); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/882-angular in repository chorem. See http://git.chorem.org/chorem.git commit b74fe5c6af1644cbd227abb4871bc5419e86923e Author: kootox <jean.couteau@gmail.com> Date: Thu Mar 5 15:51:04 2015 +0100 refs #882 : ContactDetails CRUD from company info --- .../actions/crm/ContactDetailsAction.java | 43 +++++++++++ .../webmotion/actions/crm/ContactDetailsDTO.java | 2 + chorem-webmotion/src/main/resources/mapping | 4 + .../jsp/crm/partials/contactDetailsCreateCard.html | 47 +++++++++++ .../jsp/crm/partials/contactDetailsEditCard.html | 50 ++++++++++++ .../jsp/crm/partials/contactDetailsInfoCard.html | 33 ++++++++ .../jsp/crm/partials/contactDetailsListCard.html | 20 +++-- chorem-webmotion/src/main/webapp/js/crm.js | 90 +++++++++++++++++++++- 8 files changed, 277 insertions(+), 12 deletions(-) diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/ContactDetailsAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/ContactDetailsAction.java index ae52c43..4f212ad 100644 --- a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/ContactDetailsAction.java +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/ContactDetailsAction.java @@ -2,6 +2,8 @@ package org.chorem.webmotion.actions.crm; import org.chorem.ChoremClient; import org.chorem.entities.ContactDetails; +import org.chorem.entities.ContactDetailsImpl; +import org.chorem.entities.Note; import org.debux.webmotion.server.WebMotionController; import org.debux.webmotion.server.render.Render; import org.nuiton.wikitty.query.WikittyQuery; @@ -35,4 +37,45 @@ public class ContactDetailsAction extends WebMotionController { return renderJSON(contactDTOs); } + + public Render getContactDetails(ChoremClient client, String id){ + ContactDetails cd = client.restore(ContactDetails.class, id); + + ContactDetailsDTO cdDTO = new ContactDetailsDTO(cd); + + return renderJSON(cdDTO); + } + + public Render createContactDetails(ChoremClient client, ContactDetailsDTO cdDTO){ + ContactDetails cd = new ContactDetailsImpl(); + cd.setTarget(cdDTO.getTarget()); + cd.setValue(cdDTO.getValue()); + cd.setType(cdDTO.getType()); + cd.setName(cdDTO.getName()); + cd = client.store(cd); + + cdDTO = new ContactDetailsDTO(cd); + + return renderJSON(cdDTO); + + } + + public Render updateContactDetails(ChoremClient client, String id, ContactDetailsDTO cdDTO){ + ContactDetails cd = client.restore(ContactDetails.class, id); + cd.setTarget(cdDTO.getTarget()); + cd.setValue(cdDTO.getValue()); + cd.setType(cdDTO.getType()); + cd.setName(cdDTO.getName()); + cd = client.store(cd); + + cdDTO = new ContactDetailsDTO(cd); + + return renderJSON(cdDTO); + } + + public Render deleteContactDetails(ChoremClient client, String id){ + client.delete(id); + + return renderSuccess(); + } } diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/ContactDetailsDTO.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/ContactDetailsDTO.java index 1ad09eb..45889a3 100644 --- a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/ContactDetailsDTO.java +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/ContactDetailsDTO.java @@ -12,6 +12,8 @@ public class ContactDetailsDTO { protected String target; protected String wikittyId; + public ContactDetailsDTO(){} + public ContactDetailsDTO(ContactDetails contact) { this.name = contact.getName(); this.value = contact.getValue(); diff --git a/chorem-webmotion/src/main/resources/mapping b/chorem-webmotion/src/main/resources/mapping index 774a512..00f0bd7 100644 --- a/chorem-webmotion/src/main/resources/mapping +++ b/chorem-webmotion/src/main/resources/mapping @@ -103,6 +103,10 @@ PUT /crm/companies/add action:crm.CompaniesAction.createCompa DELETE /crm/companies/{id} action:crm.CompaniesAction.deleteCompany GET /crm/companies/{id}/contactDetails action:crm.ContactDetailsAction.listContactDetails +PUT /crm/contactDetails/add action:crm.ContactDetailsAction.createContactDetails +POST /crm/contactDetails/{id} action:crm.ContactDetailsAction.updateContactDetails +GET /crm/contactDetails/{id} action:crm.ContactDetailsAction.getContactDetails +DELETE /crm/contactDetails/{id} action:crm.ContactDetailsAction.deleteContactDetails GET /crm/companies/{id}/notes action:crm.NoteAction.listNotes PUT /crm/notes/add action:crm.NoteAction.createNote diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsCreateCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsCreateCard.html new file mode 100644 index 0000000..76cf883 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsCreateCard.html @@ -0,0 +1,47 @@ +<div class="panel panel-default"> + + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Créer un moyen de contact</h3> + <div class="btn-group pull-right"> + <button class="btn btn-danger" ng-click="cancel()"> + <i class="fa fa-times"></i> + Annuler + </button> + <button class="btn btn-success" ng-click="saveContactDetails()"> + <i class="fa fa-check"></i> + Sauver + </button> + </div> + </div> + + <div class="modal-body"> + <form class="form-horizontal"> + <div class="form-group"> + <label class="col-xs-3 control-label">Nom</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="contactDetails.name"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Type</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="contactDetails.type"> + </div> + </div> + + + <div class="form-group"> + <label class="col-xs-3 control-label">Valeur</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="contactDetails.value"> + </div> + </div> + + </form> + </div> + + <div class="panel-footer"> + + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsEditCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsEditCard.html new file mode 100644 index 0000000..5d116d1 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsEditCard.html @@ -0,0 +1,50 @@ +<div class="panel panel-default"> + + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Éditer un moyen de contact</h3> + <div class="btn-group pull-right"> + <button class="btn btn-danger" ng-click="cancel()"> + <i class="fa fa-times"></i> + Annuler + </button> + <button class="btn btn-success" ng-click="saveContactDetails()"> + <i class="fa fa-check"></i> + Sauver + </button> + </div> + </div> + + <div class="modal-body"> + <form class="form-horizontal"> + <div class="form-group"> + <label class="col-xs-3 control-label">Nom</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="contactDetails.name"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Type</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="contactDetails.type"> + </div> + </div> + + + <div class="form-group"> + <label class="col-xs-3 control-label">Valeur</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="contactDetails.value"> + </div> + </div> + + </form> + </div> + + <div class="panel-footer"> + <button class="btn btn-danger btn-block" ng-click="deleteContactDetails()"> + <i class="fa fa-trash-o"></i> + Supprimer le moyen de contact + </button> + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsInfoCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsInfoCard.html new file mode 100644 index 0000000..6ff4a1d --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsInfoCard.html @@ -0,0 +1,33 @@ +<div class="panel panel-default"> + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Détails du moyen de contact</h3> + <div class="btn-group pull-right visible-xs"> + <a class="btn btn-primary" href="#/companies/{{company.wikittyId}}/contactDetails/{{contactDetails.wikittyId}}/edit"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <a class="btn btn-primary pull-right hidden-xs" href="#/companies/{{company.wikittyId}}/contactDetails/{{contactDetails.wikittyId}}/edit"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <div class="list-group"> + <div class="list-group-item"> + <i class="fa fa-2x fa-file-text-o pull-left"></i> + <label>Nom</label> + <h4 class="list-group-item-heading">{{contactDetails.name}}</h4> + </div> + <div class="list-group-item"> + <label>Type</label> + <h4 class="list-group-item-heading">{{contactDetails.type}}</h4> + </div> + <div class="list-group-item"> + <label>Valeur</label> + <h4 class="list-group-item-heading">{{contactDetails.value}}</h4> + </div> + </div> + <div class="panel-footer"> + <small class="pull-left"> </small> + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsListCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsListCard.html index 39b54b9..0263473 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsListCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsListCard.html @@ -2,26 +2,24 @@ <div class="panel-heading clearfix"> <h3 class="panel-title pull-left">Moyens de contact</h3> <div class="btn-group pull-right visible-xs"> - <a class="btn btn-primary" href="#" + <a class="btn btn-primary" href="#/companies/{{company.wikittyId}}/contactDetails/add" data-toggle="modal" data-target="#editModal"> - <i class="fa fa-pencil"></i> - <span>Edit</span> + <i class="fa fa-plus"></i> + <span>Ajouter</span> </a> </div> - <a class="btn btn-primary pull-right hidden-xs" href="#" - data-toggle="modal" - data-target="#editModal"> - <i class="fa fa-pencil"></i> - <span>Edit</span> + <a class="btn btn-primary pull-right hidden-xs" href="#/companies/{{company.wikittyId}}/contactDetails/add"> + <i class="fa fa-plus"></i> + <span>Ajouter</span> </a> </div> <div class="list-group"> - <div class="list-group-item" - ng-repeat="contact in contactDetails"> + <a class="list-group-item" ng-repeat="contact in contactDetails" + href="#/companies/{{company.wikittyId}}/contactDetails/{{contact.wikittyId}}"> <label>{{contact.type}} - {{contact.name}}</label> <h4 class="list-group-item-heading">{{contact.value}}</h4> - </div> + </a> </div> <div class="panel-footer"> <small class="pull-left"> </small> diff --git a/chorem-webmotion/src/main/webapp/js/crm.js b/chorem-webmotion/src/main/webapp/js/crm.js index ea67517..5d415b1 100644 --- a/chorem-webmotion/src/main/webapp/js/crm.js +++ b/chorem-webmotion/src/main/webapp/js/crm.js @@ -30,7 +30,19 @@ crmTest.config(['$routeProvider', when('/companies/:companyId/notes/:noteId/edit', { templateUrl:'partials/noteEditCard.html', - controller:'NoteEditController'}); + controller:'NoteEditController'}). + + when('/companies/:companyId/contactDetails/add', { + templateUrl:'partials/contactDetailsCreateCard.html', + controller:'ContactDetailsCreateController'}). + + when('/companies/:companyId/contactDetails/:contactDetailsId', { + templateUrl:'partials/contactDetailsInfoCard.html', + controller:'ContactDetailsDetailController'}). + + when('/companies/:companyId/contactDetails/:contactDetailsId/edit', { + templateUrl:'partials/contactDetailsEditCard.html', + controller:'ContactDetailsEditController'}); }]); //Should use heritage for next main list controllers @@ -305,3 +317,79 @@ crmTest.controller('NoteEditController', function ($scope, $http, $routeParams, } }); + +crmTest.controller('ContactDetailsCreateController', function ($scope, $http, $location, $route) { + + $scope.company = $scope.selectedItem; + + $scope.saveContactDetails = function(){ + $scope.contactDetails.target=$scope.company.wikittyId; + $http({ + method : 'PUT', + url : 'contactDetails/add', + data : $.param($scope.contactDetails), // pass in data as strings + headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) + }) + .success(function(data) { + $location.path('companies/'+data); + $route.reload(); + }); + }; + + $scope.cancel = function(){ + $location.path('companies/'); + $route.reload(); + } + +}); + +crmTest.controller('ContactDetailsDetailController', function ($scope, $http, $routeParams){ + + $scope.company=$scope.selectedItem; + + $http.get('contactDetails/'+$routeParams.contactDetailsId).success(function(data){ + $scope.contactDetails = data; + }); + +}); + +crmTest.controller('ContactDetailsEditController', function ($scope, $http, $routeParams, $location, $route) { + + //copy selectedItem to not modify the parent one + $scope.company=$scope.selectedItem; + + $http.get('contactDetails/'+$routeParams.contactDetailsId).success(function(data){ + $scope.contactDetails = data; + }); + + $scope.saveContactDetails = function(){ + + $http({ + method : 'POST', + url : 'contactDetails/'+$scope.contactDetails.wikittyId, + data : $.param($scope.contactDetails), // pass in data as strings + headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) + }) + .success(function(data) { + //then reload + $location.path('companies/'+$scope.selectedItem.wikittyId); + $route.reload(); + }); + }; + + $scope.cancel = function(){ + $location.path('companies/'+$scope.selectedItem.wikittyId); + $route.reload(); + } + + $scope.deleteContactDetails = function(){ + if(confirm('Are you sure you want to delete?')){ + $http.delete('contactDetails/'+$scope.contactDetails.wikittyId).success(function(data){ + + $location.path('companies'); + $route.reload(); + }); + } + } + +}); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/882-angular in repository chorem. See http://git.chorem.org/chorem.git commit 3cd452c834b5556332cef0d36a3d39e894082eee Author: kootox <jean.couteau@gmail.com> Date: Tue Mar 10 16:07:17 2015 +0100 refs #882 : Adds employees CRUD reusing notes and contact details card --- .../webmotion/actions/crm/EmployeeAction.java | 87 ++++++- .../chorem/webmotion/actions/crm/PersonAction.java | 38 +++ chorem-webmotion/src/main/resources/mapping | 13 +- .../main/webapp/WEB-INF/jsp/crm/angularTest.html | 8 + .../jsp/crm/partials/employeeCreateCard.html | 47 ++++ .../WEB-INF/jsp/crm/partials/employeeEditCard.html | 52 +++++ ...mployeesListCard.html => employeeInfoCard.html} | 20 +- .../WEB-INF/jsp/crm/partials/employeePanel.html | 8 + .../jsp/crm/partials/employeesListCard.html | 22 +- chorem-webmotion/src/main/webapp/js/crm.js | 258 +++++++++++++++++---- 10 files changed, 479 insertions(+), 74 deletions(-) diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/EmployeeAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/EmployeeAction.java index a9a04b1..cae0570 100644 --- a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/EmployeeAction.java +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/EmployeeAction.java @@ -2,8 +2,11 @@ package org.chorem.webmotion.actions.crm; import org.chorem.ChoremClient; import org.chorem.entities.Employee; +import org.chorem.entities.EmployeeImpl; +import org.chorem.entities.Note; import org.debux.webmotion.server.WebMotionController; import org.debux.webmotion.server.render.Render; +import org.debux.webmotion.server.render.RenderJson; import org.nuiton.wikitty.query.WikittyQuery; import org.nuiton.wikitty.query.WikittyQueryMaker; import org.nuiton.wikitty.query.WikittyQueryResult; @@ -16,7 +19,7 @@ import java.util.List; */ public class EmployeeAction extends WebMotionController{ - public Render listEmployees(ChoremClient client, String id) { + public Render listEmployeesForCompany(ChoremClient client, String id) { //recuperation des notes WikittyQuery employeesQuery = new WikittyQueryMaker().and() .exteq(Employee.EXT_EMPLOYEE) @@ -25,7 +28,7 @@ public class EmployeeAction extends WebMotionController{ WikittyQueryResult<String> employeesIds = client.findAllByQuery(employeesQuery); - List<Employee> employees = client.restore(Employee.class, employeesIds.getAll(),"Company.person"); + List<Employee> employees = client.restore(Employee.class, employeesIds.getAll(),"Employee.person", "Employee.company"); List<EmployeeDTO> employeeDTOs = new ArrayList<>(); @@ -35,4 +38,84 @@ public class EmployeeAction extends WebMotionController{ return renderJSON(employeeDTOs); } + + public Render listEmployeesForPerson(ChoremClient client, String id) { + //recuperation des notes + WikittyQuery employeesQuery = new WikittyQueryMaker().and() + .exteq(Employee.EXT_EMPLOYEE) + .eq(Employee.FQ_FIELD_EMPLOYEE_PERSON, id) + .end().setLimit(WikittyQuery.MAX); + + WikittyQueryResult<String> employeesIds = client.findAllByQuery(employeesQuery); + + List<Employee> employees = client.restore(Employee.class, employeesIds.getAll(),"Employee.person", "Employee.company"); + + List<EmployeeDTO> employeeDTOs = new ArrayList<>(); + + for (Employee employee:employees){ + employeeDTOs.add(new EmployeeDTO(employee)); + } + + return renderJSON(employeeDTOs); + } + + public Render getEmployee(ChoremClient client, String id) { + Employee employee = client.restore(Employee.class, id, "Employee.person", "Employee.company"); + + EmployeeDTO employeeDTO = new EmployeeDTO(employee); + + return renderJSON(employeeDTO); + } + + public Render updateEmployee(ChoremClient client, String id, EmployeeDTO dto) { + Employee employee = client.restore(Employee.class, id); + + if (dto.getPerson() != null) { + employee.setPerson(dto.getPerson().getWikittyId()); + } else { + employee.setPerson(dto.getPersonId()); + } + + if (dto.getCompany() != null){ + employee.setCompany(dto.getCompany().getWikittyId()); + } else { + employee.setCompany(dto.getCompanyId()); + } + + employee.setDescription(dto.getDescription()); + employee = client.store(employee); + + dto = new EmployeeDTO(employee); + + return renderJSON(dto); + } + + public Render createEmployee(ChoremClient client, EmployeeDTO dto) { + Employee employee = new EmployeeImpl(); + + if (dto.getPerson() != null) { + employee.setPerson(dto.getPerson().getWikittyId()); + } else { + employee.setPerson(dto.getPersonId()); + } + + if (dto.getCompany() != null){ + employee.setCompany(dto.getCompany().getWikittyId()); + } else { + employee.setCompany(dto.getCompanyId()); + } + + employee.setDescription(dto.getDescription()); + employee = client.store(employee); + + dto = new EmployeeDTO(employee); + + return renderJSON(dto); + } + + public Render deleteEmployee(ChoremClient client, String id) { + client.delete(id); + + return renderSuccess(); + } } diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/PersonAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/PersonAction.java new file mode 100644 index 0000000..b7547ec --- /dev/null +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/PersonAction.java @@ -0,0 +1,38 @@ +package org.chorem.webmotion.actions.crm; + +import org.chorem.ChoremClient; +import org.chorem.entities.Person; +import org.debux.webmotion.server.WebMotionController; +import org.debux.webmotion.server.render.Render; +import org.nuiton.wikitty.query.WikittyQuery; +import org.nuiton.wikitty.query.WikittyQueryMaker; +import org.nuiton.wikitty.query.WikittyQueryResult; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by couteau on 09/03/15. + */ +public class PersonAction extends WebMotionController { + + public Render listPersons(ChoremClient client) { + + //recuperation des persons + WikittyQuery personsQuery = new WikittyQueryMaker().and() + .exteq(Person.EXT_PERSON) + .end().setLimit(WikittyQuery.MAX); + + WikittyQueryResult<String> personsIds = client.findAllByQuery(personsQuery); + + List<Person> persons = client.restore(Person.class, personsIds.getAll()); + + List<PersonDTO> personDTOs = new ArrayList<>(); + + for (Person person : persons) { + personDTOs.add(new PersonDTO(person)); + } + + return renderJSON(personDTOs); + } +} diff --git a/chorem-webmotion/src/main/resources/mapping b/chorem-webmotion/src/main/resources/mapping index 00f0bd7..3746a97 100644 --- a/chorem-webmotion/src/main/resources/mapping +++ b/chorem-webmotion/src/main/resources/mapping @@ -102,19 +102,26 @@ POST /crm/companies/{id} action:crm.CompaniesAction.updateCompa PUT /crm/companies/add action:crm.CompaniesAction.createCompany DELETE /crm/companies/{id} action:crm.CompaniesAction.deleteCompany -GET /crm/companies/{id}/contactDetails action:crm.ContactDetailsAction.listContactDetails +GET /crm/contactDetails?target={id} action:crm.ContactDetailsAction.listContactDetails PUT /crm/contactDetails/add action:crm.ContactDetailsAction.createContactDetails POST /crm/contactDetails/{id} action:crm.ContactDetailsAction.updateContactDetails GET /crm/contactDetails/{id} action:crm.ContactDetailsAction.getContactDetails DELETE /crm/contactDetails/{id} action:crm.ContactDetailsAction.deleteContactDetails -GET /crm/companies/{id}/notes action:crm.NoteAction.listNotes +GET /crm/notes?target={id} action:crm.NoteAction.listNotes PUT /crm/notes/add action:crm.NoteAction.createNote POST /crm/notes/{id} action:crm.NoteAction.updateNote GET /crm/notes/{id} action:crm.NoteAction.getNote DELETE /crm/notes/{id} action:crm.NoteAction.deleteNote -GET /crm/companies/{id}/employees action:crm.EmployeeAction.listEmployees +GET /crm/employees?company={id} action:crm.EmployeeAction.listEmployeesForCompany +GET /crm/employees?person={id} action:crm.EmployeeAction.listEmployeesForPerson +PUT /crm/employees/add action:crm.EmployeeAction.createEmployee +GET /crm/employees/{id} action:crm.EmployeeAction.getEmployee +POST /crm/employees/{id} action:crm.EmployeeAction.updateEmployee +DELETE /crm/employees/{id} action:crm.EmployeeAction.deleteEmployee + +GET /crm/persons action:crm.PersonAction.listPersons GET /crm/partials/{page} view:crm/partials/{page} diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html index 4901e75..0b81234 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html @@ -8,10 +8,18 @@ <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-route.js"></script> + <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-sanitize.js"></script> + <script src="/chorem/js/crm.js"></script> <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="https://code.jquery.com/jquery-2.1.3.min.js"></script> + + <link href="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-select/0.10.0/select.css" rel="stylesheet" /> + <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-select/0.10.0/select.js"></script> + <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.5/select2.css"> + + </head> <body> diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeCreateCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeCreateCard.html new file mode 100644 index 0000000..f424af3 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeCreateCard.html @@ -0,0 +1,47 @@ +<div class="panel panel-default"> + + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Créer un salarié</h3> + <div class="btn-group pull-right"> + <button class="btn btn-danger" ng-click="cancel()"> + <i class="fa fa-times"></i> + Annuler + </button> + <button class="btn btn-success" ng-click="saveEmployee()"> + <i class="fa fa-check"></i> + Sauver + </button> + </div> + </div> + + <div class="modal-body"> + <form class="form-horizontal"> + <div class="form-group"> + <label class="col-xs-3 control-label">Nom</label> + <div class="col-xs-9"> + <ui-select ng-model="employee.person" theme="select2" class="col-xs-9"> + <ui-select-match placeholder="Select a person in the list or search his name...">{{$select.selected.firstName}} {{$select.selected.lastName}}</ui-select-match> + <ui-select-choices repeat="person in persons | propsFilter: {firstName: $select.search, lastName: $select.search}"> + <span ng-bind-html="''+person.firstName | highlight: $select.search"></span> + <span ng-bind-html="''+person.lastName | highlight: $select.search"></span> + </ui-select-choices> + </ui-select> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Description</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="employee.description"> + </div> + </div> + + </form> + </div> + + <div class="panel-footer"> + </div> +</div> + + + diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeEditCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeEditCard.html new file mode 100644 index 0000000..9dfe317 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeEditCard.html @@ -0,0 +1,52 @@ +<div class="panel panel-default"> + + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Éditer un salarié</h3> + <div class="btn-group pull-right"> + <button class="btn btn-danger" ng-click="cancel()"> + <i class="fa fa-times"></i> + Annuler + </button> + <button class="btn btn-success" ng-click="saveEmployee()"> + <i class="fa fa-check"></i> + Sauver + </button> + </div> + </div> + + <div class="modal-body"> + <form class="form-horizontal"> + <div class="form-group"> + <label class="col-xs-3 control-label">Nom</label> + <div class="col-xs-9"> + <ui-select ng-model="employee.person" theme="select2" class="col-xs-9"> + <ui-select-match placeholder="Select a person in the list or search his name...">{{$select.selected.firstName}} {{$select.selected.lastName}}</ui-select-match> + <ui-select-choices repeat="person in persons | propsFilter: {firstName: $select.search, lastName: $select.search}" + value="{{$select.selected.wikittyId}}"> + <span ng-bind-html="''+person.firstName | highlight: $select.search"></span> + <span ng-bind-html="''+person.lastName | highlight: $select.search"></span> + </ui-select-choices> + </ui-select> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Description</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="employee.description"> + </div> + </div> + + </form> + </div> + + <div class="panel-footer"> + <button class="btn btn-danger btn-block" ng-click="deleteEmployee()"> + <i class="fa fa-trash-o"></i> + Supprimer le salarié + </button> + </div> +</div> + + + diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeInfoCard.html similarity index 51% copy from chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html copy to chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeInfoCard.html index 6a0bc09..d3cc23e 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeInfoCard.html @@ -1,27 +1,27 @@ <div class="panel panel-default"> <div class="panel-heading clearfix"> - <h3 class="panel-title pull-left">Employés</h3> + <h3 class="panel-title pull-left">Détails du salarié</h3> <div class="btn-group pull-right visible-xs"> - <a class="btn btn-primary" href="#" - data-toggle="modal" - data-target="#editModal"> + <a class="btn btn-primary" href="#"> <i class="fa fa-pencil"></i> <span>Edit</span> </a> </div> - <a class="btn btn-primary pull-right hidden-xs" href="#" - data-toggle="modal" - data-target="#editModal"> + <a class="btn btn-primary pull-right hidden-xs" href="#/companies/{{company.wikittyId}}/employees/{{employee.wikittyId}}/edit"> <i class="fa fa-pencil"></i> <span>Edit</span> </a> </div> <div class="list-group"> - <div class="list-group-item" - ng-repeat="employee in employees"> - <label>{{note.date}}</label> + <div class="list-group-item"> + <i class="fa fa-2x fa-file-text-o pull-left"></i> + <label>Personne</label> <h4 class="list-group-item-heading">{{employee.person.firstName}} {{employee.person.lastName}}</h4> </div> + <div class="list-group-item"> + <label>Description</label> + <h4 class="list-group-item-heading">{{employee.description}}</h4> + </div> </div> <div class="panel-footer"> <small class="pull-left"> </small> diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeePanel.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeePanel.html new file mode 100644 index 0000000..a98ac70 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeePanel.html @@ -0,0 +1,8 @@ +<!-- employee info card --> +<ng-include src="'partials/employeeInfoCard.html'"></ng-include> + +<!-- contact details card --> +<ng-include src="'partials/contactDetailsListCard.html'"></ng-include> + +<!-- notes card --> +<ng-include src="'partials/notesListCard.html'"></ng-include> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html index 6a0bc09..eb2f840 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html @@ -2,26 +2,20 @@ <div class="panel-heading clearfix"> <h3 class="panel-title pull-left">Employés</h3> <div class="btn-group pull-right visible-xs"> - <a class="btn btn-primary" href="#" - data-toggle="modal" - data-target="#editModal"> - <i class="fa fa-pencil"></i> - <span>Edit</span> + <a class="btn btn-primary" href="#/companies/{{company.wikittyId}}/employees/add"> + <i class="fa fa-plus"></i><span>Ajouter</span> </a> </div> - <a class="btn btn-primary pull-right hidden-xs" href="#" - data-toggle="modal" - data-target="#editModal"> - <i class="fa fa-pencil"></i> - <span>Edit</span> + <a class="btn btn-primary pull-right hidden-xs" href="#/companies/{{company.wikittyId}}/employees/add"> + <i class="fa fa-plus"></i><span>Ajouter</span> </a> </div> <div class="list-group"> - <div class="list-group-item" - ng-repeat="employee in employees"> - <label>{{note.date}}</label> + <a class="list-group-item" ng-repeat="employee in employees" + href="#/companies/{{company.wikittyId}}/employees/{{employee.wikittyId}}"> + <label>{{employee.description}}</label> <h4 class="list-group-item-heading">{{employee.person.firstName}} {{employee.person.lastName}}</h4> - </div> + </a> </div> <div class="panel-footer"> <small class="pull-left"> </small> diff --git a/chorem-webmotion/src/main/webapp/js/crm.js b/chorem-webmotion/src/main/webapp/js/crm.js index 5d415b1..0859bc2 100644 --- a/chorem-webmotion/src/main/webapp/js/crm.js +++ b/chorem-webmotion/src/main/webapp/js/crm.js @@ -1,4 +1,4 @@ -var crmTest = angular.module('crmTest', ['ngRoute']); +var crmTest = angular.module('crmTest', ['ngRoute','ui.select','ngSanitize']); crmTest.config(['$routeProvider', function($routeProvider){ @@ -42,9 +42,53 @@ crmTest.config(['$routeProvider', when('/companies/:companyId/contactDetails/:contactDetailsId/edit', { templateUrl:'partials/contactDetailsEditCard.html', - controller:'ContactDetailsEditController'}); + controller:'ContactDetailsEditController'}). + + when('/companies/:companyId/employees/add', { + templateUrl:'partials/employeeCreateCard.html', + controller:'EmployeeCreateController'}). + + when('/companies/:companyId/employees/:employeeId', { + templateUrl:'partials/employeePanel.html', + controller:'EmployeeDetailController'}). + + when('/companies/:companyId/employees/:employeeId/edit', { + templateUrl:'partials/employeeEditCard.html', + controller:'EmployeeEditController'}); }]); +/**For select 2 filtering -> OR between search terms instead of AND**/ +crmTest.filter('propsFilter', function() { + return function(items, props) { + var out = []; + + if (angular.isArray(items)) { + items.forEach(function(item) { + var itemMatches = false; + + var keys = Object.keys(props); + for (var i = 0; i < keys.length; i++) { + var prop = keys[i]; + var text = props[prop].toLowerCase(); + if (item[prop].toString().toLowerCase().indexOf(text) !== -1) { + itemMatches = true; + break; + } + } + + if (itemMatches) { + out.push(item); + } + }); + } else { + // Let the output be the input untouched + out = items; + } + + return out; + } +}); + //Should use heritage for next main list controllers crmTest.controller('CompanyListController', function ($scope, $http, $location, $route, $routeParams) { @@ -56,6 +100,12 @@ crmTest.controller('CompanyListController', function ($scope, $http, $location, $scope.selectedItem=$scope.items[0]; + $scope.targetId=""; + + $scope.setTargetId=function(targetId){ + $scope.targetId=targetId; + } + $scope.selectItem=function(selectedCompany){ $scope.selectedItem = selectedCompany; }; @@ -135,10 +185,12 @@ crmTest.controller('CompanyDetailController', function ($scope, $http, $routePar $scope.company=$scope.selectedItem; + $scope.setTargetId($scope.selectedItem.wikittyId); + //get back contact details for the company $scope.updateContactDetails=function(){ if ($scope.company){ - $http.get('companies/'+$scope.company.wikittyId+"/contactDetails").success(function(data){ + $http.get('contactDetails?target='+$scope.company.wikittyId).success(function(data){ $scope.contactDetails = data; }); } @@ -147,7 +199,7 @@ crmTest.controller('CompanyDetailController', function ($scope, $http, $routePar //get back notes for the company $scope.updateNotes=function(){ if ($scope.company){ - $http.get('companies/'+$scope.company.wikittyId+"/notes").success(function(data){ + $http.get('notes?target='+$scope.company.wikittyId).success(function(data){ $scope.notes = data; }); } @@ -156,7 +208,7 @@ crmTest.controller('CompanyDetailController', function ($scope, $http, $routePar //get back employees for the company $scope.updateEmployees=function(){ if ($scope.company){ - $http.get('companies/'+$scope.company.wikittyId+"/employees").success(function(data){ + $http.get('employees?company='+$scope.company.wikittyId).success(function(data){ $scope.employees = data; }); } @@ -168,7 +220,7 @@ crmTest.controller('CompanyDetailController', function ($scope, $http, $routePar }); -crmTest.controller('CompanyEditController', function ($scope, $http, $routeParams, $location, $route) { +crmTest.controller('CompanyEditController', function ($scope, $http, $routeParams, $window) { //copy selectedItem to not modify the parent one $scope.company=$scope.selectedItem; @@ -188,14 +240,12 @@ crmTest.controller('CompanyEditController', function ($scope, $http, $routeParam $scope.$parent.selectedCompany=data; //then reload - $location.path('companies/'+$scope.selectedItem.wikittyId); - $route.reload(); + $window.history.back(); }); }; $scope.cancel = function(){ - $location.path('companies/'+$scope.selectedItem.wikittyId); - $route.reload(); + $window.history.back(); } $scope.deleteCompany = function(){ @@ -205,15 +255,15 @@ crmTest.controller('CompanyEditController', function ($scope, $http, $routeParam $scope.deleteItem($scope.selectedItem); $scope.$parent.selectedItem=''; - $location.path('companies'); - $route.reload(); + $window.history.back(); + $window.history.back(); }); } } }); -crmTest.controller('CompanyCreateController', function ($scope, $http, $location, $route) { +crmTest.controller('CompanyCreateController', function ($scope, $http, $window) { $scope.saveCompany = function(){ $http({ @@ -228,26 +278,24 @@ crmTest.controller('CompanyCreateController', function ($scope, $http, $location $scope.addItem(data); $scope.$parent.selectedItem=data; - $location.path('companies/'+data); - $route.reload(); + $window.history.back(); }); }; $scope.cancel = function(){ - $location.path('companies/'); - $route.reload(); + $window.history.back(); } }); -crmTest.controller('NoteCreateController', function ($scope, $http, $location, $route) { +crmTest.controller('NoteCreateController', function ($scope, $http, $window) { $scope.company = $scope.selectedItem; //$scope.note.target = $scope.company.wikittyId; $scope.saveNote = function(){ - $scope.note.target=$scope.company.wikittyId; + $scope.note.target=$scope.targetId; $http({ method : 'PUT', url : 'notes/add', @@ -255,14 +303,12 @@ crmTest.controller('NoteCreateController', function ($scope, $http, $location, $ headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) }) .success(function(data) { - $location.path('companies/'+data); - $route.reload(); + $window.history.back(); }); }; $scope.cancel = function(){ - $location.path('companies/'); - $route.reload(); + $window.history.back(); } }); @@ -277,7 +323,7 @@ crmTest.controller('NoteDetailController', function ($scope, $http, $routeParams }); -crmTest.controller('NoteEditController', function ($scope, $http, $routeParams, $location, $route) { +crmTest.controller('NoteEditController', function ($scope, $http, $routeParams, $window) { //copy selectedItem to not modify the parent one $scope.company=$scope.selectedItem; @@ -295,35 +341,32 @@ crmTest.controller('NoteEditController', function ($scope, $http, $routeParams, headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) }) .success(function(data) { - //then reload - $location.path('companies/'+$scope.selectedItem.wikittyId); - $route.reload(); + $window.history.back(); }); }; $scope.cancel = function(){ - $location.path('companies/'+$scope.selectedItem.wikittyId); - $route.reload(); + $window.history.back(); } $scope.deleteNote = function(){ if(confirm('Are you sure you want to delete?')){ $http.delete('notes/'+$scope.note.wikittyId).success(function(data){ - $location.path('companies'); - $route.reload(); + $window.history.back(); + $window.history.back(); }); } } }); -crmTest.controller('ContactDetailsCreateController', function ($scope, $http, $location, $route) { +crmTest.controller('ContactDetailsCreateController', function ($scope, $http, $window) { $scope.company = $scope.selectedItem; $scope.saveContactDetails = function(){ - $scope.contactDetails.target=$scope.company.wikittyId; + $scope.contactDetails.target=$scope.targetId; $http({ method : 'PUT', url : 'contactDetails/add', @@ -331,14 +374,12 @@ crmTest.controller('ContactDetailsCreateController', function ($scope, $http, $l headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) }) .success(function(data) { - $location.path('companies/'+data); - $route.reload(); + $window.history.back(); }); }; $scope.cancel = function(){ - $location.path('companies/'); - $route.reload(); + $window.history.back(); } }); @@ -353,7 +394,7 @@ crmTest.controller('ContactDetailsDetailController', function ($scope, $http, $r }); -crmTest.controller('ContactDetailsEditController', function ($scope, $http, $routeParams, $location, $route) { +crmTest.controller('ContactDetailsEditController', function ($scope, $http, $routeParams, $window) { //copy selectedItem to not modify the parent one $scope.company=$scope.selectedItem; @@ -371,25 +412,152 @@ crmTest.controller('ContactDetailsEditController', function ($scope, $http, $rou headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) }) .success(function(data) { - //then reload - $location.path('companies/'+$scope.selectedItem.wikittyId); - $route.reload(); + $window.history.back(); }); }; $scope.cancel = function(){ - $location.path('companies/'+$scope.selectedItem.wikittyId); - $route.reload(); + $window.history.back(); } $scope.deleteContactDetails = function(){ if(confirm('Are you sure you want to delete?')){ $http.delete('contactDetails/'+$scope.contactDetails.wikittyId).success(function(data){ - $location.path('companies'); - $route.reload(); + $window.history.back(); + $window.history.back(); + }); + } + } + +}); + +crmTest.controller('EmployeeDetailController', function ($scope, $http, $routeParams){ + + $scope.company=$scope.selectedItem; + + $scope.setTargetId($routeParams.employeeId); + + $http.get('employees/'+$routeParams.employeeId).success(function(data){ + $scope.employee = data; + }); + + //get back contact details for the employee + $scope.updateContactDetails=function(){ + if ($scope.company){ + $http.get('contactDetails?target='+$routeParams.employeeId).success(function(data){ + $scope.contactDetails = data; + }); + } + }; + + //get back notes for the employee + $scope.updateNotes=function(){ + if ($scope.company){ + $http.get('notes?target='+$routeParams.employeeId).success(function(data){ + $scope.notes = data; + }); + } + }; + + $scope.updateContactDetails(); + $scope.updateNotes(); + +}); + +crmTest.controller('EmployeeEditController', function ($scope, $http, $routeParams, $window) { + + //copy selectedItem to not modify the parent one + $scope.company=$scope.selectedItem; + + $scope.updateSelect2Values = function(){ + if($scope.persons && $scope.employee){ + for(index in $scope.persons){ + var person = $scope.persons[index]; + if (person.wikittyId===$scope.employee.personId){ + $scope.person=person; + } + } + } + }; + + $http.get('employees/'+$routeParams.employeeId).success(function(data){ + $scope.employee = data; + $scope.updateSelect2Values(); + }); + + //get all companies + $http.get('companies').success(function(data){ + $scope.companies = data; + }); + + //get all persons + $http.get('persons').success(function(data){ + $scope.persons = data; + $scope.updateSelect2Values(); + }); + + $scope.saveEmployee = function(){ + + $http({ + method : 'POST', + url : 'employees/'+$scope.employee.wikittyId, + data : $.param($scope.employee), // pass in data as strings + headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) + }) + .success(function(data) { + $window.history.back(); + }); + }; + + $scope.cancel = function(){ + $window.history.back(); + } + + $scope.deleteEmployee = function(){ + if(confirm('Are you sure you want to delete?')){ + $http.delete('employees/'+$scope.employee.wikittyId).success(function(data){ + + $window.history.back(); + $window.history.back(); }); } } }); + +crmTest.controller('EmployeeCreateController', function ($scope, $http, $window) { + + $scope.company = $scope.selectedItem; + + $scope.employee={}; + + //get all companies + $http.get('companies').success(function(data){ + $scope.companies = data; + }); + + //get all persons + $http.get('persons').success(function(data){ + $scope.persons = data; + }); + + $scope.saveEmployee = function(){ + + $scope.employee.company = $scope.company; + + $http({ + method : 'PUT', + url : 'employees/add', + data : $.param($scope.employee), // pass in data as strings + headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) + }) + .success(function(data) { + $window.history.back(); + }); + }; + + $scope.cancel = function(){ + $window.history.back(); + } +}); \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/882-angular in repository chorem. See http://git.chorem.org/chorem.git commit a5f63dcaecb0f1334ef6b907990da330e1a681b7 Author: kootox <jean.couteau@gmail.com> Date: Tue Mar 10 16:43:59 2015 +0100 refs #882 : Remove useless footers --- .../src/main/webapp/WEB-INF/jsp/crm/partials/companyCreateCard.html | 4 ---- .../src/main/webapp/WEB-INF/jsp/crm/partials/companyEditCard.html | 6 +----- .../src/main/webapp/WEB-INF/jsp/crm/partials/companyInfoCard.html | 3 --- .../webapp/WEB-INF/jsp/crm/partials/contactDetailsCreateCard.html | 4 ---- .../webapp/WEB-INF/jsp/crm/partials/contactDetailsInfoCard.html | 3 --- .../webapp/WEB-INF/jsp/crm/partials/contactDetailsListCard.html | 3 --- .../main/webapp/WEB-INF/jsp/crm/partials/employeeCreateCard.html | 3 --- .../src/main/webapp/WEB-INF/jsp/crm/partials/employeeInfoCard.html | 3 --- .../src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html | 3 --- .../src/main/webapp/WEB-INF/jsp/crm/partials/noteCreateCard.html | 4 ---- .../src/main/webapp/WEB-INF/jsp/crm/partials/noteDetailCard.html | 3 --- .../src/main/webapp/WEB-INF/jsp/crm/partials/notesListCard.html | 3 --- 12 files changed, 1 insertion(+), 41 deletions(-) diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyCreateCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyCreateCard.html index f384092..48d8c39 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyCreateCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyCreateCard.html @@ -36,8 +36,4 @@ <div class="modal-footer"> </div> - - <div class="panel-footer"> - - </div> </div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyEditCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyEditCard.html index 74ff087..c4083ef 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyEditCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyEditCard.html @@ -33,14 +33,10 @@ </form> </div> - <div class="modal-footer"> + <div class="panel-footer"> <button class="btn btn-danger btn-block" ng-click="deleteCompany()"> <i class="fa fa-trash-o"></i> Supprimer la société </button> </div> - - <div class="panel-footer"> - - </div> </div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyInfoCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyInfoCard.html index e6bc455..055ee4b 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyInfoCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyInfoCard.html @@ -23,7 +23,4 @@ <h4 class="list-group-item-heading">{{company.type}}</h4> </div> </div> - <div class="panel-footer"> - <small class="pull-left"> </small> - </div> </div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsCreateCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsCreateCard.html index 76cf883..ed75d7c 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsCreateCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsCreateCard.html @@ -40,8 +40,4 @@ </form> </div> - - <div class="panel-footer"> - - </div> </div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsInfoCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsInfoCard.html index 6ff4a1d..0e107b8 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsInfoCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsInfoCard.html @@ -27,7 +27,4 @@ <h4 class="list-group-item-heading">{{contactDetails.value}}</h4> </div> </div> - <div class="panel-footer"> - <small class="pull-left"> </small> - </div> </div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsListCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsListCard.html index 0263473..7fb412a 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsListCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/contactDetailsListCard.html @@ -21,7 +21,4 @@ <h4 class="list-group-item-heading">{{contact.value}}</h4> </a> </div> - <div class="panel-footer"> - <small class="pull-left"> </small> - </div> </div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeCreateCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeCreateCard.html index f424af3..3191ad0 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeCreateCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeCreateCard.html @@ -38,9 +38,6 @@ </form> </div> - - <div class="panel-footer"> - </div> </div> diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeInfoCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeInfoCard.html index d3cc23e..c864d60 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeInfoCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeeInfoCard.html @@ -23,7 +23,4 @@ <h4 class="list-group-item-heading">{{employee.description}}</h4> </div> </div> - <div class="panel-footer"> - <small class="pull-left"> </small> - </div> </div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html index eb2f840..4439360 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/employeesListCard.html @@ -17,7 +17,4 @@ <h4 class="list-group-item-heading">{{employee.person.firstName}} {{employee.person.lastName}}</h4> </a> </div> - <div class="panel-footer"> - <small class="pull-left"> </small> - </div> </div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteCreateCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteCreateCard.html index dc1dd95..6574b41 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteCreateCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteCreateCard.html @@ -40,8 +40,4 @@ </form> </div> - - <div class="panel-footer"> - - </div> </div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteDetailCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteDetailCard.html index 538e79e..68f796a 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteDetailCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/noteDetailCard.html @@ -27,7 +27,4 @@ <h4 class="list-group-item-heading">{{note.content}}</h4> </div> </div> - <div class="panel-footer"> - <small class="pull-left"> </small> - </div> </div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/notesListCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/notesListCard.html index a89bd60..81c3653 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/notesListCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/notesListCard.html @@ -18,7 +18,4 @@ <label>{{note.date | date : dd/MM/yyy}}</label> </a> </div> - <div class="panel-footer"> - <small class="pull-left"> </small> - </div> </div> \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/882-angular in repository chorem. See http://git.chorem.org/chorem.git commit a258442dae7587b56c50d91aa9a7f2a2c57db361 Author: kootox <jean.couteau@gmail.com> Date: Wed Mar 11 16:17:35 2015 +0100 refs #882 : deal with invoices on companies --- .../webmotion/actions/crm/CategoryAction.java | 36 ++++ .../chorem/webmotion/actions/crm/CategoryDTO.java | 55 ++++++ .../webmotion/actions/crm/InvoiceAction.java | 126 +++++++++++++ .../chorem/webmotion/actions/crm/InvoiceDTO.java | 198 +++++++++++++++++++++ chorem-webmotion/src/main/resources/mapping | 8 + .../WEB-INF/jsp/crm/partials/companyPanel.html | 5 +- .../jsp/crm/partials/invoiceCreateCard.html | 99 +++++++++++ .../jsp/crm/partials/invoiceDetailCard.html | 58 ++++++ .../WEB-INF/jsp/crm/partials/invoiceEditCard.html | 106 +++++++++++ .../WEB-INF/jsp/crm/partials/invoicesListCard.html | 21 +++ chorem-webmotion/src/main/webapp/js/crm.js | 127 ++++++++++++- 11 files changed, 830 insertions(+), 9 deletions(-) diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CategoryAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CategoryAction.java new file mode 100644 index 0000000..5e752b6 --- /dev/null +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CategoryAction.java @@ -0,0 +1,36 @@ +package org.chorem.webmotion.actions.crm; + +import org.chorem.ChoremClient; +import org.chorem.entities.Category; +import org.debux.webmotion.server.WebMotionController; +import org.debux.webmotion.server.render.Render; +import org.nuiton.wikitty.query.WikittyQuery; +import org.nuiton.wikitty.query.WikittyQueryMaker; +import org.nuiton.wikitty.query.WikittyQueryResult; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by couteau on 11/03/15. + */ +public class CategoryAction extends WebMotionController { + + public Render listCategories(ChoremClient client){ + WikittyQuery categoriesQuery = new WikittyQueryMaker().and() + .exteq(Category.EXT_CATEGORY) + .end().setLimit(WikittyQuery.MAX); + + WikittyQueryResult<String> categoriesId = client.findAllByQuery(categoriesQuery); + + List<Category> categories = client.restore(Category.class, categoriesId.getAll()); + + List<CategoryDTO> categoryDTOs = new ArrayList<>(); + + for (Category category:categories){ + categoryDTOs.add(new CategoryDTO(category)); + } + + return renderJSON(categoryDTOs); + } +} diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CategoryDTO.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CategoryDTO.java new file mode 100644 index 0000000..ee1202d --- /dev/null +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/CategoryDTO.java @@ -0,0 +1,55 @@ +package org.chorem.webmotion.actions.crm; + +import org.chorem.entities.Category; + +/** + * Created by couteau on 11/03/15. + */ +public class CategoryDTO { + + protected String wikittyId; + protected String name; + protected String parent; + protected int index; + + public String getWikittyId() { + return wikittyId; + } + + public void setWikittyId(String wikittyId) { + this.wikittyId = wikittyId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getParent() { + return parent; + } + + public void setParent(String parent) { + this.parent = parent; + } + + public int getIndex() { + return index; + } + + public void setIndex(int index) { + this.index = index; + } + + public CategoryDTO(){} + + public CategoryDTO(Category category){ + this.wikittyId = category.getWikittyId(); + this.name = category.getName(); + this.parent = category.getParent(); + this.index = category.getIndex(); + } +} diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/InvoiceAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/InvoiceAction.java new file mode 100644 index 0000000..b357f34 --- /dev/null +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/InvoiceAction.java @@ -0,0 +1,126 @@ +package org.chorem.webmotion.actions.crm; + +import org.chorem.ChoremClient; +import org.chorem.entities.Invoice; +import org.chorem.entities.InvoiceImpl; +import org.debux.webmotion.server.WebMotionController; +import org.debux.webmotion.server.render.Render; +import org.nuiton.wikitty.query.WikittyQuery; +import org.nuiton.wikitty.query.WikittyQueryMaker; +import org.nuiton.wikitty.query.WikittyQueryResult; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by couteau on 11/03/15. + */ +public class InvoiceAction extends WebMotionController { + + public Render listInvoicesForPayer(ChoremClient client, String payer){ + + WikittyQuery invoicesQuery = new WikittyQueryMaker().and() + .exteq(Invoice.EXT_INVOICE) + .eq(Invoice.FQ_FIELD_FINANCIALTRANSACTION_PAYER, payer) + .end().setLimit(WikittyQuery.MAX); + + WikittyQueryResult<String> invoicesId = client.findAllByQuery(invoicesQuery); + + List<Invoice> invoices = client.restore(Invoice.class, invoicesId.getAll(), + "FinancialTransaction.payer", + "FinancialTransaction.beneficiary", + "FinancialTransaction.category"); + + List<InvoiceDTO> invoiceDTOs = new ArrayList<>(); + + for (Invoice invoice:invoices){ + invoiceDTOs.add(new InvoiceDTO(invoice, client)); + } + + return renderJSON(invoiceDTOs); + } + + public Render getInvoice(ChoremClient client, String id) { + Invoice invoice = client.restore(Invoice.class, id, + "FinancialTransaction.payer", + "FinancialTransaction.beneficiary", + "FinancialTransaction.category"); + + InvoiceDTO dto = new InvoiceDTO(invoice, client); + + return renderJSON(dto); + + } + + public Render createInvoice(ChoremClient client, InvoiceDTO dto){ + + Invoice invoice = new InvoiceImpl(); + + invoice.setStatus(dto.getStatus()); + invoice.setAmount(dto.getAmount()); + invoice.setDescription(dto.getDescription()); + invoice.setPaymentDate(dto.getPaymentDate()); + invoice.setEmittedDate(dto.getEmittedDate()); + invoice.setExpectedDate(dto.getExpectedDate()); + invoice.setReference(dto.getReference()); + invoice.setVAT(dto.getVat()); + + if(dto.getCategory() != null) { + invoice.setCategory(dto.getCategory().getWikittyId()); + } else { + invoice.setCategory(dto.getCategoryId()); + } + + if(dto.getPayer() != null) { + invoice.setPayer(dto.getPayer().getWikittyId()); + } else { + invoice.setPayer(dto.getPayerId()); + } + + invoice = client.store(invoice); + + dto = new InvoiceDTO(invoice, client); + + return renderJSON(dto); + + } + + public Render updateInvoice(ChoremClient client, String id, InvoiceDTO dto){ + + Invoice invoice = client.restore(Invoice.class, id); + + invoice.setStatus(dto.getStatus()); + invoice.setAmount(dto.getAmount()); + invoice.setDescription(dto.getDescription()); + invoice.setPaymentDate(dto.getPaymentDate()); + invoice.setEmittedDate(dto.getEmittedDate()); + invoice.setExpectedDate(dto.getExpectedDate()); + invoice.setReference(dto.getReference()); + invoice.setVAT(dto.getVat()); + + if(dto.getCategory() != null) { + invoice.setCategory(dto.getCategory().getWikittyId()); + } else { + invoice.setCategory(dto.getCategoryId()); + } + + if(dto.getPayer() != null) { + invoice.setPayer(dto.getPayer().getWikittyId()); + } else { + invoice.setPayer(dto.getPayerId()); + } + + invoice = client.store(invoice); + + dto = new InvoiceDTO(invoice, client); + + return renderJSON(dto); + + } + + public Render deleteInvoice(ChoremClient client, String id) { + client.delete(id); + + return renderSuccess(); + } +} diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/InvoiceDTO.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/InvoiceDTO.java new file mode 100644 index 0000000..1a1262a --- /dev/null +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/InvoiceDTO.java @@ -0,0 +1,198 @@ +package org.chorem.webmotion.actions.crm; + +import org.chorem.ChoremClient; +import org.chorem.entities.Category; +import org.chorem.entities.Company; +import org.chorem.entities.CompanyImpl; +import org.chorem.entities.Invoice; + +import java.util.Date; + +/** + * Created by couteau on 10/03/15. + */ +public class InvoiceDTO { + + protected String reference; + protected String description; + protected double amount; + protected double vat; + protected Date emittedDate; + protected Date expectedDate; + protected Date paymentDate; + protected String payerId; + protected CompanyDTO payer; + protected String beneficiaryId; + protected CompanyDTO beneficiary; + protected String target; + protected String categoryId; + protected CategoryDTO category; + protected String status; + protected String wikittyId; + + public String getReference() { + return reference; + } + + public void setReference(String reference) { + this.reference = reference; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public double getAmount() { + return amount; + } + + public void setAmount(double amount) { + this.amount = amount; + } + + public double getVat() { + return vat; + } + + public void setVat(double vat) { + this.vat = vat; + } + + public Date getEmittedDate() { + return emittedDate; + } + + public void setEmittedDate(Date emittedDate) { + this.emittedDate = emittedDate; + } + + public Date getExpectedDate() { + return expectedDate; + } + + public void setExpectedDate(Date expectedDate) { + this.expectedDate = expectedDate; + } + + public Date getPaymentDate() { + return paymentDate; + } + + public void setPaymentDate(Date paymentDate) { + this.paymentDate = paymentDate; + } + + public String getPayerId() { + return payerId; + } + + public void setPayerId(String payerId) { + this.payerId = payerId; + } + + public CompanyDTO getPayer() { + return payer; + } + + public void setPayer(CompanyDTO payer) { + this.payer = payer; + } + + public String getBeneficiaryId() { + return beneficiaryId; + } + + public void setBeneficiaryId(String beneficiaryId) { + this.beneficiaryId = beneficiaryId; + } + + public CompanyDTO getBeneficiary() { + return beneficiary; + } + + public void setBeneficiary(CompanyDTO beneficiary) { + this.beneficiary = beneficiary; + } + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + public String getCategoryId() { + return categoryId; + } + + public void setCategoryId(String categoryId) { + this.categoryId = categoryId; + } + + public CategoryDTO getCategory() { + return category; + } + + public void setCategory(CategoryDTO category) { + this.category = category; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getWikittyId() { + return wikittyId; + } + + public void setWikittyId(String wikittyId) { + this.wikittyId = wikittyId; + } + + public InvoiceDTO(){} + + public InvoiceDTO(Invoice invoice, ChoremClient client){ + + this.reference = invoice.getReference(); + this.description = invoice.getDescription(); + this.amount = invoice.getAmount(); + this.vat = invoice.getVAT(); + this.emittedDate = invoice.getEmittedDate(); + this.expectedDate = invoice.getExpectedDate(); + this.paymentDate = invoice.getPaymentDate(); + this.payerId = invoice.getPayer(); + this.beneficiaryId = invoice.getBeneficiary(); + + Company company = client.restore(Company.class, invoice.getBeneficiary(), true); + + if (company != null) { + this.beneficiary = new CompanyDTO(company); + } + + company = client.restore(Company.class, invoice.getPayer(), true); + if (company != null) { + this.payer = new CompanyDTO(company); + } + + this.target = invoice.getTarget(); + this.categoryId = invoice.getCategory(); + + Category category = invoice.getCategory(false); + if (category != null) { + this.category = new CategoryDTO(category); + } + + this.status = invoice.getStatus(); + this.wikittyId = invoice.getWikittyId(); + + } +} diff --git a/chorem-webmotion/src/main/resources/mapping b/chorem-webmotion/src/main/resources/mapping index 3746a97..5e31957 100644 --- a/chorem-webmotion/src/main/resources/mapping +++ b/chorem-webmotion/src/main/resources/mapping @@ -121,6 +121,14 @@ GET /crm/employees/{id} action:crm.EmployeeAction.getEmployee POST /crm/employees/{id} action:crm.EmployeeAction.updateEmployee DELETE /crm/employees/{id} action:crm.EmployeeAction.deleteEmployee +GET /crm/invoices?payer={id} action:crm.InvoiceAction.listInvoicesForPayer +GET /crm/invoices/{id} action:crm.InvoiceAction.getInvoice +PUT /crm/invoices/add action:crm.InvoiceAction.createInvoice +POST /crm/invoices/{id} action:crm.InvoiceAction.updateInvoice +DELETE /crm/invoices/{id} action:crm.InvoiceAction.deleteInvoice + +GET /crm/categories action:crm.CategoryAction.listCategories + GET /crm/persons action:crm.PersonAction.listPersons GET /crm/partials/{page} view:crm/partials/{page} diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyPanel.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyPanel.html index bcf7732..c539ac1 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyPanel.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/companyPanel.html @@ -8,4 +8,7 @@ <ng-include src="'partials/notesListCard.html'"></ng-include> <!--employees card --> -<ng-include src="'partials/employeesListCard.html'"></ng-include> \ No newline at end of file +<ng-include src="'partials/employeesListCard.html'"></ng-include> + +<!--invoices card--> +<ng-include src="'partials/invoicesListCard.html'"></ng-include> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceCreateCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceCreateCard.html new file mode 100644 index 0000000..2475e54 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceCreateCard.html @@ -0,0 +1,99 @@ +<div class="panel panel-default"> + + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Créer une facture</h3> + <div class="btn-group pull-right"> + <button class="btn btn-danger" ng-click="cancel()"> + <i class="fa fa-times"></i> + Annuler + </button> + <button class="btn btn-success" ng-click="save()"> + <i class="fa fa-check"></i> + Sauver + </button> + </div> + </div> + + <div class="modal-body"> + <form class="form-horizontal"> + + <div class="form-group"> + <label class="col-xs-3 control-label">Référence</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="invoice.reference"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Montant</label> + <div class="col-xs-9"> + <div class="input-group"> + <input type="number" class="form-control" ng-model="invoice.amount"> + <span class="input-group-addon">€</span> + </div> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">TVA</label> + <div class="col-xs-9"> + <div class="input-group"> + <input type="number" class="form-control" ng-model="invoice.vat"> + <span class="input-group-addon">%</span> + </div> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Description</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="invoice.description"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Émission</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="invoice.emittedDate"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Échéance</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="invoice.expectedDate"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Paiement</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="invoice.paymentDate"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Catégorie</label> + <div class="col-xs-9"> + <ui-select ng-model="invoice.category" theme="select2" class="col-xs-9"> + <ui-select-match placeholder="Entrez le nom de la catégorie">{{$select.selected.name}}</ui-select-match> + <ui-select-choices repeat="category in categories | propsFilter: {name: $select.search}"> + <span ng-bind-html="''+category.name | highlight: $select.search"></span> + </ui-select-choices> + </ui-select> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Statut</label> + <div class="col-xs-9"> + <select ng-model="invoice.status" class="form-control"> + <option selected>ACCEPTED</option> + <option>CANCELLED</option> + </select> + </div> + </div> + + </form> + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceDetailCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceDetailCard.html new file mode 100644 index 0000000..68a4708 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceDetailCard.html @@ -0,0 +1,58 @@ +<div class="panel panel-default"> + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Détails de la facture</h3> + <div class="btn-group pull-right visible-xs"> + <a class="btn btn-primary" href="#/companies/{{company.wikittyId}}/invoices/{{invoice.wikittyId}}/edit"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <a class="btn btn-primary pull-right hidden-xs" + href="#/companies/{{company.wikittyId}}/invoices/{{invoice.wikittyId}}/edit"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <div class="list-group"> + <div class="list-group-item"> + <label>Référence</label> + <h4 class="list-group-item-heading">{{invoice.reference}}</h4> + </div> + <div class="list-group-item"> + <label>Montant</label> + <h4 class="list-group-item-heading">{{invoice.amount|currency}}</h4> + </div> + <div class="list-group-item"> + <label>TVA</label> + <h4 class="list-group-item-heading">{{invoice.vat}} %</h4> + </div> + <div class="list-group-item"> + <label>Description</label> + <h4 class="list-group-item-heading">{{invoice.description}}</h4> + </div> + <div class="list-group-item"> + <label>Émission</label> + <h4 class="list-group-item-heading">{{invoice.emittedDate}}</h4> + </div> + <div class="list-group-item"> + <label>Limite de paiement</label> + <h4 class="list-group-item-heading">{{invoice.expectedDate}}</h4> + </div> + <div class="list-group-item"> + <label>Paiement</label> + <h4 class="list-group-item-heading">{{invoice.paymentDate}}</h4> + </div> + <div class="list-group-item"> + <label>Target</label> + <h4 class="list-group-item-heading">{{invoice.target}}</h4> + </div> + <div class="list-group-item"> + <label>Catégorie</label> + <h4 class="list-group-item-heading">{{invoice.category.name}}</h4> + </div> + <div class="list-group-item"> + <label>Statut</label> + <h4 class="list-group-item-heading">{{invoice.status}}</h4> + </div> + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceEditCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceEditCard.html new file mode 100644 index 0000000..812ee17 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceEditCard.html @@ -0,0 +1,106 @@ +<div class="panel panel-default"> + + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Éditer une facture</h3> + <div class="btn-group pull-right"> + <button class="btn btn-danger" ng-click="cancel()"> + <i class="fa fa-times"></i> + Annuler + </button> + <button class="btn btn-success" ng-click="save()"> + <i class="fa fa-check"></i> + Sauver + </button> + </div> + </div> + + <div class="modal-body"> + <form class="form-horizontal"> + + <div class="form-group"> + <label class="col-xs-3 control-label">Référence</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="invoice.reference"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Montant</label> + <div class="col-xs-9"> + <div class="input-group"> + <input type="number" class="form-control" ng-model="invoice.amount"> + <span class="input-group-addon">€</span> + </div> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">TVA</label> + <div class="col-xs-9"> + <div class="input-group"> + <input type="number" class="form-control" ng-model="invoice.vat"> + <span class="input-group-addon">%</span> + </div> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Description</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="invoice.description"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Émission</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="invoice.emittedDate"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Échéance</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="invoice.expectedDate"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Paiement</label> + <div class="col-xs-9"> + <input type="text" class="form-control" ng-model="invoice.paymentDate"> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Catégorie</label> + <div class="col-xs-9"> + <ui-select ng-model="invoice.category" theme="select2" class="col-xs-9"> + <ui-select-match placeholder="Entrez le nom de la catégorie">{{$select.selected.name}}</ui-select-match> + <ui-select-choices repeat="category in categories | propsFilter: {name: $select.search}"> + <span ng-bind-html="''+category.name | highlight: $select.search"></span> + </ui-select-choices> + </ui-select> + </div> + </div> + + <div class="form-group"> + <label class="col-xs-3 control-label">Statut</label> + <div class="col-xs-9"> + <select ng-model="invoice.status" class="form-control"> + <option>ACCEPTED</option> + <option>CANCELLED</option> + </select> + </div> + </div> + + </form> + </div> + + <div class="panel-footer"> + <button class="btn btn-danger btn-block" ng-click="delete()"> + <i class="fa fa-trash-o"></i> + Supprimer la facture + </button> + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoicesListCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoicesListCard.html new file mode 100644 index 0000000..89d5ad6 --- /dev/null +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoicesListCard.html @@ -0,0 +1,21 @@ +<div class="panel panel-default"> + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Factures</h3> + <div class="btn-group pull-right visible-xs"> + <a class="btn btn-primary" href="#/companies/{{company.wikittyId}}/invoices/add"> + <i class="fa fa-pencil"></i> + <span>Ajouter</span> + </a> + </div> + <a class="btn btn-primary pull-right hidden-xs" href="#/companies/{{company.wikittyId}}/invoices/add"> + <i class="fa fa-plus"></i> + <span>Ajouter</span> + </a> + </div> + <div class="list-group"> + <a class="list-group-item" ng-repeat="invoice in invoices" href="#/companies/{{company.wikittyId}}/invoices/{{invoice.wikittyId}}"/> + <label>{{invoice.emittedDate | date : dd/MM/yyy}} - {{invoice.description}}</label> + <h4 class="list-group-item-heading">{{invoice.reference}} - {{invoice.amount|currency}}</h4> + </a> + </div> +</div> \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/js/crm.js b/chorem-webmotion/src/main/webapp/js/crm.js index 0859bc2..1298558 100644 --- a/chorem-webmotion/src/main/webapp/js/crm.js +++ b/chorem-webmotion/src/main/webapp/js/crm.js @@ -54,7 +54,19 @@ crmTest.config(['$routeProvider', when('/companies/:companyId/employees/:employeeId/edit', { templateUrl:'partials/employeeEditCard.html', - controller:'EmployeeEditController'}); + controller:'EmployeeEditController'}). + + when('/companies/:companyId/invoices/add', { + templateUrl:'partials/invoiceCreateCard.html', + controller:'InvoiceCreateController'}). + + when('/companies/:companyId/invoices/:invoiceId', { + templateUrl:'partials/invoiceDetailCard.html', + controller:'InvoiceDetailController'}). + + when('/companies/:companyId/invoices/:invoiceId/edit', { + templateUrl:'partials/invoiceEditCard.html', + controller:'InvoiceEditController'}); }]); /**For select 2 filtering -> OR between search terms instead of AND**/ @@ -206,17 +218,27 @@ crmTest.controller('CompanyDetailController', function ($scope, $http, $routePar }; //get back employees for the company - $scope.updateEmployees=function(){ - if ($scope.company){ - $http.get('employees?company='+$scope.company.wikittyId).success(function(data){ - $scope.employees = data; - }); - } - }; + $scope.updateEmployees=function(){ + if ($scope.company){ + $http.get('employees?company='+$scope.company.wikittyId).success(function(data){ + $scope.employees = data; + }); + } + }; + + //get back invoices for the company + $scope.updateInvoices=function(){ + if ($scope.company){ + $http.get('invoices?payer='+$scope.company.wikittyId).success(function(data){ + $scope.invoices = data; + }); + } + }; $scope.updateContactDetails(); $scope.updateNotes(); $scope.updateEmployees(); + $scope.updateInvoices(); }); @@ -560,4 +582,93 @@ crmTest.controller('EmployeeCreateController', function ($scope, $http, $window) $scope.cancel = function(){ $window.history.back(); } +}); + +crmTest.controller('InvoiceDetailController', function ($scope, $http, $routeParams){ + + $scope.company=$scope.selectedItem; + + $http.get('invoices/'+$routeParams.invoiceId).success(function(data){ + $scope.invoice = data; + }); + +}); + +crmTest.controller('InvoiceCreateController', function ($scope, $http, $window) { + + $scope.company = $scope.selectedItem; + + $scope.invoice={}; + + //default status + $scope.invoice.status="ACCEPTED"; + + //get all categories + $http.get('categories').success(function(data){ + $scope.categories = data; + }); + + $scope.save = function(){ + + $scope.invoice.payer = $scope.company; + + $http({ + method : 'PUT', + url : 'invoices/add', + data : $.param($scope.invoice), // pass in data as strings + headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) + }) + .success(function(data) { + $window.history.back(); + }); + }; + + $scope.cancel = function(){ + $window.history.back(); + } +}); + +crmTest.controller('InvoiceEditController', function ($scope, $http, $window, $routeParams) { + + $scope.company = $scope.selectedItem; + + $scope.invoice={}; + + $http.get('invoices/'+$routeParams.invoiceId).success(function(data){ + $scope.invoice = data; + }); + + //get all categories + $http.get('categories').success(function(data){ + $scope.categories = data; + }); + + $scope.save = function(){ + + $scope.invoice.payer = $scope.company; + + $http({ + method : 'POST', + url : 'invoices/'+$scope.invoice.wikittyId, + data : $.param($scope.invoice), // pass in data as strings + headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload) + }) + .success(function(data) { + $window.history.back(); + }); + }; + + $scope.cancel = function(){ + $window.history.back(); + } + + $scope.delete = function(){ + if(confirm('Are you sure you want to delete?')){ + $http.delete('invoices/'+$scope.invoice.wikittyId).success(function(data){ + + $window.history.back(); + $window.history.back(); + }); + } + } }); \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/882-angular in repository chorem. See http://git.chorem.org/chorem.git commit 89ebbb7927cf0c5f74baf123ca2ebd8ab3cb97c4 Author: kootox <jean.couteau@gmail.com> Date: Thu Mar 19 10:57:09 2015 +0100 refs #882 : Add date picker on invoices --- .../webmotion/actions/crm/InvoiceAction.java | 5 +- .../org/chorem/webmotion/render/RenderJson.java | 43 +++++++++++ .../main/webapp/WEB-INF/jsp/crm/angularTest.html | 2 + .../jsp/crm/partials/invoiceCreateCard.html | 23 +++--- .../jsp/crm/partials/invoiceDetailCard.html | 8 +- .../WEB-INF/jsp/crm/partials/invoiceEditCard.html | 24 +++++- chorem-webmotion/src/main/webapp/js/crm.js | 87 +++++++++++++++++++++- 7 files changed, 173 insertions(+), 19 deletions(-) diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/InvoiceAction.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/InvoiceAction.java index b357f34..6536fe1 100644 --- a/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/InvoiceAction.java +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/crm/InvoiceAction.java @@ -3,6 +3,7 @@ package org.chorem.webmotion.actions.crm; import org.chorem.ChoremClient; import org.chorem.entities.Invoice; import org.chorem.entities.InvoiceImpl; +import org.chorem.webmotion.render.RenderJson; import org.debux.webmotion.server.WebMotionController; import org.debux.webmotion.server.render.Render; import org.nuiton.wikitty.query.WikittyQuery; @@ -48,7 +49,7 @@ public class InvoiceAction extends WebMotionController { InvoiceDTO dto = new InvoiceDTO(invoice, client); - return renderJSON(dto); + return new RenderJson(toMap(dto)); } @@ -114,7 +115,7 @@ public class InvoiceAction extends WebMotionController { dto = new InvoiceDTO(invoice, client); - return renderJSON(dto); + return new RenderJson(toMap(dto)); } diff --git a/chorem-webmotion/src/main/java/org/chorem/webmotion/render/RenderJson.java b/chorem-webmotion/src/main/java/org/chorem/webmotion/render/RenderJson.java new file mode 100644 index 0000000..f218863 --- /dev/null +++ b/chorem-webmotion/src/main/java/org/chorem/webmotion/render/RenderJson.java @@ -0,0 +1,43 @@ +package org.chorem.webmotion.render; + +import com.google.gson.Gson; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletResponse; + +import com.google.gson.GsonBuilder; +import org.debux.webmotion.server.call.Call; +import org.debux.webmotion.server.call.HttpContext; +import org.debux.webmotion.server.mapping.Mapping; +import org.debux.webmotion.server.render.Render; + +public class RenderJson extends Render { + protected Map<String, Object> model; + + public RenderJson(Map<String, Object> model) { + this.model = model; + } + + public Map<String, Object> getModel() { + return this.model; + } + + public void create(Mapping mapping, Call call) throws IOException, ServletException { + HttpContext context = call.getContext(); + HttpServletResponse response = context.getResponse(); + Object object = this.model; + if(this.model != null && this.model.size() == 1 && this.model.keySet().contains(DEFAULT_MODEL_NAME)) { + object = this.model.values().toArray()[0]; + } + + response.setContentType("application/json"); + + Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create(); + + String json = gson.toJson(object); + PrintWriter out = context.getOut(); + out.print(json); + } +} \ No newline at end of file diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html index 0b81234..6cc9f5b 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/angularTest.html @@ -19,6 +19,8 @@ <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-select/0.10.0/select.js"></script> <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.5/select2.css"> + <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.1/ui-bootstrap-tpls.js"></script> + </head> diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceCreateCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceCreateCard.html index 2475e54..de6f303 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceCreateCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceCreateCard.html @@ -52,23 +52,28 @@ </div> <div class="form-group"> - <label class="col-xs-3 control-label">Émission</label> - <div class="col-xs-9"> - <input type="text" class="form-control" ng-model="invoice.emittedDate"> - </div> - </div> - - <div class="form-group"> <label class="col-xs-3 control-label">Échéance</label> <div class="col-xs-9"> - <input type="text" class="form-control" ng-model="invoice.expectedDate"> + <p class="input-group"> + <input type="text" class="form-control" datepicker-popup="dd/MM/yyyy" ng-model="invoice.expectedDate" + is-open="openedExpected" datepicker-options="dateOptions" close-text="Close" /> + <span class="input-group-btn"> + <button type="button" class="btn btn-default" ng-click="openExpected($event)"><i class="glyphicon glyphicon-calendar"></i></button> + </span> + </p> </div> </div> <div class="form-group"> <label class="col-xs-3 control-label">Paiement</label> <div class="col-xs-9"> - <input type="text" class="form-control" ng-model="invoice.paymentDate"> + <p class="input-group"> + <input type="text" class="form-control" datepicker-popup="dd/MM/yyyy" ng-model="invoice.paymentDate" + is-open="openedPayment" datepicker-options="dateOptions" close-text="Close" /> + <span class="input-group-btn"> + <button type="button" class="btn btn-default" ng-click="openPayment($event)"><i class="glyphicon glyphicon-calendar"></i></button> + </span> + </p> </div> </div> diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceDetailCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceDetailCard.html index 68a4708..8682c06 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceDetailCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceDetailCard.html @@ -32,15 +32,15 @@ </div> <div class="list-group-item"> <label>Émission</label> - <h4 class="list-group-item-heading">{{invoice.emittedDate}}</h4> + <h4 class="list-group-item-heading">{{invoice.emittedDate|date:'dd/MM/yyyy'}}</h4> </div> <div class="list-group-item"> - <label>Limite de paiement</label> - <h4 class="list-group-item-heading">{{invoice.expectedDate}}</h4> + <label>Échéance</label> + <h4 class="list-group-item-heading">{{invoice.expectedDate|date:'dd/MM/yyyy'}}</h4> </div> <div class="list-group-item"> <label>Paiement</label> - <h4 class="list-group-item-heading">{{invoice.paymentDate}}</h4> + <h4 class="list-group-item-heading">{{invoice.paymentDate|date:'dd/MM/yyyy'}}</h4> </div> <div class="list-group-item"> <label>Target</label> diff --git a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceEditCard.html b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceEditCard.html index 812ee17..51181e7 100644 --- a/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceEditCard.html +++ b/chorem-webmotion/src/main/webapp/WEB-INF/jsp/crm/partials/invoiceEditCard.html @@ -54,21 +54,39 @@ <div class="form-group"> <label class="col-xs-3 control-label">Émission</label> <div class="col-xs-9"> - <input type="text" class="form-control" ng-model="invoice.emittedDate"> + <p class="input-group"> + <input type="text" class="form-control" datepicker-popup="dd/MM/yyyy" ng-model="invoice.emittedDate" + is-open="opened" datepicker-options="dateOptions" close-text="Fermer" /> + <span class="input-group-btn"> + <button type="button" class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button> + </span> + </p> </div> </div> <div class="form-group"> <label class="col-xs-3 control-label">Échéance</label> <div class="col-xs-9"> - <input type="text" class="form-control" ng-model="invoice.expectedDate"> + <p class="input-group"> + <input type="text" class="form-control" datepicker-popup="dd/MM/yyyy" ng-model="invoice.expectedDate" + is-open="openedExpected" datepicker-options="dateOptions" close-text="Close" /> + <span class="input-group-btn"> + <button type="button" class="btn btn-default" ng-click="openExpected($event)"><i class="glyphicon glyphicon-calendar"></i></button> + </span> + </p> </div> </div> <div class="form-group"> <label class="col-xs-3 control-label">Paiement</label> <div class="col-xs-9"> - <input type="text" class="form-control" ng-model="invoice.paymentDate"> + <p class="input-group"> + <input type="text" class="form-control" datepicker-popup="dd/MM/yyyy" ng-model="invoice.paymentDate" + is-open="openedPayment" datepicker-options="dateOptions" close-text="Close" /> + <span class="input-group-btn"> + <button type="button" class="btn btn-default" ng-click="openPayment($event)"><i class="glyphicon glyphicon-calendar"></i></button> + </span> + </p> </div> </div> diff --git a/chorem-webmotion/src/main/webapp/js/crm.js b/chorem-webmotion/src/main/webapp/js/crm.js index 1298558..60cca07 100644 --- a/chorem-webmotion/src/main/webapp/js/crm.js +++ b/chorem-webmotion/src/main/webapp/js/crm.js @@ -1,4 +1,4 @@ -var crmTest = angular.module('crmTest', ['ngRoute','ui.select','ngSanitize']); +var crmTest = angular.module('crmTest', ['ngRoute','ui.select','ngSanitize', 'ui.bootstrap']); crmTest.config(['$routeProvider', function($routeProvider){ @@ -612,6 +612,20 @@ crmTest.controller('InvoiceCreateController', function ($scope, $http, $window) $scope.invoice.payer = $scope.company; + //date parsing before submitting + console.log($scope.invoice.emittedDate); + if ($scope.invoice.emittedDate instanceof Date){ + $scope.invoice.emittedDate = $scope.invoice.emittedDate.toJSON(); + } else { + $scope.invoice.emittedDate = undefined; + } + if ($scope.invoice.expectedDate instanceof Date){ + $scope.invoice.expectedDate = $scope.invoice.expectedDate.toJSON(); + } + if ($scope.invoice.paymentDate instanceof Date){ + $scope.invoice.paymentDate = $scope.invoice.paymentDate.toJSON(); + } + $http({ method : 'PUT', url : 'invoices/add', @@ -626,6 +640,32 @@ crmTest.controller('InvoiceCreateController', function ($scope, $http, $window) $scope.cancel = function(){ $window.history.back(); } + + $scope.open = function($event) { + $event.preventDefault(); + $event.stopPropagation(); + + $scope.opened = true; + }; + + $scope.openExpected = function($event) { + $event.preventDefault(); + $event.stopPropagation(); + + $scope.openedExpected = true; + }; + + $scope.openPayment = function($event) { + $event.preventDefault(); + $event.stopPropagation(); + + $scope.openedPayment = true; + }; + + $scope.dateOptions = { + formatYear: 'yy', + startingDay: 1 + }; }); crmTest.controller('InvoiceEditController', function ($scope, $http, $window, $routeParams) { @@ -636,6 +676,7 @@ crmTest.controller('InvoiceEditController', function ($scope, $http, $window, $r $http.get('invoices/'+$routeParams.invoiceId).success(function(data){ $scope.invoice = data; + //$scope.invoice.emittedDate=new Date($scope.invoice.emittedDate); }); //get all categories @@ -647,6 +688,24 @@ crmTest.controller('InvoiceEditController', function ($scope, $http, $window, $r $scope.invoice.payer = $scope.company; + //date parsing before submitting + console.log($scope.invoice.emittedDate); + if ($scope.invoice.emittedDate instanceof Date){ + $scope.invoice.emittedDate = $scope.invoice.emittedDate.toJSON(); + } else { + delete $scope.invoice.emittedDate; + } + if ($scope.invoice.expectedDate instanceof Date){ + $scope.invoice.expectedDate = $scope.invoice.expectedDate.toJSON(); + } else { + delete $scope.invoice.expectedDate; + } + if ($scope.invoice.paymentDate instanceof Date){ + $scope.invoice.paymentDate = $scope.invoice.paymentDate.toJSON(); + } else { + delete $scope.invoice.paymentDate; + } + $http({ method : 'POST', url : 'invoices/'+$scope.invoice.wikittyId, @@ -671,4 +730,30 @@ crmTest.controller('InvoiceEditController', function ($scope, $http, $window, $r }); } } + + $scope.open = function($event) { + $event.preventDefault(); + $event.stopPropagation(); + + $scope.opened = true; + }; + + $scope.openExpected = function($event) { + $event.preventDefault(); + $event.stopPropagation(); + + $scope.openedExpected = true; + }; + + $scope.openPayment = function($event) { + $event.preventDefault(); + $event.stopPropagation(); + + $scope.openedPayment = true; + }; + + $scope.dateOptions = { + formatYear: 'yy', + startingDay: 1 + }; }); \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm