This commit is contained in:
Juan Ferrer Toribio 2017-01-10 17:55:41 +01:00
commit a52ffbc9a3
7 changed files with 63 additions and 29 deletions

View File

@ -1,29 +1,28 @@
<form name="form" ng-submit="form.$valid && addressData.submit()" pad-medium> <form name="form" ng-submit="form.$valid && addressData.submit()" >
<vn-vertical pad-medium> <vn-vertical pad-medium>
<vn-card > <vn-card >
<vn-vertical pad-large> <vn-vertical pad-large>
<vn-title vn-one>Consignatario</vn-title> <vn-title vn-one>Consignatario</vn-title>
<vn-horizontal> <vn-horizontal>
<vn-check vn-one label="Activo" field="addressData.activo"></vn-check> <vn-check vn-one label="Activo" field="addressData.address.enabled"></vn-check>
<vn-check vn-one label="Predeterminado" field="addressData.address.enabled"></vn-check> <vn-check vn-one label="Predeterminado" field="addressData.address.default"></vn-check>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one label="Identificador" field="addressData.address.id" focus></vn-textfield>
<vn-textfield vn-one label="Consignatario" field="addressData.address.consignee"></vn-textfield> <vn-textfield vn-one label="Consignatario" field="addressData.address.consignee"></vn-textfield>
<vn-textfield vn-one label="Domicilio" field="addressData.address.street"></vn-textfield> <vn-textfield vn-one label="Domicilio" field="addressData.address.street"></vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one label="Código Postal" field="addressData.address.postcode"></vn-textfield> <vn-textfield vn-one label="Código Postal" field="addressData.address.postcode"></vn-textfield>
<vn-textfield vn-one label="Municipio" field="addressData.address.city"></vn-textfield> <vn-textfield vn-one label="Municipio" field="addressData.address.city"></vn-textfield>
<vn-combo vn-one label="Provincia" field="addressData.address.province"> <vn-combo vn-one label="Provincia" field="addressData.address.province">
<option ng-repeat="p in addressData.provinces" value="{{p.id}}">{{p.name}}</ng-repeat> <option ng-repeat="p in addressData.provinces | orderBy:'name'" value="{{p.id}}">{{p.name}}</ng-repeat>
</vn-combo> </vn-combo>
<vn-textfield vn-one label="Teléfono" field="addressData.address.phone"></vn-textfield> <vn-textfield vn-one label="Teléfono" field="addressData.address.phone"></vn-textfield>
<vn-textfield vn-one label="Móvil" field="addressData.address.mobile"></vn-textfield> <vn-textfield vn-one label="Móvil" field="addressData.address.mobile"></vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-combo vn-one label="Agencia" field="addressData.address.agency"> <vn-combo vn-one label="Agencia" field="addressData.address.agency">
<option ng-repeat="p in addressData.agencies | orderBy:'name'" value="{{p.id}}">{{p.name}}</ng-repeat> <option ng-repeat="a in addressData.agencies | orderBy:'name'" value="{{a.id}}">{{a.name}}</ng-repeat>
</vn-combo> </vn-combo>
</vn-horizontal> </vn-horizontal>
<vn-empty> <vn-empty>

View File

