diff --git a/client/core/src/watcher/index.js b/client/core/src/watcher/index.js index cadbd98f8..b6120d3bb 100644 --- a/client/core/src/watcher/index.js +++ b/client/core/src/watcher/index.js @@ -40,11 +40,7 @@ export default class Watcher extends Component { let id = this.data[this.idField]; return new Promise((resolve, reject) => { this.$http.get(`${this.url}/${id}`).then( - json => { - copyObject(json.data, this.data); - this.copyData(); - resolve(json); - }, + json => this.writeData(json, resolve), json => reject(json) ); }); @@ -59,13 +55,10 @@ export default class Watcher extends Component { let changedData = getModifiedData(this.data, this.orgData); if(id) { + console.log(changedData); return new Promise((resolve, reject) => { this.$http.put(`${this.url}/${id}`, changedData).then( - json => { - this.data = json.data; - this.copyData(); - resolve(json); - }, + json => this.writeData(json, resolve), json => reject(json) ); }); @@ -73,19 +66,19 @@ export default class Watcher extends Component { else { return new Promise((resolve, reject) => { this.$http.post(this.url, this.data).then( - json => { - this.data = json.data; - copyObject(this.data, this.orgData); - resolve(json); - }, + json => this.writeData(json, resolve), json => reject(json) ); }); } } + writeData(json, resolve) { + copyObject(json.data, this.data); + this.copyData(); + resolve(json); + } copyData() { - this.orgData = {}; - copyObject(this.data, this.orgData); + this.orgData = copyObject(this.data); } callback(transition) { if (!this.state && this.dataChanged()) { diff --git a/db.json b/db.json index 02c2c54af..0cf642367 100644 --- a/db.json +++ b/db.json @@ -2,7 +2,7 @@ "ids": { "User": 2, "AccessToken": 2, - "Client": 21, + "Client": 20, "PaymentMethod": 4, "SalesPerson": 11, "Address": 83, @@ -20,12 +20,11 @@ "NUf7o684TmteojFX9KmPOpaDLthjP5Def4wuy83Yjv31i43HHiWgV3FyBp6pX8Ue": "{\"id\":\"NUf7o684TmteojFX9KmPOpaDLthjP5Def4wuy83Yjv31i43HHiWgV3FyBp6pX8Ue\",\"ttl\":1209600,\"created\":\"2016-11-21T11:06:11.113Z\",\"userId\":1}" }, "Client": { - "12": "{\"name\":\"Verdnatura\",\"id\":12,\"fi\":\"B97367486\",\"salesPerson\":6,\"telefono\":\"963242100\",\"socialName\":\"Verdnatura Levante SL\",\"active\":true,\"user\":\"verdnatura\",\"fax\":\"963242100\",\"phone\":\"963242101\",\"email\":\"informatica@verdnatura.es\",\"surcharge\":true,\"cyc\":321,\"credit\":1000,\"iban\":\"456\",\"street\":\"Avenida Espioca, 100\",\"city\":\"Silla\",\"postcode\":\"12345678\",\"mobile\":\"654654654\",\"dueDay\":321,\"gestdoc\":23452343,\"province\":1,\"country\":1,\"modify\":\"BasicData\",\"navigate\":true,\"payMethod\":\"1\",\"coreVnh\":true,\"coreVnl\":true,\"invoiceByEmail\":true}", - "14": "{\"name\":\"Cliente 1\",\"id\":14,\"street\":\"Aaaaaaaaaa\",\"fi\":\"1234567890A\",\"socialName\":\"Cliente 1\",\"fax\":\"963242100\",\"dischargeDate\":\"01/01/2017\",\"telefono\":\"963242100\",\"salesPerson\":\"2\",\"email\":\"informatica@verdnatura.es\",\"city\":\"asdf\",\"postcode\":\"asdf\",\"phone\":\"asdf\",\"mobile\":\"asdf\",\"credit\":2345,\"cyc\":56,\"iban\":\"asdf\",\"dueDay\":345,\"gestdoc\":2435,\"surcharge\":true,\"navigate\":true}", + "12": "{\"name\":\"Verdnatura\",\"id\":12,\"fi\":\"B97367486\",\"salesPerson\":3,\"telefono\":\"963242100\",\"socialName\":\"Verdnatura Levante SL\",\"active\":true,\"user\":\"verdnatura\",\"fax\":\"963242100\",\"phone\":\"963242101\",\"email\":\"informatica@verdnatura.es\",\"surcharge\":true,\"cyc\":321,\"credit\":1000,\"iban\":\"456\",\"street\":\"Avenida Espioca, 100\",\"city\":\"Silla\",\"postcode\":\"12345678\",\"mobile\":\"654654654\",\"dueDay\":321,\"gestdoc\":23452343,\"province\":1,\"country\":1,\"modify\":\"BasicData\",\"navigate\":true,\"payMethod\":\"1\",\"coreVnh\":true,\"coreVnl\":true,\"invoiceByEmail\":true}", + "14": "{\"name\":\"Leopoldo\",\"id\":14,\"street\":\"Casa\",\"fi\":\"1234567890A\",\"socialName\":\"Leopoldo\",\"fax\":\"963242100\",\"dischargeDate\":\"01/01/2017\",\"telefono\":\"963242100\",\"salesPerson\":\"2\",\"email\":\"informatica@verdnatura.es\",\"city\":\"asdf\",\"postcode\":\"123\",\"phone\":\"963215469\",\"mobile\":\"667985632\",\"credit\":2345,\"cyc\":56,\"iban\":\"asdf\",\"dueDay\":345,\"gestdoc\":2435,\"surcharge\":true,\"navigate\":true,\"province\":6,\"country\":2}", "15": "{\"name\":\"Florsiteria Pepa\",\"fi\":\"12341234rasf\",\"socialName\":\"asdfasd\",\"dueDay\":5,\"id\":15,\"payMethod\":\"2\",\"salesPerson\":\"1\",\"modify\":\"BasicData\",\"iban\":\"sdfgsdfgsdfg\",\"email\":\"pepa@flores.es\"}", "16": "{\"name\":\"Floristeria Antonieta\",\"fi\":\"2345234523d\",\"socialName\":\"23452345assdfgsdfgt\",\"active\":true,\"dueDay\":5,\"id\":16,\"modify\":\"FiscalData\",\"email\":\"antonieta@gmail.com\",\"phone\":\"654654654\",\"mobile\":\"654456456\",\"fax\":\"456456456\",\"street\":\"asdfasdf\",\"salesPerson\":8}", - "19": "{\"name\":\"Planticas Eustaquio\",\"fi\":\"789456123B\",\"socialName\":\"Eustaquio Martinez\",\"active\":true,\"dueDay\":5,\"id\":19,\"email\":\"peustaquio@hotmail.es\"}", - "20": "{\"name\":\"Vicente Falco\",\"fi\":\"73773536R\",\"socialName\":\"vicente falco\",\"active\":true,\"dueDay\":5,\"id\":20,\"phone\":\"963258073\",\"mobile\":\"636898196\",\"fax\":\"636898196\",\"email\":\"vicente.falco@gmail.com\"}" + "19": "{\"name\":\"Planticas Eustaquio\",\"fi\":\"789456123B\",\"socialName\":\"Eustaquio Martinez\",\"active\":true,\"dueDay\":5,\"id\":19,\"email\":\"peustaquio@hotmail.es\"}" }, "PaymentMethod": { "1": "{\"name\":\"Tarjeta\",\"id\":1}", diff --git a/services/client/common/models/Client.json b/services/client/common/models/Client.json index 7021b82a6..f5a9d2b1f 100644 --- a/services/client/common/models/Client.json +++ b/services/client/common/models/Client.json @@ -6,11 +6,7 @@ "id": { "type": "Number", "id": true, - "description": "Identifier", - "validation": { - "unique": true, - "exportable": false - } + "description": "Identifier" }, "name": { "type": "string", @@ -92,6 +88,11 @@ "foreignKey": "id" } }, + "scopes": { + "test": { + "where": {"name": "Verdnatura"} + } + }, "acls": [], "methods": {} }