From ae3f9db94807fa4f551ec61659fe03fb0ceb5107 Mon Sep 17 00:00:00 2001 From: nelo Date: Wed, 17 May 2017 08:19:03 +0200 Subject: [PATCH 1/3] =?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/3] =?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 From a7bfd5122a8de379e48815874df6aff813498df4 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 17 May 2017 12:07:42 +0200 Subject: [PATCH 3/3] Errores gulp solucionados --- client/client/{routes.js => routes.json} | 0 gulpfile.js | 30 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) rename client/client/{routes.js => routes.json} (100%) diff --git a/client/client/routes.js b/client/client/routes.json similarity index 100% rename from client/client/routes.js rename to client/client/routes.json diff --git a/gulpfile.js b/gulpfile.js index 4213707abf..99d9bcc166 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -40,7 +40,7 @@ gulp.task('clean', function() { var splitingFiles = './spliting/*'; -gulp.task('spliting', function() { +gulp.task('spliting', function(cb) { var importTpl = fs.readFileSync('./spliting/import.tpl.js', 'utf8'); var requireTpl = fs.readFileSync('./spliting/require.tpl.js', 'utf8'); @@ -55,27 +55,28 @@ gulp.task('spliting', function() { fs.appendFileSync(splitFile, importTpl); var i = deps.length; - while (i--) { + while (i--) fs.appendFileSync(splitFile, requireTpl.replace(/\$module/g, deps[i])); - } } + + cb(); }); // Webpack -gulp.task('webpack', ['spliting'], function(callback) { +gulp.task('webpack', ['spliting'], function(cb) { var configCopy = Object.create(webpackConfig); var compiler = webpack(configCopy); compiler.run(function(err, stats) { if (err) throw new gutil.PluginError('webpack', err); gutil.log('[webpack]', stats.toString({colors: true})); - callback(); + cb(); }); }); -gulp.task('webpack-dev-server', ['spliting'], function(callback) { +gulp.task('webpack-dev-server', ['spliting'], function() { var configCopy = Object.create(webpackConfig); for (var entry in configCopy.entry) { @@ -124,23 +125,22 @@ gulp.task('locales', function() { // Routes -var routeFiles = `./${srcDir}/**/routes.js`; +var routeFiles = `./${srcDir}/**/routes.json`; gulp.task('routes', function() { - var fileTpl = '\n"<%=dirname%>": <%=contents%>'; - var globalTpl = 'var routes = {<%=contents%>\n}'; - var regex = new RegExp('^(.*)/routes\.js$'); - function cb(file) { var relative = file.relative.replace(/\\/g, '/'); - var dirname = relative.match(regex)[1]; - return {dirname: dirname}; + var dirname = relative.match(/^(.*)\/routes\.json$/)[1]; + return { + dirname: dirname, + json: file.contents + }; } return gulp.src(routeFiles) - .pipe(wrap(fileTpl, cb)) + .pipe(wrap('\n"<%=dirname%>": <%=json%>', cb)) .pipe(concat('routes.js', {newLine: ','})) - .pipe(wrap(globalTpl)) + .pipe(wrap('var routes = {<%=contents%>\n};')) .pipe(gulp.dest(buildDir)); });