aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/deleteredirect.js
blob: f480339e99ac8fd95f263c51aec26a9f3f2f87b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
redirectorApp.controller('DeleteRedirectCtrl', ['$scope', function($s) {

	// Ok, this is pretty ugly. But I want to make this controller to control
	// everything about the deleting process, so I make this available on
	// the parent scope, so the RedirectListCtrl can access it.
	$s.$parent.confirmDeleteRedirect = function(index) {
		$s.redirect = $s.redirects[index];
		$s.deleteIndex = index;
		$s.$parent.showDeleteForm = true;
	};

	$s.cancelDelete = function(index) {
		delete $s.redirect;
		delete $s.deletingIndex;
		$s.$parent.showDeleteForm = false;
	}

	$s.deleteRedirect = function() {
		$s.redirects.splice($s.deletingIndex, 1);
		delete $s.redirect;
		delete $s.deletingIndex;
		$s.$parent.showDeleteForm = false;
		$s.saveChanges();
	};
}]);