mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
Adding handling of 'current hub'
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
Darkswarm.controller "CurrentHubCtrl", ($scope, CurrentHub) ->
|
||||
$scope.CurrentHub = CurrentHub
|
||||
@@ -1,9 +1,12 @@
|
||||
Darkswarm.controller "HubNodeCtrl", ($scope, Navigation, $location, $anchorScroll, $templateCache) ->
|
||||
Darkswarm.controller "HubNodeCtrl", ($scope, Navigation, $location, $anchorScroll, $templateCache, CurrentHub) ->
|
||||
$scope.toggle = ->
|
||||
Navigation.navigate $scope.hub.path
|
||||
|
||||
$scope.open = ->
|
||||
$location.path() == $scope.hub.path
|
||||
|
||||
$scope.current = ->
|
||||
$scope.hub.id is CurrentHub.id
|
||||
|
||||
if $scope.open()
|
||||
$anchorScroll()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
Darkswarm.controller "HubsCtrl", ($scope, Hubs) ->
|
||||
console.log Hubs.hubs[0]
|
||||
$scope.Hubs = Hubs
|
||||
$scope.hubs = Hubs.hubs
|
||||
|
||||
7
app/assets/javascripts/darkswarm/services/hub.js.coffee
Normal file
7
app/assets/javascripts/darkswarm/services/hub.js.coffee
Normal file
@@ -0,0 +1,7 @@
|
||||
Darkswarm.factory 'CurrentHub', ($location, hubs, $filter, currentHub) ->
|
||||
new class CurrentHub
|
||||
hasHub: false
|
||||
constructor: ->
|
||||
@[k] = v for k, v of currentHub
|
||||
@hasHub = true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Darkswarm.factory 'Hubs', ($location, hubs, $filter) ->
|
||||
Darkswarm.factory 'Hubs', ($location, hubs, $filter, CurrentHub) ->
|
||||
new class Hubs
|
||||
constructor: ->
|
||||
@hubs = $filter('orderBy')(hubs, ['-active', '+orders_close_at'])
|
||||
|
||||
Reference in New Issue
Block a user