Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 2e1ba9b

Browse files
author
Nick Litwin
committed
More updates
1 parent 7c67336 commit 2e1ba9b

25 files changed

+295
-289
lines changed
Lines changed: 68 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,141 @@
1+
import angular from 'angular'
2+
import _ from 'lodash'
3+
14
(function() {
2-
'use strict';
5+
'use strict'
6+
37
var _supportedAccounts = [
4-
{ provider: "dribbble", className: "fa-dribbble", displayName: "Dribbble", disabled: false, order: 6, colorClass: 'el-dribble', featured: true},
5-
{ provider: "linkedin", className: "fa-linkedin", displayName: "LinkedIn", disabled: true, order: 5, colorClass: 'el-linkedin', featured: true},
6-
{ provider: "stackoverflow", className: "fa-stack-overflow", displayName: "Stack Overflow", disabled: false, order: 3, colorClass: 'el-stackoverflow'},
7-
{ provider: "behance", className: "fa-behance", displayName: "Behance", disabled: true, order: 2, colorClass: 'el-behance'},
8-
{ provider: "github", className: "fa-github", displayName: "Github", disabled: false, order: 1, colorClass: 'el-github', featured: true},
9-
{ provider: "bitbucket", className: "fa-bitbucket", displayName: "Bitbucket", disabled: false, order: 7, colorClass: 'el-bitbucket'},
10-
{ provider: "twitter", className: "fa-twitter", displayName: "Twitter", disabled: true, order: 4, colorClass: 'el-twitter'},
11-
{ provider: "weblink", className: "fa-globe", displayName: "Web Links", disabled: true, order: -1, colorClass: 'el-weblinks'}
12-
// TODO add more
13-
];
8+
{ provider: 'dribbble', className: 'fa-dribbble', displayName: 'Dribbble', disabled: false, order: 6, colorClass: 'el-dribble', featured: true},
9+
{ provider: 'linkedin', className: 'fa-linkedin', displayName: 'LinkedIn', disabled: true, order: 5, colorClass: 'el-linkedin', featured: true},
10+
{ provider: 'stackoverflow', className: 'fa-stack-overflow', displayName: 'Stack Overflow', disabled: false, order: 3, colorClass: 'el-stackoverflow'},
11+
{ provider: 'behance', className: 'fa-behance', displayName: 'Behance', disabled: true, order: 2, colorClass: 'el-behance'},
12+
{ provider: 'github', className: 'fa-github', displayName: 'Github', disabled: false, order: 1, colorClass: 'el-github', featured: true},
13+
{ provider: 'bitbucket', className: 'fa-bitbucket', displayName: 'Bitbucket', disabled: false, order: 7, colorClass: 'el-bitbucket'},
14+
{ provider: 'twitter', className: 'fa-twitter', displayName: 'Twitter', disabled: true, order: 4, colorClass: 'el-twitter'},
15+
{ provider: 'weblink', className: 'fa-globe', displayName: 'Web Links', disabled: true, order: -1, colorClass: 'el-weblinks'}
16+
]
1417

1518
angular.module('tcUIComponents')
1619
.directive('externalAccounts', function() {
1720
return {
1821
restrict: 'E',
19-
templateUrl: 'directives/external-account/external-account.directive.html',
22+
template: require('./external-account')(),
2023
scope: {
2124
linkedAccounts: '=',
2225
readOnly: '='
2326
},
2427
controller: ['$log', '$scope', 'ExternalAccountService', 'toaster',
2528
function($log, $scope, ExternalAccountService, toaster) {
2629

27-
$log = $log.getInstance("ExtAccountDirectiveCtrl")
30+
$log = $log.getInstance('ExtAccountDirectiveCtrl')
2831

29-
var _accountList = _.clone(_supportedAccounts, true);
30-
_.remove(_accountList, function(al) { return al.order < 0});
32+
var _accountList = _.clone(_supportedAccounts, true)
33+
_.remove(_accountList, function(al) { return al.order < 0})
3134
$scope.$watchCollection('linkedAccounts', function(newValue, oldValue) {
3235
if (newValue) {
3336
angular.forEach(_accountList, function(account) {
3437
var _linkedAccount = _.find(newValue, function(p) {
3538
return p.provider === account.provider
36-
});
37-
var accountStatus = _.get(_linkedAccount, 'data.status', null);
39+
})
40+
var accountStatus = _.get(_linkedAccount, 'data.status', null)
3841
if (!_linkedAccount) {
39-
account.status = 'unlinked';
42+
account.status = 'unlinked'
4043
} else if(accountStatus && accountStatus.toLowerCase() === 'pending') {
41-
account.status = 'pending';
44+
account.status = 'pending'
4245
} else {
43-
account.status = 'linked';
46+
account.status = 'linked'
4447
}
45-
});
46-
$scope.accountList = _accountList;
48+
})
49+
$scope.accountList = _accountList
4750
} else {
4851
// reset the status for all accounts
4952
angular.forEach(_accountList, function(account) {
50-
delete account.status;
51-
});
53+
delete account.status
54+
})
5255
}
53-
});
56+
})
5457

