1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-04 15:24:23 +01:00
fab-manager/app/assets/javascripts/controllers/dashboard.coffee
2016-05-17 16:41:32 +02:00

39 lines
1016 B
CoffeeScript

'use strict'
Application.Controllers.controller "DashboardController", ["$scope", 'memberPromise', 'SocialNetworks', ($scope, memberPromise, SocialNetworks) ->
## Current user's profile
$scope.user = memberPromise
## 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()
]