diff --git a/dashboard-ui/scripts/supporterkeypage.js b/dashboard-ui/scripts/supporterkeypage.js
index 75c83031fe..52a48bc126 100644
--- a/dashboard-ui/scripts/supporterkeypage.js
+++ b/dashboard-ui/scripts/supporterkeypage.js
@@ -124,27 +124,87 @@ $(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow);
(function () {
- function loadConnectSupporters(page) {
+ function removeUser(page, id) {
- $('.linkSupporterKeyMessage', page).html(Globalize.translate('MessageLinkYourSupporterKey', 5));
+ Dashboard.confirm(Globalize.translate('MessageConfirmRemoveConnectSupporter'), Globalize.translate('HeaderConfirmRemoveUser'), function (result) {
+
+ if (result) {
+
+ Dashboard.showLoadingMsg();
+
+ ApiClient.ajax({
+ type: "DELETE",
+ url: ApiClient.getUrl('Connect/Supporters', {
+ Id: id
+ })
+
+ }).done(function () {
+
+ loadConnectSupporters(page);
+ });
+ }
+
+ });
+ }
+
+ function getUserHtml(user) {
+
+ var html = '';
+
+ html += '
';
+ html += '';
+ var imgUrl = user.ImageUrl || 'css/images/userflyoutdefault.png';
+ html += '
';
+ html += '';
+ html += user.DisplayName;
+ html += '
';
+ html += '';
+ html += user.Email;
+ html += '
';
+ html += '';
+ html += '';
+ html += '';
+ html += '';
+
+ return html;
+ }
+
+ function renderUsers(page, result) {
+
+ $('.linkSupporterKeyMessage', page).html(Globalize.translate('MessageLinkYourSupporterKey', result.MaxUsers));
+
+ var html = '';
+
+ if (result.Users.length) {
+
+ html += '';
+
+ html += result.Users.map(getUserHtml).join('');
+
+ html += '
';
+ }
+
+ var elem = $('.supporters', page).html(html).trigger('create');
+
+ $('.btnRemoveUser', elem).on('click', function () {
+
+ removeUser(page, this.getAttribute('data-id'));
+
+ });
+ }
+
+ function loadConnectSupporters(page) {
Dashboard.suppressAjaxErrors = true;
ApiClient.ajax({
type: "GET",
url: ApiClient.getUrl('Connect/Supporters'),
- dataType: "json",
-
- error: function () {
- // Don't show normal dashboard errors
- },
-
- enableGlobalAjaxListener: false
-
- }).done(function () {
-
+ dataType: "json"
+ }).done(function (result) {
+ renderUsers(page, result);
}).fail(function () {