Adding handling of 'current hub'

This commit is contained in:
Will Marshall
2014-04-25 11:32:02 +10:00
parent f57020d190
commit 2212156f00
11 changed files with 25 additions and 10 deletions

View File

@@ -0,0 +1,2 @@
Darkswarm.controller "CurrentHubCtrl", ($scope, CurrentHub) ->
$scope.CurrentHub = CurrentHub

View File

@@ -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()

View File

@@ -1,4 +1,3 @@
Darkswarm.controller "HubsCtrl", ($scope, Hubs) ->
console.log Hubs.hubs[0]
$scope.Hubs = Hubs
$scope.hubs = Hubs.hubs

View 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

View File

@@ -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'])