From b9c0745b73fd8bf0415f5a74da60b7e05b0830ae Mon Sep 17 00:00:00 2001 From: nelo Date: Mon, 23 Jan 2017 10:56:12 +0100 Subject: [PATCH] modifcaciones direcciones --- @salix/app/src/run.js | 15 ++++++-- services/client/common/models/Address.js | 45 ++---------------------- 2 files changed, 15 insertions(+), 45 deletions(-) diff --git a/@salix/app/src/run.js b/@salix/app/src/run.js index 997e30790..a91dcca5d 100644 --- a/@salix/app/src/run.js +++ b/@salix/app/src/run.js @@ -1,7 +1,16 @@ import {module} from './module'; -run.$inject = ['$rootScope']; -export function run ($rootScope) { - $rootScope.$on('$viewContentLoaded', () => {}) +const HOOK_ABORTED_TRANSITION = 3; + +run.$inject = ['$rootScope', '$state']; +export function run ($rootScope, $state) { + $rootScope.$on('$viewContentLoaded', () => {}); + window.myAppErrorLog = []; + $state.defaultErrorHandler(function(error) { + if (error.type === HOOK_ABORTED_TRANSITION) + window.myAppErrorLog.push(error); + }); } module.run(run); + + diff --git a/services/client/common/models/Address.js b/services/client/common/models/Address.js index 6436305fb..75ef213ba 100644 --- a/services/client/common/models/Address.js +++ b/services/client/common/models/Address.js @@ -7,23 +7,10 @@ module.exports = function(Address) { Address.observe('before save', function (ctx, next) { var data = getData(ctx); - var address = Address.findOne( getFilterAddress(data), function (err, address){ - if(address){ - var id = address.id; - } - - if (data.enabled && data.default) { - ctx.Model.update({client: data.client}, {default: false}); - } - - next(); - }); - - if(!data.default && isDefaultAddress(ctx, data)){ - next(generateErrorDefaultAddress()); + if (data.enabled && data.default) { + ctx.Model.update({client: data.client}, {default: false}); } - - + next(); }); function getData(ctx){ @@ -33,30 +20,4 @@ module.exports = function(Address) { return ctx.instance; } - function generateErrorDefaultAddress(){ - var error = new Error(); - error.message = "No se puede desmarcar el consignatario predeterminado"; - error.status = 500; - return error; - } - - function isDefaultAddress(ctx, data){ - - } - - function getFilterAddress(data){ - var filter = { - filter: { - where: { - and: [ - {client: data.client}, - {default: true} - ] - } - } - } - - return filter; - } - }; \ No newline at end of file