2018-10-25 16:51:20 +02:00
|
|
|
/* eslint-disable
|
|
|
|
no-return-assign,
|
|
|
|
no-undef,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
2018-10-25 16:50:16 +02:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS101: Remove unnecessary use of Array.from
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2018-10-25 16:51:20 +02:00
|
|
|
'use strict'
|
2018-10-25 16:50:16 +02:00
|
|
|
|
2018-10-25 16:51:20 +02:00
|
|
|
Application.Controllers.controller('DashboardController', ['$scope', 'memberPromise', 'SocialNetworks', function ($scope, memberPromise, SocialNetworks) {
|
|
|
|
// # Current user's profile
|
|
|
|
$scope.user = memberPromise
|
2018-10-25 16:50:16 +02:00
|
|
|
|
2018-10-25 16:51:20 +02:00
|
|
|
// # List of social networks associated with this user and toggle 'show all' state
|
2018-10-25 16:50:16 +02:00
|
|
|
$scope.social = {
|
|
|
|
showAllLinks: false,
|
2016-05-17 16:41:32 +02:00
|
|
|
networks: SocialNetworks
|
2018-10-25 16:51:20 +02:00
|
|
|
}
|
2016-05-17 16:41:32 +02:00
|
|
|
|
2018-10-25 16:50:16 +02:00
|
|
|
/* PRIVATE SCOPE */
|
2016-05-17 16:41:32 +02:00
|
|
|
|
2018-10-25 16:51:20 +02:00
|
|
|
// #
|
2018-10-25 16:50:16 +02:00
|
|
|
// Kind of constructor: these actions will be realized first when the controller is loaded
|
2018-10-25 16:51:20 +02:00
|
|
|
// #
|
|
|
|
const initialize = () => $scope.social.networks = filterNetworks()
|
2016-05-17 16:41:32 +02:00
|
|
|
|
2018-10-25 16:51:20 +02:00
|
|
|
// #
|
2018-10-25 16:50:16 +02:00
|
|
|
// Filter social network or website that are associated with the profile of the user provided in promise
|
|
|
|
// and return the filtered networks
|
|
|
|
// @return {Array}
|
2018-10-25 16:51:20 +02:00
|
|
|
// #
|
|
|
|
var filterNetworks = function () {
|
|
|
|
const networks = []
|
2018-10-25 16:50:16 +02:00
|
|
|
for (let network of Array.from(SocialNetworks)) {
|
|
|
|
if ($scope.user.profile[network] && ($scope.user.profile[network].length > 0)) {
|
2018-10-25 16:51:20 +02:00
|
|
|
networks.push(network)
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-25 16:51:20 +02:00
|
|
|
return networks
|
|
|
|
}
|
2016-05-17 16:41:32 +02:00
|
|
|
|
2018-10-25 16:51:20 +02:00
|
|
|
// # !!! MUST BE CALLED AT THE END of the controller
|
|
|
|
return initialize()
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
2016-05-17 16:41:32 +02:00
|
|
|
|
2018-10-25 16:51:20 +02:00
|
|
|
])
|