@ -5,11 +5,9 @@ export const NAME = 'vnClientAddressesData';
export const COMPONENT = { export const COMPONENT = {
template: template, template: template,
controllerAs: 'addressData', controllerAs: 'addressData',
bindings: {
address: '<'
},
controller: function($http,$stateParams) controller: function($http,$stateParams)
{ {
this.address = {}
$http.get(`/client/api/Addresses/${$stateParams.addressId}`).then( $http.get(`/client/api/Addresses/${$stateParams.addressId}`).then(
json => this.address = json.data, json => this.address = json.data,
json => console.error(json.data.error.message) json => console.error(json.data.error.message)
@ -25,12 +23,21 @@ export const COMPONENT = {
json => console.error(json.data.error.message) json => console.error(json.data.error.message)
); );
this.submit = function(){ this.submit = function(){
$http.post('/client/api/Addresses', this.address).then( if($stateParams.addressId){
json => console.log(json.statusText), $http.put('/client/api/Addresses', this.address).then(
json => console.error(json.data.error.message) json => console.log(json.statusText),
); json => console.error(json.data.error.message)
}; );
}
else{
$http.post('/client/api/Addresses', this.address).then(
json => console.log(json.statusText),
json => console.error(json.data.error.message)
);
}
};
} }
}; };

View File

@ -14,10 +14,11 @@
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one label="Código postal" field="fiscal.client.postcode"></vn-textfield> <vn-textfield vn-one label="Código postal" field="fiscal.client.postcode"></vn-textfield>
<vn-combo vn-one label="Provincia" field="fiscal.client.province"></vn-combo> <vn-combo vn-one label="Provincia" field="fiscal.client.province">
<option ng-repeat="p in fiscal.provinces" value="{{p.id}}">{{p.name}}</option>
</vn-combo>
<vn-combo vn-one label="País" field="fiscal.client.country"> <vn-combo vn-one label="País" field="fiscal.client.country">
<option value="1">Spain</option> <option ng-repeat="c in fiscal.countries" value="{{c.id}}">{{c.name}}</option>
<option value="2">Holland</option>
</vn-combo> </vn-combo>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
@ -31,7 +32,9 @@
<vn-vertical pad-large> <vn-vertical pad-large>
<vn-title>Información de facturación</vn-title> <vn-title>Información de facturación</vn-title>
<vn-horizontal> <vn-horizontal>
<vn-combo vn-two label="Forma de pago" field="fiscal.client.payMethod"></vn-combo> <vn-combo vn-two label="Forma de pago" field="fiscal.client.payMethod">
<option ng-repeat="p in fiscal.payments" value="{{p.id}}">{{p.name}}</option>
</vn-combo>
<vn-textfield vn-one label="Vencimiento" field="fiscal.client.dueDay"></vn-textfield> <vn-textfield vn-one label="Vencimiento" field="fiscal.client.dueDay"></vn-textfield>
<vn-check vn-three label="Recargo de equivalencia" field="fiscal.client.surcharge"></vn-check> <vn-check vn-three label="Recargo de equivalencia" field="fiscal.client.surcharge"></vn-check>
</vn-horizontal> </vn-horizontal>

View File

@ -9,6 +9,21 @@ export const COMPONENT = {
client: '<' client: '<'
}, },
controller: function($http) { controller: function($http) {
$http.get('/client/api/Countries').then(
json => this.countries = json.data,
json => console.error(json.data.error.message)
);
$http.get('/client/api/Provinces').then(
json => this.provinces = json.data,
json => console.error(json.data.error.message)
);
$http.get('/client/api/PaymentMethods').then(
json => this.payments = json.data,
json => console.error(json.data.error.message)
);
this.submit = function() { this.submit = function() {
$http.put('/client/api/Clients', this.client).then( $http.put('/client/api/Clients', this.client).then(
json => console.log(json.statusText), json => console.log(json.statusText),

View File

@ -32,11 +32,8 @@
"3": "{\"name\":\"Carlos Zambrano\",\"id\":3}" "3": "{\"name\":\"Carlos Zambrano\",\"id\":3}"
}, },
"Address": { "Address": {
"1": "{\"street\":\"Avda Espioca 11\",\"consignee\":\"Verndatura Silla\",\"city\":\"Silla\",\"postcode\":\"46900\",\"enabled\":true,\"phone\":\"969999898\",\"mobile\":\"989898888\",\"agencyId\":1,\"provinceId\":1,\"countryId\":1,\"id\":1}", "63": "{\"street\":\"Avd. Espioca nº 100\",\"consignee\":\"Verndatura Silla\",\"city\":\"Silla\",\"postcode\":\"46460\",\"phone\":\"66666666\",\"mobile\":\"989898888\",\"id\":63,\"province\":\"2\",\"agency\":\"3\",\"default\":true,\"enabled\":true}",
"2": "{\"street\":\"Avda Espioca 100\",\"consignee\":\"Verndatura Madrid\",\"city\":\"2\",\"postcode\":\"46900\",\"enabled\":true,\"phone\":\"963242100\",\"mobile\":\"649599333\",\"agencyId\":2,\"provinceId\":2,\"countryId\":1,\"id\":2}", "64": "{\"street\":\"Aaa\",\"consignee\":\"aaa\",\"city\":\"aaa\",\"postcode\":\"11111\",\"phone\":\"963242100\",\"mobile\":\"11231241423\",\"id\":64}"
"5": "{\"id\":5,\"street\":\"c/prueba\",\"consignee\":\"prueba\",\"city\":\"Valencia\",\"postcode\":\"46900\",\"phone\":\"659125488\",\"mobile\":\"6987452354\"}",
"34": "{\"id\":34,\"street\":\"prueba34\",\"consignee\":\"prueba34\",\"city\":\"Valencia\",\"postcode\":\"46900\",\"phone\":\"636898196\",\"mobile\":\"636898196\"}",
"55": "{\"id\":55,\"street\":\"C/ Fernando Senent Perez 11\",\"consignee\":\"prueba55\",\"city\":\"Valencia\",\"postcode\":\"46026\",\"phone\":\"636898196\",\"mobile\":\"636898196\"}"
}, },
"Country": { "Country": {
"1": "{\"id\":1,\"name\":\"Spain\"}", "1": "{\"id\":1,\"name\":\"Spain\"}",

View File

@ -30,9 +30,11 @@
}, },
"mobile": { "mobile": {
"type": "string" "type": "string"
} },
}, "default": {
"relations": { "type": "boolean"
},
"relations": {
"agency": { "agency": {
"type": "belongsTo", "type": "belongsTo",
"model": "Agency", "model": "Agency",
@ -49,4 +51,5 @@
"foreignKey": "provinceId" "foreignKey": "provinceId"
} }
} }
}
} }

View File

@ -94,6 +94,16 @@
"type": "belongsTo", "type": "belongsTo",
"model": "PaymentMethod", "model": "PaymentMethod",
"foreingKey": "payId" "foreingKey": "payId"
},
"country":{
"type": "belongsTo",
"model": "Country",
"foreignKey": "countryId"
},
"province":{
"type": "belongsTo",
"model": "Province",
"foreignKey": "provinceId"
} }
} }
} }