This is an automated email from the git hooks/post-receive script. New commit to branch chorem-ng in repository chorem. See http://git.chorem.org/chorem.git commit b2ef1352eb9c3e8e7daa7d35d5239c36db25c70d Author: kootox <jean.couteau@gmail.com> Date: Thu Apr 16 16:35:39 2015 +0200 refs #1211 : Add persons list, filering and navigation --- .../main/webapp/crm/partials/companies.list.html | 2 +- .../main/webapp/crm/partials/personInfoCard.html | 26 ++++ .../src/main/webapp/crm/partials/personPanel.html | 11 ++ .../{companies.list.html => personsList.html} | 20 +-- chorem-ui-angular/src/main/webapp/home.html | 2 +- chorem-ui-angular/src/main/webapp/index.html | 2 +- chorem-ui-angular/src/main/webapp/js/crm/crm.js | 22 ++- .../src/main/webapp/js/crm/crmControllers.js | 153 +++++++++++++++++++++ 8 files changed, 223 insertions(+), 15 deletions(-) diff --git a/chorem-ui-angular/src/main/webapp/crm/partials/companies.list.html b/chorem-ui-angular/src/main/webapp/crm/partials/companies.list.html index d66ea9b..c1795ad 100644 --- a/chorem-ui-angular/src/main/webapp/crm/partials/companies.list.html +++ b/chorem-ui-angular/src/main/webapp/crm/partials/companies.list.html @@ -1,5 +1,5 @@ <div class="bootcards-container"> - <div class="row" ng-controller="CompanyListController"> + <div class="row"> <div class="col-sm-6 bootcards-list" id="list"> <div class="panel panel-default"> <div class="panel-body"> diff --git a/chorem-ui-angular/src/main/webapp/crm/partials/personInfoCard.html b/chorem-ui-angular/src/main/webapp/crm/partials/personInfoCard.html new file mode 100644 index 0000000..59a6fa0 --- /dev/null +++ b/chorem-ui-angular/src/main/webapp/crm/partials/personInfoCard.html @@ -0,0 +1,26 @@ +<div class="panel panel-default"> + <div class="panel-heading clearfix"> + <h3 class="panel-title pull-left">Détails de la personne</h3> + <div class="btn-group pull-right visible-xs"> + <a class="btn btn-primary" href="#/company/{{company.id}}/edit"> + <i class="fa fa-pencil"></i> + <span>Edit</span> + </a> + </div> + <a class="btn btn-primary pull-right hidden-xs" href="#/companies/{{company.id}}/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-user pull-left"></i> + <label>Prénom</label> + <h4 class="list-group-item-heading">{{person.Person.firstName}}</h4> + </div> + <div class="list-group-item"> + <label>Nom</label> + <h4 class="list-group-item-heading">{{person.Person.lastName}}</h4> + </div> + </div> +</div> \ No newline at end of file diff --git a/chorem-ui-angular/src/main/webapp/crm/partials/personPanel.html b/chorem-ui-angular/src/main/webapp/crm/partials/personPanel.html new file mode 100644 index 0000000..711ab83 --- /dev/null +++ b/chorem-ui-angular/src/main/webapp/crm/partials/personPanel.html @@ -0,0 +1,11 @@ +<!-- person info card --> +<ng-include src="'crm/partials/personInfoCard.html'"></ng-include> + +<!-- contact details card --> +<ng-include src="'crm/partials/contactDetailsListCard.html'"></ng-include> + +<!-- notes card --> +<ng-include src="'crm/partials/notesListCard.html'"></ng-include> + +<!--employees card --> +<ng-include src="'crm/partials/employeesListCard.html'"></ng-include> \ No newline at end of file diff --git a/chorem-ui-angular/src/main/webapp/crm/partials/companies.list.html b/chorem-ui-angular/src/main/webapp/crm/partials/personsList.html similarity index 67% copy from chorem-ui-angular/src/main/webapp/crm/partials/companies.list.html copy to chorem-ui-angular/src/main/webapp/crm/partials/personsList.html index d66ea9b..843d349 100644 --- a/chorem-ui-angular/src/main/webapp/crm/partials/companies.list.html +++ b/chorem-ui-angular/src/main/webapp/crm/partials/personsList.html @@ -1,5 +1,5 @@ <div class="bootcards-container"> - <div class="row" ng-controller="CompanyListController"> + <div class="row"> <div class="col-sm-6 bootcards-list" id="list"> <div class="panel panel-default"> <div class="panel-body"> @@ -7,13 +7,13 @@ <div class="row"> <div class="col-xs-9"> <div class="form-group"> - <input type="text" class="form-control" placeholder="Search Companies..." + <input type="text" class="form-control" placeholder="Search Persons..." ng-model="searchTerm" ng-change="filter()"> <i class="fa fa-search"></i> </div> </div> <div class="col-xs-3"> - <a class="btn btn-primary btn-block" ui-sref="crm.companies.add"> + <a class="btn btn-primary btn-block" ui-sref="crm.persons.add"> <i class="fa fa-plus"></i> <span>Add</span> </a> @@ -23,13 +23,13 @@ </div> <div class="list-group"> - <a class="list-group-item" href="#/companies/{{company.id}}" - 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.Company.name}}</h4> - <p class="list-group-item-text">{{company.Company.type}} </p> + <a class="list-group-item" href="#/persons/{{company.id}}" + ng-repeat="person in filteredItems" + ng-class="{'active':isItemSelected(person)}" + ng-click="selectItem(person)"> + <i class="fa fa-3x fa-user pull-left"></i> + <h4 class="list-group-item-heading">{{person.Person.firstName}} {{person.Person.lastName}}</h4> + <p> </p> </a> </div> diff --git a/chorem-ui-angular/src/main/webapp/home.html b/chorem-ui-angular/src/main/webapp/home.html index c2790b0..ac05943 100644 --- a/chorem-ui-angular/src/main/webapp/home.html +++ b/chorem-ui-angular/src/main/webapp/home.html @@ -15,7 +15,7 @@ <div class="panel-body"> <div class="row"> <div class="col-xs-6 col-sm-4"> - <a class="bootcards-summary-item" href="#" style="padding-top:35px;"> + <a class="bootcards-summary-item" ui-sref="crm.persons" style="padding-top:35px;"> <i class="fa fa-3x fa-users"></i> <h4> Personnes diff --git a/chorem-ui-angular/src/main/webapp/index.html b/chorem-ui-angular/src/main/webapp/index.html index 7814bc3..abe885c 100644 --- a/chorem-ui-angular/src/main/webapp/index.html +++ b/chorem-ui-angular/src/main/webapp/index.html @@ -58,7 +58,7 @@ <i class="fa fa-building-o"></i> Sociétés </a></li> - <li><a href="#"> + <li><a ui-sref="crm.persons"> <i class="fa fa-users"></i> Personnes </a></li> diff --git a/chorem-ui-angular/src/main/webapp/js/crm/crm.js b/chorem-ui-angular/src/main/webapp/js/crm/crm.js index b2e42ca..73e2e10 100644 --- a/chorem-ui-angular/src/main/webapp/js/crm/crm.js +++ b/chorem-ui-angular/src/main/webapp/js/crm/crm.js @@ -25,8 +25,26 @@ choremCRM.config( .state('crm.companies.view', { url: '/:companyId', templateUrl: 'crm/partials/companyPanel.html', - controller:'CompanyDetailController' - }); + controller: 'CompanyDetailController' + }) + + .state('crm.persons', { + url: '/persons', + templateUrl: 'crm/partials/personsList.html', + controller: 'PersonListController' + }) + + .state('crm.persons.add', { + url: '/add', + templateUrl: 'crm/partials/personCreateCard.html', + controller:'PersonCreateController' + }) + + .state('crm.persons.view', { + url: '/:personId', + templateUrl: 'crm/partials/personPanel.html', + controller: 'PersonDetailController' + }) }]); diff --git a/chorem-ui-angular/src/main/webapp/js/crm/crmControllers.js b/chorem-ui-angular/src/main/webapp/js/crm/crmControllers.js index da70e5c..6382420 100644 --- a/chorem-ui-angular/src/main/webapp/js/crm/crmControllers.js +++ b/chorem-ui-angular/src/main/webapp/js/crm/crmControllers.js @@ -169,4 +169,157 @@ choremCRMControllers.controller('CompanyCreateController', function ($scope, $ht $window.history.back(); } +}); + +choremCRMControllers.controller('PersonListController', function ($scope, $http, $location, $state) { + + $scope.items = ''; + + $scope.filteredItems = $scope.items; + + $scope.searchTerm=""; + + $scope.selectedItem=$scope.items[0]; + + $scope.targetId=""; + + $scope.setTargetId=function(targetId){ + $scope.targetId=targetId; + } + + $scope.selectItem=function(selectedPerson){ + $scope.selectedItem = selectedPerson; + $state.go('crm.persons.view', { personId: selectedPerson.id }); + }; + + $scope.selectItemById=function(id){ + for (var index in $scope.items) { + var company = $scope.items[index]; + if (company.id===id){ + $scope.selectedItem=company; + } + } + } + + $scope.isItemSelected=function(selectedCompany){ + return selectedCompany===$scope.selectedItem; + }; + + $scope.filter=function(){ + $scope.filteredItems=[]; + for (var index in $scope.items) { + var company = $scope.items[index]; + var regexp = new RegExp($scope.searchTerm,"i"); + if (company.Person.firstName.match(regexp)||company.Person.lastName.match(regexp)){ + $scope.filteredItems.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(); + } + + $scope.deleteItem = function(oldItem) { + var index = $scope.items.indexOf(oldItem); + + if (index > -1) { + $scope.items.splice(index, 1); + } + + $scope.filter(); + } + + $scope.refresh=function(){ + $http.get('services/v1/Person').success(function(data){ + $scope.items = data; + $scope.filter(); + }); + }; + + $scope.refresh(); + +}); + +choremCRMControllers.controller('PersonCreateController', function ($scope, $http, $window) { + + $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) { + + //update company and selectedItem in parent scope + $scope.addItem(data); + $scope.$parent.selectedItem=data; + + $window.history.back(); + }); + }; + + $scope.cancel = function(){ + $window.history.back(); + } + +}); + +choremCRMControllers.controller('PersonDetailController', function ($scope, $http, $state){ + + $scope.personId=$state.params.personId; + + $scope.updatePerson=function(){ + if ($scope.personId){ + $http.get('services/v1/Person/'+$scope.personId).success(function(data){ + $scope.person = data; + }); + } + }; + + //get back contact details for the person + $scope.updateContactDetails=function(){ + if ($scope.personId){ + $http.get('contactDetails?target='+$scope.companyId).success(function(data){ + $scope.contactDetails = data; + }); + } + }; + + //get back notes for the person + $scope.updateNotes=function(){ + if ($scope.personId){ + $http.get('notes?target='+$scope.personId).success(function(data){ + $scope.notes = data; + }); + } + }; + + //get back companies for the person + $scope.updateEmployees=function(){ + if ($scope.personyId){ + $http.get('employees?person='+$scope.personId).success(function(data){ + $scope.employees = data; + }); + } + }; + + $scope.updatePerson(); + $scope.updateContactDetails(); + $scope.updateNotes(); + $scope.updateEmployees(); + }); \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.