View closed shops by URL

This commit is contained in:
Rohan Mitchell
2016-08-03 15:41:31 +10:00
parent f03839b70c
commit 1054fd2d05
2 changed files with 20 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
Darkswarm.controller "EnterprisesCtrl", ($scope, $rootScope, $timeout, Enterprises, Search, $document, HashNavigation, FilterSelectorsService, EnterpriseModal, enterpriseMatchesNameQueryFilter, distanceWithinKmFilter) ->
Darkswarm.controller "EnterprisesCtrl", ($scope, $rootScope, $timeout, $location, Enterprises, Search, $document, HashNavigation, FilterSelectorsService, EnterpriseModal, enterpriseMatchesNameQueryFilter, distanceWithinKmFilter) ->
$scope.Enterprises = Enterprises
$scope.producers_to_filter = Enterprises.producers
$scope.filterSelectors = FilterSelectorsService.createSelectors()
@@ -21,6 +21,10 @@ Darkswarm.controller "EnterprisesCtrl", ($scope, $rootScope, $timeout, Enterpris
Enterprises.calculateDistance query, $scope.firstNameMatch()
$rootScope.$broadcast 'enterprisesChanged'
$timeout ->
if $location.search()['show_closed']?
$scope.showClosedShops()
$scope.$watch "filtersActive", (value) ->
$scope.$broadcast 'filtersToggled'
@@ -71,6 +75,8 @@ Darkswarm.controller "EnterprisesCtrl", ($scope, $rootScope, $timeout, Enterpris
$scope.showClosedShops = ->
delete $scope.filterExpression['active']
$location.search('show_closed', '1')
$scope.hideClosedShops = ->
$scope.filterExpression['active'] = true
$location.search('show_closed', null)

View File

@@ -75,6 +75,19 @@ feature 'Shops', js: true do
end
end
describe "viewing closed shops by URL" do
before do
d1
d2
visit shops_path(anchor: "/?show_closed=1")
end
it "shows closed shops" do
#click_link_and_ensure("Show closed shops", -> { page.has_selector? 'hub.inactive' })
page.should have_selector 'hub.inactive', text: d2.name
end
end
private