From ae3f9db94807fa4f551ec61659fe03fb0ceb5107 Mon Sep 17 00:00:00 2001 From: nelo Date: Wed, 17 May 2017 08:19:03 +0200 Subject: [PATCH 1/2] =?UTF-8?q?VnAutocomplete=20ya=20no=20carga=20los=20da?= =?UTF-8?q?tos=20cuando=20los=20datos=20se=20pueden=20bandera.=20Creado=20?= =?UTF-8?q?el=20m=C3=A9todo=20card=20en=20client=20para=20listar=20el=20cl?= =?UTF-8?q?iente=20con=20sus=20datos=20para=20el=20combo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client/src/basic-data/index.html | 2 ++ client/client/src/card/index.js | 2 +- client/client/src/fiscal-data/index.html | 3 ++ client/core/src/autocomplete/index.js | 22 +++++++++--- services/client/common/models/Client.js | 5 +-- services/client/common/models/Client.json | 11 ++---- services/client/common/scopes/card.js | 39 ++++++++++++++++++++ services/client/common/scopes/card.json | 43 +++++++++++++++++++++++ 8 files changed, 110 insertions(+), 17 deletions(-) create mode 100644 services/client/common/scopes/card.js create mode 100644 services/client/common/scopes/card.json diff --git a/client/client/src/basic-data/index.html b/client/client/src/basic-data/index.html index 8e089af4b6..9fad9255b6 100644 --- a/client/client/src/basic-data/index.html +++ b/client/client/src/basic-data/index.html @@ -22,6 +22,7 @@ this.client = json.data ); diff --git a/client/client/src/fiscal-data/index.html b/client/client/src/fiscal-data/index.html index acd389825a..8e74ad5712 100644 --- a/client/client/src/fiscal-data/index.html +++ b/client/client/src/fiscal-data/index.html @@ -20,6 +20,7 @@ Date: Wed, 17 May 2017 09:45:34 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Correcci=C3=B3n=20error=20autocomplete=20Se?= =?UTF-8?q?parado=20meted=20activate=20Separado=20meted=20addresses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/core/src/autocomplete/index.js | 6 -- services/client/common/models/Client.js | 83 +------------------ .../client/common/scopes/client/activate.js | 29 +++++++ .../client/common/scopes/client/addresses.js | 49 +++++++++++ .../client/common/scopes/{ => client}/card.js | 0 .../common/scopes/{ => client}/card.json | 0 6 files changed, 81 insertions(+), 86 deletions(-) create mode 100644 services/client/common/scopes/client/activate.js create mode 100644 services/client/common/scopes/client/addresses.js rename services/client/common/scopes/{ => client}/card.js (100%) rename services/client/common/scopes/{ => client}/card.json (100%) diff --git a/client/core/src/autocomplete/index.js b/client/core/src/autocomplete/index.js index 24db75bb2c..422db8d420 100644 --- a/client/core/src/autocomplete/index.js +++ b/client/core/src/autocomplete/index.js @@ -344,12 +344,6 @@ export default class Autocomplete extends Component { this.item = item; this.mdlUpdate(); } - $onChanges(changes) { - if (!changes.initialValue) - this.requestItem(); - else - this.showItem(changes.initialValue); - } } Autocomplete.$inject = ['$element', '$scope', '$http', 'vnPopover']; diff --git a/services/client/common/models/Client.js b/services/client/common/models/Client.js index b7ad468d8a..a4bd9a6516 100644 --- a/services/client/common/models/Client.js +++ b/services/client/common/models/Client.js @@ -1,6 +1,8 @@ module.exports = function(Client) { - require("../scopes/card.js")(Client); + require("../scopes/client/card.js")(Client); + require("../scopes/client/activate.js")(Client); + require("../scopes/client/addresses.js")(Client); // Validations Client.validatesUniquenessOf('name', {message: 'El nombre debe ser único'}); @@ -43,36 +45,6 @@ module.exports = function(Client) { } }); - // Methods - - Client.remoteMethod('activate', { - description: 'Activate or deactive client', - accepts: { - arg: 'id', - type: 'number', - required: true, - description: 'Model id', - http: {source: 'path'} - }, - returns: { - arg: 'active', - type: 'boolean' - }, - http: { - verb: 'put', - path: '/:id/activate' - } - }); - - Client.activate = function(id, cb) { - console.log(id); - Client.findById(id, function(err, client) { - if(!err) { - Client.update({id: client.id}, {active: !client.active}); - cb(null, !client.active); - } - }); - }; // Basic filter @@ -94,53 +66,4 @@ module.exports = function(Client) { }; } - // Client addresses - - Client.remoteMethod('addressesList', { - description: 'List items using a filter', - accessType: 'READ', - accepts: [ - { - arg: 'id', - type: 'string', - required: true, - description: 'Model id', - http: {source: 'path'} - }, - { - arg: 'filter', - type: 'object', - required: true, - description: 'Filter defining where', - http: function(ctx) { - return ctx.req.query; - } - } - ], - returns: { - arg: 'data', - type: ['Address'], - root: true - }, - http: { - path: `/:id/addressesList`, - verb: 'get' - } - }); - - Client.addressesList = function(id, p, cb) { - let filter = { - where: { - clientFk: id, - }, - skip: (p.page - 1) * p.size, - limit: p.size - }; - - Client.app.models.Address.find(filter, function(err, instances) { - if(!err) { - cb(null, instances); - } - }) - }; }; \ No newline at end of file diff --git a/services/client/common/scopes/client/activate.js b/services/client/common/scopes/client/activate.js new file mode 100644 index 0000000000..c3d0ff451e --- /dev/null +++ b/services/client/common/scopes/client/activate.js @@ -0,0 +1,29 @@ +module.exports = function(Client){ + Client.remoteMethod('activate', { + description: 'Activate or deactive client', + accepts: { + arg: 'id', + type: 'number', + required: true, + description: 'Model id', + http: {source: 'path'} + }, + returns: { + arg: 'active', + type: 'boolean' + }, + http: { + verb: 'put', + path: '/:id/activate' + } + }); + + Client.activate = function(id, cb) { + Client.findById(id, function(err, client) { + if(!err) { + Client.update({id: client.id}, {active: !client.active}); + cb(null, !client.active); + } + }); + }; +}; \ No newline at end of file diff --git a/services/client/common/scopes/client/addresses.js b/services/client/common/scopes/client/addresses.js new file mode 100644 index 0000000000..d050d52387 --- /dev/null +++ b/services/client/common/scopes/client/addresses.js @@ -0,0 +1,49 @@ +module.exports = function(Client){ + Client.remoteMethod('addressesList', { + description: 'List items using a filter', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'string', + required: true, + description: 'Model id', + http: {source: 'path'} + }, + { + arg: 'filter', + type: 'object', + required: true, + description: 'Filter defining where', + http: function(ctx) { + return ctx.req.query; + } + } + ], + returns: { + arg: 'data', + type: ['Address'], + root: true + }, + http: { + path: `/:id/addressesList`, + verb: 'get' + } + }); + + Client.addressesList = function(id, p, cb) { + let filter = { + where: { + clientFk: id, + }, + skip: (p.page - 1) * p.size, + limit: p.size + }; + + Client.app.models.Address.find(filter, function(err, instances) { + if(!err) { + cb(null, instances); + } + }) + }; +} \ No newline at end of file diff --git a/services/client/common/scopes/card.js b/services/client/common/scopes/client/card.js similarity index 100% rename from services/client/common/scopes/card.js rename to services/client/common/scopes/client/card.js diff --git a/services/client/common/scopes/card.json b/services/client/common/scopes/client/card.json similarity index 100% rename from services/client/common/scopes/card.json rename to services/client/common/scopes/client/card.json