Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#1.5.0

* Added deletion function.

# 1.4.0

* Added form to resend verification email.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-user-management",
"version": "1.4.0",
"version": "1.5.0",
"homepage": "https://github.com/incuna/angular-user-management",
"authors": [
"Perry Roper <perryroper@gmail.com>"
Expand Down
1 change: 1 addition & 0 deletions src/profile/scripts/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
var module = angular.module('user_management.profile');

module.controller('ProfileCtrl', [function () {}]);
module.controller('ProfileDeletedCtrl', [function () {}]);

}(window.angular));

36 changes: 36 additions & 0 deletions src/profile/scripts/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,40 @@
}
]);

module.directive('profileDelete', [
'profileFactory', '$modal', '$location', '$filter',
function (profileFactory, $modal, $location, $filter) {
return {
restrict: 'A',
scope: true,

link: function (scope, element, attrs) {

scope.deleteProfile = function () {
$modal.open({
templateUrl: 'templates/user_management/profile/delete-profile.html',
windowClass: 'delete-profile',
controller: ['$scope', '$modalInstance', function ($scope, $modalInstance) {
$scope.failed = false;

$scope.close = function () {
$modalInstance.dismiss('close');
};
$scope.deleteProfile = function(){
profileFactory.profile.deleteData().then(function(){
$modalInstance.dismiss('close');
$location.path($filter('reverseUrl')('ProfileDeletedCtrl').substring(1));
},
function(){
$scope.failed = true;
});
};
}]
});
};
}
};
}
]);

}(window.angular));
5 changes: 4 additions & 1 deletion src/profile/scripts/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
templateUrl: 'templates/user_management/profile/profile.html',
controller: 'ProfileCtrl',
anonymous: false
})
.when('/delete-profile-confirmation/', {
templateUrl: 'templates/user_management/profile/delete-profile-confirmation.html',
controller: 'ProfileDeletedCtrl'
});
}
]);

}(window.angular));

6 changes: 6 additions & 0 deletions src/profile/scripts/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
url: profile.url
});
},
deleteData: function(){
return $http({
method: 'DELETE',
url: profile.url
});
},
patch: function (data) {
return $http({
method: 'PATCH',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div data-extend-template="templates/base.html" class="profile-page">
<div data-block="page-body-content-inner">
<span translate>Your account has been deleted.</span>
<a class="btn btn-default" ng-href="/" translate>Home</a>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="notification-header">
<span ng-show="!failed" translate>You are about to permanently delete your profile and all associated data. This cannot be undone. Please confirm you would like to proceed.</span>
<span ng-show="failed" translate>Delete failed, please try again later.</span>
</div>

<div class="actions">
<button ng-click="deleteProfile()" class="action button right-arrow seperated tick" translate>Delete</button>
<button ng-click="close()" class="action button right-arrow seperated cancel" translate>Cancel</button>
</div>