From 102c344859fdb833d5d244b4794312f3eb4ede8a Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 17 Jan 2017 13:02:35 +0100 Subject: [PATCH] =?UTF-8?q?dialog-confirm=20y=20acceso-Web=20dialog-confir?= =?UTF-8?q?m=20ahora=20es=20generico=20y=20se=20ha=20a=C3=B1adido=20la=20e?= =?UTF-8?q?ntidad=20account?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- @salix/crud/src/client/basic-data/index.html | 2 +- @salix/crud/src/client/basic-data/index.js | 3 +- @salix/crud/src/client/confirm/index.html | 4 +-- @salix/crud/src/client/confirm/index.js | 23 +++++++------ @salix/crud/src/client/fiscal-data/index.html | 2 +- @salix/crud/src/client/fiscal-data/index.js | 7 ++-- @salix/crud/src/client/index/index.js | 21 ++++++------ @salix/crud/src/client/web-access/index.html | 8 ++--- @salix/crud/src/client/web-access/index.js | 33 ++++++++++++------- db.json | 7 +++- services/client/common/models/account.json | 2 +- services/client/server/model-config.json | 4 +++ 12 files changed, 66 insertions(+), 50 deletions(-) diff --git a/@salix/crud/src/client/basic-data/index.html b/@salix/crud/src/client/basic-data/index.html index b9105cfdf..7d3f06b6a 100644 --- a/@salix/crud/src/client/basic-data/index.html +++ b/@salix/crud/src/client/basic-data/index.html @@ -26,4 +26,4 @@ - + diff --git a/@salix/crud/src/client/basic-data/index.js b/@salix/crud/src/client/basic-data/index.js index 64f2a5cc7..3481c7436 100644 --- a/@salix/crud/src/client/basic-data/index.js +++ b/@salix/crud/src/client/basic-data/index.js @@ -9,8 +9,7 @@ export const COMPONENT = { client: '<' }, controller: function($http, copyObject, equalsObject, $transitions, $element) { - - var self = this; + var self = this; var deregister = $transitions.onStart({ }, callback); this.$onChanges = function(changes) { diff --git a/@salix/crud/src/client/confirm/index.html b/@salix/crud/src/client/confirm/index.html index cb48b6324..54202679e 100644 --- a/@salix/crud/src/client/confirm/index.html +++ b/@salix/crud/src/client/confirm/index.html @@ -5,7 +5,7 @@

- - + +
\ No newline at end of file diff --git a/@salix/crud/src/client/confirm/index.js b/@salix/crud/src/client/confirm/index.js index 5d4c2615c..f9c3400bb 100644 --- a/@salix/crud/src/client/confirm/index.js +++ b/@salix/crud/src/client/confirm/index.js @@ -1,28 +1,27 @@ import template from './index.html'; import {module} from '../../module'; -export const NAME = 'vnConfirmClient'; +export const NAME = 'vnDialogConfirm'; export const COMPONENT = { template: template, - controllerAs: 'clientConfirm', + controllerAs: 'dialogConfirm', bindings: { state: '<', - client: '=', - clientOld: "=" + object: '=', + objectOld: "=" }, - controller: function($state, $element, copyObject){ - - var dialog = $element.find('dialog')[0] + controller: function($state, $element, copyObject) { + var dialog = $element.find('dialog')[0]; - this.accept = function(){ - copyObject(this.clientOld, this.client); + this.accept = function() { + copyObject(this.objectOld, this.object); $state.go(this.state); dialog.close(); - } + }; - this.cancel = function(){ + this.cancel = function() { dialog.close(); - } + }; } }; COMPONENT.controller.$inject = ['$state', '$element', 'copyObject']; diff --git a/@salix/crud/src/client/fiscal-data/index.html b/@salix/crud/src/client/fiscal-data/index.html index 11b7f3949..d7008b4de 100644 --- a/@salix/crud/src/client/fiscal-data/index.html +++ b/@salix/crud/src/client/fiscal-data/index.html @@ -60,4 +60,4 @@ - + diff --git a/@salix/crud/src/client/fiscal-data/index.js b/@salix/crud/src/client/fiscal-data/index.js index bccda409d..401c22d97 100644 --- a/@salix/crud/src/client/fiscal-data/index.js +++ b/@salix/crud/src/client/fiscal-data/index.js @@ -9,14 +9,13 @@ export const COMPONENT = { client: '<' }, controller: function($http, copyObject, equalsObject, $transitions, $element) { - var self = this; var deregister = $transitions.onStart({ }, callback); - + $http.get('/client/api/Countries').then( json => this.countries = json.data ); - + $http.get('/client/api/Provinces').then( json => this.provinces = json.data ); @@ -24,7 +23,7 @@ export const COMPONENT = { $http.get('/client/api/PaymentMethods').then( json => this.payments = json.data ); - + this.submit = function() { if (!equalsObject(this.client, this.clientOld)) { this.client.modify = "FiscalData"; diff --git a/@salix/crud/src/client/index/index.js b/@salix/crud/src/client/index/index.js index d62cb27cf..3830a3e37 100644 --- a/@salix/crud/src/client/index/index.js +++ b/@salix/crud/src/client/index/index.js @@ -12,13 +12,12 @@ export const COMPONENT = { var where = null; var filter = this.filter; var queryStr = '/client/api/Clients'; - var search = filter.search; - if(search) + if (search) where = {name: {ilike: search}}; var params = filter.params; - if(params) { + if (params) { where = {}; let partials = { alias: true, @@ -26,18 +25,18 @@ export const COMPONENT = { socialName: true, city: true, email: true - } - for(let param in params) - if (params[param]) { - if(partials[param]) - where[param] = {ilike: params[param]}; - else + }; + for (let param in params) + if (params[param]) { + if (partials[param]) + where[param] = {ilike: params[param]}; + else where[param] = params[param]; - } + } filter.params = undefined; } - if(where) { + if (where) { let json = JSON.stringify({where: where}); queryStr = `${queryStr}?filter=${json}`; } diff --git a/@salix/crud/src/client/web-access/index.html b/@salix/crud/src/client/web-access/index.html index 540ee47e7..b8dae30c3 100644 --- a/@salix/crud/src/client/web-access/index.html +++ b/@salix/crud/src/client/web-access/index.html @@ -2,12 +2,12 @@ Acceso Web - - + + - + - + diff --git a/@salix/crud/src/client/web-access/index.js b/@salix/crud/src/client/web-access/index.js index b123c888d..de7d2216e 100644 --- a/@salix/crud/src/client/web-access/index.js +++ b/@salix/crud/src/client/web-access/index.js @@ -9,17 +9,16 @@ export const COMPONENT = { client: '<' }, controller: function($http, copyObject, equalsObject, $transitions, $element) { - var self = this; var deregister = $transitions.onStart({ }, callback); - + this.submit = function() { - if (!equalsObject(this.client, this.clientOld)) { + if (!equalsObject(this.account, this.accountOld)) { this.client.modify = "WebAccess"; - $http.put('/client/api/Clients', this.client).then( + $http.put(`/client/api/Accounts/${this.account.id}`, this.account).then( json => { - this.client = json.data; - this.copyClient(); + this.account = json.data; + self.copyAccount(); } ); } @@ -27,7 +26,7 @@ export const COMPONENT = { this.$onChanges = function(changes) { if (this.client) { - this.copyClient(); + this.getAccount(this.client.id); } }; @@ -36,7 +35,7 @@ export const COMPONENT = { }; function callback(transition) { - if (!equalsObject(self.client, self.clientOld)) { + if (!equalsObject(self.account, self.accountOld)) { self.state = transition.to().name; var dialog = $element[0].querySelector('dialog'); dialog.showModal(); @@ -44,9 +43,21 @@ export const COMPONENT = { } } - this.copyClient = function() { - this.clientOld = {}; - copyObject(this.client, this.clientOld); + this.copyAccount = function() { + this.accountOld = {}; + copyObject(this.account, this.accountOld); + }; + + this.getAccount = function(clientId) { + $http.get(`/client/api/Accounts/${clientId}`).then( + json => { + this.account = json.data; + this.copyAccount(); + }, + json => { + this.account = {id: clientId}; + } + ); }; } }; diff --git a/db.json b/db.json index 4e3bc286f..67d09dd6b 100644 --- a/db.json +++ b/db.json @@ -8,7 +8,8 @@ "Address": 58, "Country": 3, "Province": 3, - "Agency": 4 + "Agency": 4, + "Account": 14 }, "models": { "User": { @@ -49,6 +50,10 @@ "1": "{\"name\":\"Zeleris\",\"id\":1}", "2": "{\"name\":\"MRW\",\"id\":2}", "3": "{\"name\":\"DHL\",\"id\":3}" + }, + "Account": { + "12": "{\"id\":12,\"name\":\"prueba12\",\"active\":false,\"user\":\"juanete\"}", + "13": "{\"id\":13,\"name\":\"manu\",\"active\":false,\"user\":\"joselito\"}" } } } \ No newline at end of file diff --git a/services/client/common/models/account.json b/services/client/common/models/account.json index 8a18abc75..af3254ad9 100644 --- a/services/client/common/models/account.json +++ b/services/client/common/models/account.json @@ -1,5 +1,5 @@ { - "name": "account", + "name": "Account", "base": "PersistedModel", "properties": { "id": { diff --git a/services/client/server/model-config.json b/services/client/server/model-config.json index cdeb2a719..30d28228c 100644 --- a/services/client/server/model-config.json +++ b/services/client/server/model-config.json @@ -63,5 +63,9 @@ "ClientObservation": { "dataSource": "db", "public": true + }, + "Account": { + "dataSource": "db", + "public": true } } \ No newline at end of file