5558
$scope.handleClick = function(provider, status) {
5659
var provider = _.find(_supportedAccounts, function(s) {
57-
return s.provider === provider;
58-
});
60+
return s.provider === provider
61+
})
5962
if (status === 'linked') {
60-
$log.debug(String.supplant('UnLinking to ' + provider.displayName));
61-
_unlink(provider);
63+
$log.debug(String.supplant('UnLinking to ' + provider.displayName))
64+
_unlink(provider)
6265
} else if (status === 'unlinked') {
63-
$log.debug(String.supplant('Linking to ' + provider.displayName));
64-
_link(provider);
66+
$log.debug(String.supplant('Linking to ' + provider.displayName))
67+
_link(provider)
6568
}
66-
};
69+
}
6770

6871
function _link(provider) {
6972
ExternalAccountService.linkExternalAccount(provider.provider, null)
7073
.then(function(resp) {
71-
$log.debug("Social account linked: " + JSON.stringify(resp));
72-
$scope.linkedAccounts.push(resp.linkedAccount);
73-
toaster.pop('success', "Success",
74+
$log.debug('Social account linked: ' + JSON.stringify(resp))
75+
$scope.linkedAccounts.push(resp.linkedAccount)
76+
toaster.pop('success', 'Success',
7477
String.supplant(
75-
"Your {provider} account has been linked. Data from your linked account will be visible on your profile shortly.",
78+
'Your {provider} account has been linked. Data from your linked account will be visible on your profile shortly.',
7679
{provider: provider.displayName}
7780
)
78-
);
81+
)
7982
})
8083
.catch(function(resp) {
8184
if (resp.status === 'SOCIAL_PROFILE_ALREADY_EXISTS') {
82-
$log.info("Social profile already linked to another account");
83-
toaster.pop('error', "Whoops!",
85+
$log.info('Social profile already linked to another account')
86+
toaster.pop('error', 'Whoops!',
8487
String.supplant(
85-
"This {provider} account is linked to another account. \
86-
If you think this is an error please contact <a href=\"mailTo:[email protected]\">[email protected]</a>.",
88+
'This {provider} account is linked to another account. \
89+
If you think this is an error please contact <a href=\"mailTo:[email protected]\">[email protected]</a>.',
8790
{provider: provider.displayName }
8891
)
89-
);
92+
)
9093
} else {
91-
$log.error("Fatal Error: _link: " + resp.msg);
92-
toaster.pop('error', "Whoops!", "Sorry, we are unable to add your account right now. Please try again later. If the problem persists, please contact <a href=\"mailTo:[email protected]\">[email protected]</a>.");
94+
$log.error('Fatal Error: _link: ' + resp.msg)
95+
toaster.pop('error', 'Whoops!', 'Sorry, we are unable to add your account right now. Please try again later. If the problem persists, please contact <a href=\"mailTo:[email protected]\">[email protected]</a>.')
9396
}
94-
});
97+
})
9598
}
9699

