diff --git a/@salix/crud/src/client/addresses-data/index.html b/@salix/crud/src/client/addresses-data/index.html index 6ab814f7c..a67dfdbe7 100644 --- a/@salix/crud/src/client/addresses-data/index.html +++ b/@salix/crud/src/client/addresses-data/index.html @@ -1,29 +1,28 @@ -
+ Consignatario - - + + - - - - - diff --git a/@salix/crud/src/client/addresses-data/index.js b/@salix/crud/src/client/addresses-data/index.js index 2a5a27d83..1980a72ad 100644 --- a/@salix/crud/src/client/addresses-data/index.js +++ b/@salix/crud/src/client/addresses-data/index.js @@ -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) + ); + } + }; + } }; diff --git a/@salix/crud/src/client/fiscal-data/index.html b/@salix/crud/src/client/fiscal-data/index.html index 47e2112b9..b677d9c0e 100644 --- a/@salix/crud/src/client/fiscal-data/index.html +++ b/@salix/crud/src/client/fiscal-data/index.html @@ -14,10 +14,11 @@ - + + + - - + @@ -31,7 +32,9 @@ Información de facturación - + + + diff --git a/@salix/crud/src/client/fiscal-data/index.js b/@salix/crud/src/client/fiscal-data/index.js index 7a84011b3..893b08ceb 100644 --- a/@salix/crud/src/client/fiscal-data/index.js +++ b/@salix/crud/src/client/fiscal-data/index.js @@ -9,6 +9,21 @@ export const COMPONENT = { client: '<' }, 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() { $http.put('/client/api/Clients', this.client).then( json => console.log(json.statusText), diff --git a/db.json b/db.json index f426a96ee..8cd96700a 100644 --- a/db.json +++ b/db.json @@ -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\"}", diff --git a/services/client/common/models/Address.json b/services/client/common/models/Address.json index 27e395ebc..8d4cb3327 100644 --- a/services/client/common/models/Address.json +++ b/services/client/common/models/Address.json @@ -30,9 +30,11 @@ }, "mobile": { "type": "string" - } - }, - "relations": { + }, + "default": { + "type": "boolean" + }, + "relations": { "agency": { "type": "belongsTo", "model": "Agency", @@ -49,4 +51,5 @@ "foreignKey": "provinceId" } } + } } diff --git a/services/client/common/models/Client.json b/services/client/common/models/Client.json index a965ffd4a..e76911c2f 100644 --- a/services/client/common/models/Client.json +++ b/services/client/common/models/Client.json @@ -94,6 +94,16 @@ "type": "belongsTo", "model": "PaymentMethod", "foreingKey": "payId" + }, + "country":{ + "type": "belongsTo", + "model": "Country", + "foreignKey": "countryId" + }, + "province":{ + "type": "belongsTo", + "model": "Province", + "foreignKey": "provinceId" } } }