From 95236916e00b19464a3dfe3584ef1b18da9ffb25 Mon Sep 17 00:00:00 2001 From: ncuillery Date: Tue, 3 Jun 2014 19:14:19 +0200 Subject: [PATCH] fix(sample): prevent direct URL access to a day disabled in the datepicker Redirection from `booking.day` to `booking` if the date has no reservation. Closes: #17 --- sample/controllers/booking_day.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sample/controllers/booking_day.js b/sample/controllers/booking_day.js index 3aa310e..a4ab2ce 100644 --- a/sample/controllers/booking_day.js +++ b/sample/controllers/booking_day.js @@ -1,7 +1,11 @@ angular.module('ncy-sample') - .controller('BookingDayCtrl', function($scope, $rootScope, $stateParams, rooms) { + .controller('BookingDayCtrl', function($scope, $rootScope, $state, $stateParams, rooms) { $rootScope.reservationDate = new Date($stateParams.year, $stateParams.month - 1, $stateParams.day); + if(!$scope.between($rootScope.reservationDate).length) { + $state.go('^'); + } + $scope.getRoom = function(id) { return _.findWhere(rooms, {roomId: parseInt(id)}); }