dirección por defecto.
This commit is contained in:
parent
87dda33a20
commit
afe2d1ea79
|
@ -20,25 +20,25 @@ module.exports = function(Address) {
|
|||
Address.beforeRemote('prototype.updateAttributes',function(ctx, modelInstance, next){
|
||||
var data = ctx.req.body;
|
||||
data.id = ctx.req.params.id;
|
||||
update(ctx, data, next);
|
||||
getAddress(ctx, data, next);
|
||||
});
|
||||
|
||||
function update(ctx, data, next){
|
||||
var address = Address.findOne( {filter: { where: { id: data.id}}}, function (err, address){
|
||||
function getAddress(ctx, data, next){
|
||||
var address = Address.findOne( {where: { id: data.id}}, function (err, address){
|
||||
if(address)
|
||||
callbackGetAddress(ctx, data, address, next)
|
||||
else
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
function callbackGetAddress(ctx, data, address, next){
|
||||
if (data.default){
|
||||
removeAllDefault(ctx, address.client);
|
||||
removeAllDefault(address.client);
|
||||
next();
|
||||
}
|
||||
else
|
||||
else if (address.default && !data.default)
|
||||
next(generateErrorDefaultAddress());
|
||||
else
|
||||
next();
|
||||
}
|
||||
|
||||
function getData(ctx){
|
||||
|
|
Loading…
Reference in New Issue