arreglo vicente

This commit is contained in:
nelo 2017-01-10 14:41:56 +01:00
parent b41a285e7f
commit 020bb38873
4 changed files with 32 additions and 26 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-card >
<vn-vertical pad-large>
<vn-title vn-one>Consignatario</vn-title>
<vn-horizontal>
<vn-check vn-one label="Activo" field="addressData.activo"></vn-check>
<vn-check vn-one label="Predeterminado" field="addressData.address.enabled"></vn-check>
<vn-check vn-one label="Activo" field="addressData.address.enabled"></vn-check>
<vn-check vn-one label="Predeterminado" field="addressData.address.default"></vn-check>
</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="Domicilio" field="addressData.address.street"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<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-combo vn-one label="Provincia" field="addressData.address.province">
<option ng-repeat="p in addressData.provinces" value="{{p.id}}">{{p.name}}</ng-repeat>
<vn-combo vn-one label="Provincia" field="addressData.address.province">
<option ng-repeat="p in addressData.provinces | orderBy:'name'" value="{{p.id}}">{{p.name}}</ng-repeat>
</vn-combo>
<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-horizontal>
<vn-horizontal>
<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>
<vn-combo vn-one label="Agencia" field="addressData.address.agency">
<option ng-repeat="a in addressData.agencies | orderBy:'name'" value="{{a.id}}">{{a.name}}</ng-repeat>
</vn-combo>
</vn-horizontal>
<vn-empty>

View File

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

@ -5,7 +5,7 @@
"Client": 15,
"PaymentMethod": 4,
"SalesPerson": 4,
"Address": 56,
"Address": 65,
"Country": 3,
"Province": 3,
"Agency": 4
@ -32,11 +32,8 @@
"3": "{\"name\":\"Carlos Zambrano\",\"id\":3}"
},
"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}",
"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}",
"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\"}"
"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}",
"64": "{\"street\":\"Aaa\",\"consignee\":\"aaa\",\"city\":\"aaa\",\"postcode\":\"11111\",\"phone\":\"963242100\",\"mobile\":\"11231241423\",\"id\":64}"
},
"Country": {
"1": "{\"id\":1,\"name\":\"Spain\"}",

View File

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