From 020bb38873ed3d49df4db91265db7630fe577323 Mon Sep 17 00:00:00 2001 From: nelo Date: Tue, 10 Jan 2017 14:41:56 +0100 Subject: [PATCH] arreglo vicente --- .../crud/src/client/addresses-data/index.html | 15 ++++++----- .../crud/src/client/addresses-data/index.js | 25 ++++++++++++------- db.json | 9 +++---- services/client/common/models/Address.json | 9 ++++--- 4 files changed, 32 insertions(+), 26 deletions(-) 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/db.json b/db.json index 68cf05a8a..db23d85b4 100644 --- a/db.json +++ b/db.json @@ -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\"}", 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" } } + } }