forked from ManageIQ/manageiq-ui-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshopping-cart.component.js
45 lines (38 loc) · 1.05 KB
/
shopping-cart.component.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
(function() {
'use strict';
angular.module('app.components')
.component('shoppingCart', {
controller: ComponentController,
controllerAs: 'vm',
bindings: {
modalInstance: '<?',
},
templateUrl: 'app/components/shopping-cart/shopping-cart.html',
});
/** @ngInject */
function ComponentController(ShoppingCart, EventNotifications) {
var vm = this;
vm.$doCheck = refresh;
vm.submit = submit;
vm.close = close;
vm.clear = ShoppingCart.reset;
vm.remove = ShoppingCart.removeItem;
vm.state = null;
function refresh() {
vm.state = ShoppingCart.state();
}
function submit() {
ShoppingCart.submit()
.then(function() {
EventNotifications.success(__('Shopping cart successfully ordered'));
vm.modalInstance.dismiss();
})
.then(null, function(err) {
EventNotifications.error(__('There was an error submitting this request: ') + err);
});
}
function close() {
vm.modalInstance.dismiss();
}
}
})();