-
Notifications
You must be signed in to change notification settings - Fork 0
/
address-tile.dtiv.js
88 lines (75 loc) · 2.22 KB
/
address-tile.dtiv.js
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
(function() {
'use strict';
angular
.module('ctRolodex')
.directive('ctAddressTile', directive);
function directive() {
return {
templateUrl: 'address-tile.tmpl.html',
scope: {
address: '=',
options: '=?',
onDelete: '&',
onSave: '&',
onSelect: '&',
editInProgress: '=?',
onCancel: '&'
},
controllerAs: 'vm',
bindToController: true,
controller: function() {
var vm = this;
vm.editMode = false;
vm.confirmRequired = false;
vm.editInProgress = angular.isDefined(vm.editInProgress) ? vm.editInProgress : false;
if (!vm.options) {
vm.options = {};
}
vm.options.enableSave = angular.isDefined(vm.options.enableSave) ? vm.options.enableSave : false;
vm.options.enableDelete = angular.isDefined(vm.options.enableDelete) ? vm.options.enableDelete : false;
vm.options.enableSelect = angular.isDefined(vm.options.enableSelect) ? vm.options.enableSelect : false;
function toggleActive(isActive) {
vm.editMode = isActive;
vm.editInProgress = isActive;
}
vm.toggleEditMode = function() {
toggleActive(true);
};
vm.save = function() {
if (vm.options.enableSave) {
toggleActive(false);
vm.onSave({
address: vm.address
});
}
};
vm.cancel = function() {
toggleActive(false);
vm.onCancel();
};
vm.delete = function(address) {
if (vm.options.enableDelete) {
vm.confirmRequired = true;
}
};
vm.deleteProceed = function() {
toggleActive(false);
vm.onDelete({
address: vm.address
});
};
vm.deleteAbort = function() {
vm.confirmRequired = false;
};
vm.shipTo = function() {
if (vm.options.enableSelect) {
toggleActive(false);
vm.onSelect({
address: vm.address
});
}
};
}
};
}
})();