97100
function _unlink(provider) {
98101
return ExternalAccountService.unlinkExternalAccount(provider.provider)
99102
.then(function(resp) {
100-
$log.debug("Social account unlinked: " + JSON.stringify(resp));
103+
$log.debug('Social account unlinked: ' + JSON.stringify(resp))
101104
var toRemove = _.findIndex($scope.linkedAccounts, function(la) {
102-
return la.provider === provider.provider;
103-
});
105+
return la.provider === provider.provider
106+
})
104107
if (toRemove > -1) {
105108
// remove from the linkedAccounts array
106-
$scope.linkedAccounts.splice(toRemove, 1);
109+
$scope.linkedAccounts.splice(toRemove, 1)
107110
}
108-
toaster.pop('success', "Success",
111+
toaster.pop('success', 'Success',
109112
String.supplant(
110-
"Your {provider} account has been unlinked.",
113+
'Your {provider} account has been unlinked.',
111114
{provider: provider.displayName}
112115
)
113-
);
116+
)
114117
})
115118
.catch(function(resp) {
116-
var msg = resp.msg;
119+
var msg = resp.msg
117120
if (resp.status === 'SOCIAL_PROFILE_NOT_EXIST') {
118-
$log.info("Social profile not linked to account");
119-
msg = "{provider} account is not linked to your account. If you think this is an error please contact <a href=\"mailTo:[email protected]\">[email protected]</a>.";
121+
$log.info('Social profile not linked to account')
122+
msg = '{provider} account is not linked to your account. If you think this is an error please contact <a href=\"mailTo:[email protected]\">[email protected]</a>.'
120123
} else {
121-
$log.error("Fatal error: _unlink: " + msg);
122-
msg = "Sorry! We are unable to unlink your {provider} account. If problem persists, please contact <a href=\"mailTo:[email protected]\">[email protected]</a>";
124+
$log.error('Fatal error: _unlink: ' + msg)
125+
msg = 'Sorry! We are unable to unlink your {provider} account. If problem persists, please contact <a href=\"mailTo:[email protected]\">[email protected]</a>'
123126
}
124-
toaster.pop('error', "Whoops!", String.supplant(msg, {provider: provider.displayName }));
125-
});
127+
toaster.pop('error', 'Whoops!', String.supplant(msg, {provider: provider.displayName }))
128+
})
126129
}
127130
}
128131
]
129-
};
132+
}
130133
})
131134
.filter('providerData', function() {
132135
return function(input, field) {
133136
return _.result(_.find(_supportedAccounts, function(s) {
134-
return s.provider === input.provider;
135-
}), field) || "";
136-
};
137-
});
138-
})();
137+
return s.provider === input.provider
138+
}), field) || ''
139+
}
140+
})
141+
})()
Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,49 @@
1+
import angular from 'angular'
2+
13
(function() {
2-
'use strict';
4+
'use strict'
35

4-
/**
5-
* @desc links data card directive
6-
* @example <external-links-data></external-links-data>
7-
*/
8-
angular
9-
.module('tcUIComponents')
10-
.directive('externalLinksData', externalLinksData);
6+
// @desc links data card directive
7+
// @example <external-links-data></external-links-data>
8+
angular.module('tcUIComponents').directive('externalLinksData', externalLinksData)
119

1210
function externalLinksData() {
1311
var directive = {
14-
restrict: 'E',
15-
templateUrl: 'directives/external-account/external-link-data.directive.html',
12+
restrict: 'E',
13+
template: require('./external-links-data')(),
1614
scope: {
1715
linkedAccountsData: '=',
1816
editable: '=',
1917
userHandle: '@'
2018
},
2119
controller: ['$log', '$scope', '$window', '$filter', 'ExternalWebLinksService', 'toaster', 'ngDialog',
2220
function($log, $scope, $window, $filter, ExternalWebLinksService, toaster, ngDialog) {
23-
24-
$log = $log.getInstance("ExternalLinksDataCtrl");
25-
$scope.deletionDialog = null;
21+
$log = $log.getInstance('ExternalLinksDataCtrl')
22+
$scope.deletionDialog = null
2623

2724
$scope.openLink = function(account) {
28-
var url = null;
25+
var url = null
2926
if (account) {
3027
if (account.data && account.data.profileURL && account.data.status !== 'PENDING') {
31-
url = account.data.profileURL;
28+
url = account.data.profileURL
3229
}
3330
if (account.URL && account.status !== 'PENDING') {
34-
url = account.URL;
31+
url = account.URL
3532
}
3633
}
3734
if (url) {
38-
$window.open($filter('urlProtocol')(url), '_blank');
35+
$window.open($filter('urlProtocol')(url), '_blank')
3936
}
4037
}
4138

4239
$scope.confirmDeletion = function(account) {
4340
// for non weblink provider, do nothing
4441
if (account.provider !== 'weblink') {
45-
return;
42+
return
4643
}
4744
// do nothing for pending state cards
4845
if (account.status === 'PENDING') {
49-
return;
46+
return
5047
}
5148
$scope.deletionDialog = ngDialog.open({
5249
className: 'ngdialog-theme-default tc-dialog',
@@ -55,22 +52,22 @@
5552
controllerAs: 'vm',
5653
resolve: {
5754
userHandle: function() {
58-
return $scope.userHandle;
55+
return $scope.userHandle
5956
},
6057
account: function() {
61-
return account;
58+
return account
6259
},
6360
linkedAccountsData: function() {
64-
return $scope.linkedAccountsData;
61+
return $scope.linkedAccountsData
6562
}
6663
}
6764
}).closePromise.then(function (data) {
68-
$log.debug('Closing deletion confirmation dialog.');
69-
});
65+
$log.debug('Closing deletion confirmation dialog.')
66+
})
7067
}
7168
}
7269
]
73-
};
74-
return directive;
70+
}
71+
return directive
7572
}
76-
})();
73+
})()

0 commit comments

Comments
 (0)