UNPKG

cobuild-angular-stack

Version:

Base stack angular sass jade gulp

88 lines (84 loc) 3.17 kB
(function () { 'use strict'; loadCouple.$inject = ['CoupleAccount', '$stateParams', '$q', '$rootScope', '$translate', 'toastr', '$state']; function loadCouple(CoupleAccount, $stateParams, $q, $rootScope, $translate, toastr, $state) { var lastCoupleLoaded = $rootScope.lastCoupleLoaded; if (lastCoupleLoaded && lastCoupleLoaded.url === $stateParams.url) { return $q.resolve(lastCoupleLoaded); } if ($stateParams.couple) { $rootScope.lastCoupleLoaded = $stateParams.couple; return $q.resolve($stateParams.couple) } return CoupleAccount .findOne({ filter: { where: { or:[{url : $stateParams.url}, {url:$stateParams.url.toLowerCase()}], "isDisabled":false,"payInformationData.isPaid": true,"isActive":true, tempAccount: {neq:true} } } }) .$promise .then(function (couple) { $rootScope.lastCoupleLoaded = couple; return couple; }) .catch(function (err) { if (err.status === 404) { $translate('error-couple-invitation').then(function (translation) { toastr.error(translation); }); $state.go('home'); } return $q.reject; }); } config.$inject = ['$stateProvider']; function config($stateProvider) { $stateProvider .state('fakeguest', { templateUrl: "partials/guest.main-new.html", controller: 'GuestMainController', controllerAs: 'gmCtrl', params: { url: null }, data: { requireLogin: false }, resolve: { account: loadCouple } }) .state('guest', { url: "/boda/:url", templateUrl: "partials/guest.main-new.html", controller: 'GuestMainController', controllerAs: 'gmCtrl', params: { couple: null }, data: { requireLogin: false }, resolve: { account: loadCouple } }) .state('search_table', { url: "/mesas-de-regalos/:criteria", templateUrl: "partials/guest.search.html", controller: 'GuestSearchController', data: { requireLogin: false, title: 'Uniko | Mesas de regalos', description: 'Mira las mesas de los novios que ya están cambiando el concepto de la mesa de regalos' + ' y al final obtendrán todo el dinero en efectivo.' } }); } angular.module('uniko.guest') .config(config); })();