Corrección error autocomplete

Separado meted activate
Separado meted addresses
This commit is contained in:
nelo 2017-05-17 09:45:34 +02:00
parent ae3f9db948
commit e4559c3959
6 changed files with 81 additions and 86 deletions

View File

@ -344,12 +344,6 @@ export default class Autocomplete extends Component {
this.item = item; this.item = item;
this.mdlUpdate(); this.mdlUpdate();
} }
$onChanges(changes) {
if (!changes.initialValue)
this.requestItem();
else
this.showItem(changes.initialValue);
}
} }
Autocomplete.$inject = ['$element', '$scope', '$http', 'vnPopover']; Autocomplete.$inject = ['$element', '$scope', '$http', 'vnPopover'];

View File

@ -1,6 +1,8 @@
module.exports = function(Client) { 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 // Validations
Client.validatesUniquenessOf('name', {message: 'El nombre debe ser único'}); 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 // 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);
}
})
};
}; };

View File

@ -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);
}
});
};
};

View File

@ -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);
}
})
};
}