2014-07-08 07:02:26 -04:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
|
|
|
App.controller "AccountSettingsController", ["$scope", "$http", "$modal", ($scope, $http, $modal) ->
|
|
|
|
$scope.subscribed = true
|
|
|
|
|
|
|
|
$scope.unsubscribe = () ->
|
|
|
|
$scope.unsubscribing = true
|
|
|
|
$http({
|
|
|
|
method: "DELETE"
|
|
|
|
url: "/user/newsletter/unsubscribe"
|
|
|
|
headers:
|
|
|
|
"X-CSRF-Token": window.csrfToken
|
|
|
|
})
|
|
|
|
.success () ->
|
|
|
|
$scope.unsubscribing = false
|
|
|
|
$scope.subscribed = false
|
|
|
|
.error () ->
|
|
|
|
$scope.unsubscribing = true
|
|
|
|
|
|
|
|
$scope.deleteAccount = () ->
|
|
|
|
modalInstance = $modal.open(
|
|
|
|
templateUrl: "deleteAccountModalTemplate"
|
2016-10-04 10:57:08 -04:00
|
|
|
controller: "DeleteAccountModalController",
|
|
|
|
scope: $scope
|
2014-07-08 07:02:26 -04:00
|
|
|
)
|
|
|
|
]
|
|
|
|
|
|
|
|
App.controller "DeleteAccountModalController", [
|
|
|
|
"$scope", "$modalInstance", "$timeout", "$http",
|
|
|
|
($scope, $modalInstance, $timeout, $http) ->
|
2014-07-28 11:52:23 -04:00
|
|
|
$scope.state =
|
|
|
|
isValid : false
|
|
|
|
deleteText: ""
|
2014-07-08 07:02:26 -04:00
|
|
|
inflight: false
|
|
|
|
|
|
|
|
$modalInstance.opened.then () ->
|
|
|
|
$timeout () ->
|
|
|
|
$scope.$broadcast "open"
|
|
|
|
, 700
|
|
|
|
|
2014-07-28 11:52:23 -04:00
|
|
|
$scope.checkValidation = ->
|
2016-10-04 10:57:08 -04:00
|
|
|
$scope.state.isValid = $scope.state.deleteText == $scope.email
|
2014-07-28 11:52:23 -04:00
|
|
|
|
2014-07-08 07:02:26 -04:00
|
|
|
$scope.delete = () ->
|
|
|
|
$scope.state.inflight = true
|
|
|
|
|
|
|
|
$http({
|
|
|
|
method: "DELETE"
|
|
|
|
url: "/user"
|
|
|
|
headers:
|
|
|
|
"X-CSRF-Token": window.csrfToken
|
|
|
|
})
|
|
|
|
.success () ->
|
|
|
|
$modalInstance.close()
|
|
|
|
window.location = "/"
|
|
|
|
|
|
|
|
$scope.cancel = () ->
|
|
|
|
$modalInstance.dismiss('cancel')
|
2016-10-04 10:57:08 -04:00
|
|
|
]
|