Merge con vicente

This commit is contained in:
nelo 2017-01-17 14:33:06 +01:00
parent 5b69f24902
commit 4a065d073d
9 changed files with 132 additions and 9 deletions

View File

@ -1,3 +1,52 @@
.display-block{
display: block;
}
/*angular-paging*/
.well {
min-height: 20px;
padding: 19px;
margin-bottom: 20px;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);
}
.pagination {
display: inline-block;
padding-left: 0;
margin: 20px 0;
border-radius: 4px;
}
.pagination > li {
display: inline;
}
.pagination > li > a,
.pagination > li > span {
position: relative;
float: left;
padding: 6px 12px;
margin-left: -1px;
line-height: 1.42857143;
color: #337ab7;
text-decoration: none;
background-color: #fff;
border: 1px solid #ddd;
}
.pagination > li:first-child > a,
.pagination > li:first-child > span {
margin-left: 0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.form-group {
margin-bottom: 15px;
}
.pagination>li.active>a {
background: #4f94ce;
color: #fff;
}
ul.pagination li a:hover:not(.active) {background-color: #ddd;}
/* fin angular-paging*/

View File

@ -7,6 +7,8 @@ export const COMPONENT = {
controllerAs: 'addressData',
controller: function($http, $state)
{
var self = this;
this.clientId = $state.params.id;
this.address = {};
$http.get('/client/api/Agencies').then(
json => this.agencies = json.data
@ -16,6 +18,7 @@ export const COMPONENT = {
);
this.submit = function(){
this.address.client = self.clientId;
$http.post('/client/api/Addresses', this.address).then(
json => $state.go('clientCard.addresses')
);

View File

@ -18,8 +18,22 @@
</vn-auto>
</vn-horizontal>
</vn-vertical>
<vn-horizontal>
<vn-one style="text-align:center;">
<paging page="address.currentPage"
page-size="address.numPerPage"
total="address.numPages"
show-prev-next="true"
show-first-last="true"
ul-class="pagination"
active-class="active"
ng-click="address.figureOutToDisplay()">
</paging>
</vn-one>
</vn-horizontal>
</vn-card>
<vn-one margin-large-top style="position: fixed; bottom: 2em; right: 2em;">
<a ui-sref="clientCard.addressDataCreate"><vn-float-button icon="add"></vn-float-button></a>
<vn-float-button ng-click="address.newAddress()" icon="add"></vn-float-button>
</vn-one>
</vn-vertical>

View File

@ -5,22 +5,64 @@ export const NAME = 'vnClientAddresses';
export const COMPONENT = {
template: template,
controllerAs: 'address',
bindings: {
adresses: '<',
bindings: {
client: '<'
},
controller: function($http)
controller: function($http, $state)
{
var self = this;
let numPerPage = 2;
let numRecords = 0;
this.$onChanges = function(changes) {
if (this.client) {
self.client = this.client;
this.getAddresses();
}
};
this.getAddresses = () => {
var json = JSON.stringify({client: self.client.id});
$http.get(`/client/api/Addresses/count?where=${json}`).then(
json => {
numRecords = json.data.count;
self.getNumPages();
self.figureOutToDisplay();
}
);
};
$http.get('/client/api/Addresses').then(
json => this.addresses = json.data
);
this.submit = function(){
$http.post('/client/api/Clients', this.model).then(
json => $state.go('clientCard.basicData',{id: json.data.id})
this.getNumPages = () => {
var nPages = numRecords / numPerPage;
if (nPages > 0)
self.numPages = (nPages % 2) ? Math.ceil(nPages) : Math.ceil(nPages) + 1;
};
this.figureOutToDisplay = () => {
var begin = ((self.currentPage - 1) * numPerPage);
self.getAddress(begin);
};
this.getAddress = function(end) {
var json = JSON.stringify({where: {client: self.client.id}, limit: numPerPage, skip: end});
$http.get(`/client/api/Addresses?filter=${json}`).then(
json => {
self.addresses = json.data;
self.filteredTodos = self.addresses;
}
);
};
this.pageChanged = () => {
self.figureOutToDisplay();
};
this.newAddress = () => {
$state.go("clientCard.addressDataCreate", {id: self.client.id});
};
}
};
COMPONENT.controller.$inject = ['$http'];
COMPONENT.controller.$inject = ['$http', '$state'];
module.component(NAME, COMPONENT);

View File

@ -31,6 +31,9 @@
url: "/addresses",
state: "clientCard.addresses",
component: "vn-client-addresses",
params: {
client: "card.client"
},
description: "Consignatarios",
icon: "local_shipping"
}, {

View File

@ -10,6 +10,7 @@
},
"dependencies": {
"angular": "^1.5.8",
"angular-paging": "^2.2.2",
"angular-translate": "^2.13.1",
"angular-ui-router": "^1.0.0-beta.3",
"express": "^4.14.0",

5
@salix/vendor/src/angular-paging.js vendored Normal file
View File

@ -0,0 +1,5 @@
import * as _ngPaging from 'angular-paging';
export const ngPaging = {
name: 'bw.paging'
};

View File

@ -2,4 +2,5 @@ export * from './angular-vendor';
export * from './oclazyload-vendor';
export * from './uirouter-vendor';
export * from './angular-translate-vendor';
export * from './materialdesignlite-vendor';
export * from './materialdesignlite-vendor';
export * from './angular-paging';

View File

@ -49,6 +49,11 @@
"type": "belongsTo",
"model": "Province",
"foreignKey": "provinceId"
},
"client": {
"type": "belongsTo",
"model":"Client",
"foreignKey": "clientId"
}
}
}