diff --git a/app/components/account-delete-modal.html b/app/components/account-delete-modal.html new file mode 100644 index 00000000..b79c60e7 --- /dev/null +++ b/app/components/account-delete-modal.html @@ -0,0 +1,115 @@ +
diff --git a/app/components/account-delete-modal.ts b/app/components/account-delete-modal.ts new file mode 100644 index 00000000..edafd676 --- /dev/null +++ b/app/components/account-delete-modal.ts @@ -0,0 +1,57 @@ +import {localStorageAvailable} from '../utils/local-storage'; + +export default function(app) { + app.component('accountDeleteModal', { + bindings: { + close: '&', + dismiss: '&', + }, + controller: class DocumentItemMetadataModalCtrl { + close: () => void; + + public deleteExternalIds = false; + public error: string; + public submitting = false; + public succeeded = false; + + static $inject = [ + '$http', '$location', '$scope', '$window', + 'authService', 'notificationService', 'peopleApi', + ]; + constructor( + public $http, public $location, public $scope, public $window, + public authService, public notificationService, public peopleApi, + ) {} + + public hasError(field) { + const form = this.$scope.accountDeleteForm; + return form && (form.$submitted || form[field].$touched) && + form[field].$invalid; + } + + public submit() { + this.submitting = true; + this.succeeded = false; + + this.peopleApi.deleteAccount( + this.authService.user.id, + {deleteExternalIds: this.deleteExternalIds}, + ) + .then(() => { + this.succeeded = true; + this.authService.logout(); + if (localStorageAvailable) this.$window.localStorage.clear(); + this.notificationService.notifications.push({ + type: 'info', + message: 'Your account has been successfully deleted.', + }); + this.$location.url('/'); + return this.close(); + }) + .catch(error => this.error = error) + .finally(() => this.submitting = false); + } + }, + template: require('./account-delete-modal.html'), + }); +} diff --git a/app/components/avatar-list.ts b/app/components/avatar-list.ts index bff9238d..9854528d 100644 --- a/app/components/avatar-list.ts +++ b/app/components/avatar-list.ts @@ -10,9 +10,13 @@ export default function(app) { $scope.$watchCollection('$ctrl.discussion.replies', () => { if (!$ctrl.discussion) return; - $scope.participants = map($ctrl.discussion.replies, 'author'); + $scope.participants = $ctrl.discussion.replies + .filter(reply => !reply.deleted) + .map(reply => reply.author); // prepend original annotation author - $scope.participants.unshift($ctrl.discussion.author); + if (!$ctrl.discussion.deleted) { + $scope.participants.unshift($ctrl.discussion.author); + } // make list unique w.r.t. id $scope.participants = uniqBy($scope.participants, 'id'); diff --git a/app/components/comment.html b/app/components/comment.html index 0ab9bc25..bac01371 100644 --- a/app/components/comment.html +++ b/app/components/comment.html @@ -6,36 +6,41 @@- - {{$ctrl.cluster.discussions[0].author.displayName}} - · -
-+
+ Contribution has been deleted. Reason: {{$ctrl.cluster.discussions[0].deletedReason}}. +
++ + {{$ctrl.cluster.discussions[0].author.displayName}} + · +
+
+
- - {{$ctrl.discussion.author.displayName}} - · +
+ Contribution has been deleted. Reason: {{$ctrl.discussion.deletedReason}}.
-+
+ + {{$ctrl.discussion.author.displayName}} + · +
+
+