1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-30 11:24:21 +01:00
fab-manager/app/assets/javascripts/controllers/dashboard.coffee

39 lines
1016 B
CoffeeScript
Raw Normal View History

2015-05-05 03:10:25 +02:00
'use strict'
2016-05-17 16:41:32 +02:00
Application.Controllers.controller "DashboardController", ["$scope", 'memberPromise', 'SocialNetworks', ($scope, memberPromise, SocialNetworks) ->
2015-05-05 03:10:25 +02:00
2016-03-23 18:39:41 +01:00
## Current user's profile
$scope.user = memberPromise
2016-05-17 16:41:32 +02:00
## List of social networks associated with this user and toggle 'show all' state
$scope.social =
showAllLinks: false
networks: SocialNetworks
### PRIVATE SCOPE ###
##
# Kind of constructor: these actions will be realized first when the controller is loaded
##
initialize = ->
$scope.social.networks = filterNetworks()
##
# Filter social network or website that are associated with the profile of the user provided in promise
# and return the filtered networks
# @return {Array}
##
filterNetworks = ->
networks = [];
for network in SocialNetworks
if $scope.user.profile[network] && $scope.user.profile[network].length > 0
networks.push(network);
networks
## !!! MUST BE CALLED AT THE END of the controller
initialize()
2015-05-05 03:10:25 +02:00
]