partial #1801
This commit is contained in:
parent
cf49c83622
commit
5ea22a8dda
@ -29,7 +29,7 @@
|
||||
<h3 class="meal-food">{{restaurant._short_description}}</h3>
|
||||
<div ng-switch on="restaurant._tag">
|
||||
<div class="meal-item-tag" ng-switch-when="takeout">Take out only</div>
|
||||
<div class="meal-item-tag about-to-close" ng-switch-when="closing">Hurry, closes in {{restaurant.isAboutToClose()}} min!</div>
|
||||
<div class="meal-item-tag about-to-close" ng-switch-when="closing">Hurry, closes in {{restaurant._minToClose}} min!</div>
|
||||
<div class="meal-item-tag-closed" ng-switch-when="closed">Opens in a few hours</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -90,7 +90,7 @@ NGApp.controller('DefaultCtrl', function ($scope, $http, $location, CommunityAli
|
||||
/**
|
||||
* Show the restaurants
|
||||
*/
|
||||
NGApp.controller( 'RestaurantsCtrl', function ( $scope, $rootScope, $http, $location, RestaurantsService, LocationService) {
|
||||
NGApp.controller( 'RestaurantsCtrl', function ( $scope, $rootScope, $http, $location, $timeout, RestaurantsService, LocationService) {
|
||||
|
||||
$scope.restaurants = false;
|
||||
|
||||
@ -108,6 +108,20 @@ NGApp.controller( 'RestaurantsCtrl', function ( $scope, $rootScope, $http, $loca
|
||||
|
||||
$scope.mealItemClass = App.isAndroid() ? 'meal-food-android' : '';
|
||||
|
||||
// Update the close/open/about_to_close status from the restaurants
|
||||
var updateStatus = function(){
|
||||
updateRestaurantStatus = $timeout( function(){
|
||||
// Update status of the restaurant's list
|
||||
$scope.restaurants = restaurants.sort();
|
||||
updateStatus();
|
||||
} , 1000 * 15 );
|
||||
}
|
||||
|
||||
$scope.$on( '$destroy', function(){
|
||||
// Kills the timer when the controller is changed
|
||||
$timeout.cancel( updateRestaurantStatus );
|
||||
});
|
||||
|
||||
$scope.display = function($event) {
|
||||
var restaurant = this.restaurant;
|
||||
if (!restaurant.open()) {
|
||||
@ -153,6 +167,7 @@ NGApp.controller( 'RestaurantsCtrl', function ( $scope, $rootScope, $http, $loca
|
||||
document.title = city + ' Food Delivery | Order Food from ' + (city || 'Local') + ' Restaurants | Crunchbutton';
|
||||
|
||||
$scope.restaurants = restaurants.sort();
|
||||
updateStatus();
|
||||
$scope.slogan = slogan;
|
||||
$scope.tagline = tagline;
|
||||
|
||||
|
||||
@ -298,6 +298,12 @@ var Restaurant = function(id) {
|
||||
}
|
||||
}
|
||||
|
||||
if( isOpen ){
|
||||
var minToClose = self.isAboutToClose();
|
||||
if( !isNaN( parseFloat( minToClose ) ) && minToClose == 0 ){
|
||||
isOpen = false;
|
||||
}
|
||||
}
|
||||
this._open = isOpen;
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
@ -15,8 +15,27 @@ NGApp.factory('RestaurantsService', function ($http, $rootScope, PositionsServic
|
||||
service.position = PositionsService;
|
||||
|
||||
service.sort = function () {
|
||||
// dont not sort. if a restaurant closes we want to make sure it apears so
|
||||
|
||||
var list = service.getStatus();
|
||||
|
||||
list.sort(sort_by({
|
||||
name: '_open',
|
||||
reverse: true
|
||||
}, {
|
||||
name: 'delivery',
|
||||
reverse: true
|
||||
}, {
|
||||
name: '_weight',
|
||||
primer: parseInt,
|
||||
reverse: true
|
||||
}));
|
||||
|
||||
restaurants = list;
|
||||
return restaurants;
|
||||
}
|
||||
|
||||
service.getStatus = function () {
|
||||
|
||||
var list = restaurants;
|
||||
|
||||
for (var x in list) {
|
||||
@ -31,23 +50,13 @@ NGApp.factory('RestaurantsService', function ($http, $rootScope, PositionsServic
|
||||
if (list[x].delivery != '1') {
|
||||
list[x]._tag = 'takeout';
|
||||
} else if (list[x].isAboutToClose()) {
|
||||
list[x]._minToClose = list[x].isAboutToClose();
|
||||
list[x]._tag = 'closing';
|
||||
}
|
||||
}
|
||||
// show short description
|
||||
list[x]._short_description = (list[x].short_description || ('Top Order: ' + (list[x].top_name ? (list[x].top_name || list[x].top_name) : '')));
|
||||
};
|
||||
list.sort(sort_by({
|
||||
name: '_open',
|
||||
reverse: true
|
||||
}, {
|
||||
name: 'delivery',
|
||||
reverse: true
|
||||
}, {
|
||||
name: '_weight',
|
||||
primer: parseInt,
|
||||
reverse: true
|
||||
}));
|
||||
|
||||
restaurants = list;
|
||||
return restaurants;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user