branch chorem-ng updated (b052058 -> 1ec27b3)
This is an automated email from the git hooks/post-receive script. New change to branch chorem-ng in repository chorem. See http://git.chorem.org/chorem.git from b052058 UI architecture new 1ec27b3 refs #1211 : Init CRM using ui-router not backend plugged The 1 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 1ec27b39865ca25e089c57c5ea26c0d3f0143e1f Author: kootox <jean.couteau@gmail.com> Date: Sun Mar 29 17:45:14 2015 +0200 refs #1211 : Init CRM using ui-router not backend plugged Summary of changes: .../main/webapp/crm/partials/companies.list.html | 51 ++++++++ .../webapp/crm/partials/companyCreateCard.html | 39 ++++++ .../src/main/webapp/crm/partials/crm.html | 1 + chorem-ui-angular/src/main/webapp/home.html | 2 +- chorem-ui-angular/src/main/webapp/index.html | 1 + chorem-ui-angular/src/main/webapp/js/chorem.js | 2 +- chorem-ui-angular/src/main/webapp/js/crm/crm.js | 141 +++++++++++++++++++++ 7 files changed, 235 insertions(+), 2 deletions(-) create mode 100644 chorem-ui-angular/src/main/webapp/crm/partials/companies.list.html create mode 100644 chorem-ui-angular/src/main/webapp/crm/partials/companyCreateCard.html create mode 100644 chorem-ui-angular/src/main/webapp/crm/partials/crm.html create mode 100644 chorem-ui-angular/src/main/webapp/js/crm/crm.js -- 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 chorem-ng in repository chorem. See http://git.chorem.org/chorem.git commit 1ec27b39865ca25e089c57c5ea26c0d3f0143e1f Author: kootox <jean.couteau@gmail.com> Date: Sun Mar 29 17:45:14 2015 +0200 refs #1211 : Init CRM using ui-router not backend plugged --- .../main/webapp/crm/partials/companies.list.html | 51 ++++++++ .../webapp/crm/partials/companyCreateCard.html | 39 ++++++ .../src/main/webapp/crm/partials/crm.html | 1 + chorem-ui-angular/src/main/webapp/home.html | 2 +- chorem-ui-angular/src/main/webapp/index.html | 1 + chorem-ui-angular/src/main/webapp/js/chorem.js | 2 +- chorem-ui-angular/src/main/webapp/js/crm/crm.js | 141 +++++++++++++++++++++ 7 files changed, 235 insertions(+), 2 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 new file mode 100644 index 0000000..0e10dd4 --- /dev/null +++ b/chorem-ui-angular/src/main/webapp/crm/partials/companies.list.html @@ -0,0 +1,51 @@ +<div class="bootcards-container"> + <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"> + <div class="row"> + <div class="col-xs-9"> + <div class="form-group"> + <input type="text" class="form-control" placeholder="Search Companies..." + 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"> + <i class="fa fa-plus"></i> + <span>Add</span> + </a> + </div> + </div> + </div> + </div> + + <div class="list-group"> + <a class="list-group-item" href="#/companies/{{company.wikittyId}}" + 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> + </a> + + </div> + + <div class="panel-footer"> + <small class="pull-left"> </small> + </div> + + </div> + + </div> + + <div class="col-sm-6 bootcards-cards" ui-view> + + </div> + + </div> + +</div> \ No newline at end of file diff --git a/chorem-ui-angular/src/main/webapp/crm/partials/companyCreateCard.html b/chorem-ui-angular/src/main/webapp/crm/partials/companyCreateCard.html new file mode 100644 index 0000000..48d8c39 --- /dev/null +++ b/chorem-ui-angular/src/main/webapp/crm/partials/companyCreateCard.html @@ -0,0 +1,39 @@ +<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> \ No newline at end of file diff --git a/chorem-ui-angular/src/main/webapp/crm/partials/crm.html b/chorem-ui-angular/src/main/webapp/crm/partials/crm.html new file mode 100644 index 0000000..f182cdd --- /dev/null +++ b/chorem-ui-angular/src/main/webapp/crm/partials/crm.html @@ -0,0 +1 @@ +<div ui-view></div> \ No newline at end of file diff --git a/chorem-ui-angular/src/main/webapp/home.html b/chorem-ui-angular/src/main/webapp/home.html index c11ceac..134ed7d 100644 --- a/chorem-ui-angular/src/main/webapp/home.html +++ b/chorem-ui-angular/src/main/webapp/home.html @@ -24,7 +24,7 @@ </a> </div> <div class="col-xs-6 col-sm-4"> - <a class="bootcards-summary-item" href="/companies" style="padding-top:35px;"> + <a class="bootcards-summary-item" ui-sref="crm.companies" style="padding-top:35px;"> <i class="fa fa-3x fa-building-o"></i> <h4> Sociétés diff --git a/chorem-ui-angular/src/main/webapp/index.html b/chorem-ui-angular/src/main/webapp/index.html index 7ca5bee..bb8d60c 100644 --- a/chorem-ui-angular/src/main/webapp/index.html +++ b/chorem-ui-angular/src/main/webapp/index.html @@ -12,6 +12,7 @@ <script src="webjars/angular-ui-router/0.2.13/angular-ui-router.js"></script> + <script src="js/crm/crm.js"></script> <script src="js/chorem.js"></script> <link href="webjars/bootcards/1.1.0/css/bootcards-desktop.min.css" rel="stylesheet"/> <link href="https://cdnjs.cloudflare.com/ajax/libs/bootcards/1.1.0/css/bootcards-desktop..." rel="stylesheet"/> diff --git a/chorem-ui-angular/src/main/webapp/js/chorem.js b/chorem-ui-angular/src/main/webapp/js/chorem.js index 10d5f4b..72c34f9 100644 --- a/chorem-ui-angular/src/main/webapp/js/chorem.js +++ b/chorem-ui-angular/src/main/webapp/js/chorem.js @@ -1,4 +1,4 @@ -var chorem = angular.module('chorem', ['ngRoute','ui.select','ngSanitize', 'ui.bootstrap', 'ui.router']); +var chorem = angular.module('chorem', ['ngRoute','ui.select','ngSanitize', 'ui.bootstrap', 'ui.router', 'chorem.crm']); chorem.run( [ '$rootScope', '$state', '$stateParams', diff --git a/chorem-ui-angular/src/main/webapp/js/crm/crm.js b/chorem-ui-angular/src/main/webapp/js/crm/crm.js new file mode 100644 index 0000000..4a70e63 --- /dev/null +++ b/chorem-ui-angular/src/main/webapp/js/crm/crm.js @@ -0,0 +1,141 @@ +var choremCRM = angular.module('chorem.crm', ['ngRoute','ui.router']); + +choremCRM.config( + [ '$stateProvider', '$urlRouterProvider', + function ($stateProvider, $urlRouterProvider) { + $stateProvider + .state('crm', { + abstract: true, + templateUrl: 'crm/partials/crm.html', + url: '/crm' + }) + + .state('crm.companies', { + url: '/companies', + templateUrl: 'crm/partials/companies.list.html', + controller:'CompanyListController' + }) + + .state('crm.companies.add', { + url: '/add', + templateUrl: 'crm/partials/companyCreateCard.html', + controller:'CompanyCreateController' + }); +}]); + +choremCRM.controller('CompanyListController', function ($scope, $http, $location, $route, $routeParams) { + + $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(selectedCompany){ + $scope.selectedItem = selectedCompany; + }; + + $scope.selectItemById=function(id){ + for (var index in $scope.items) { + var company = $scope.items[index]; + if (company.wikittyId===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.name.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('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(); + +}); + +choremCRM.controller('CompanyCreateController', 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(); + } + +}); + -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm