|
5 | 5 | .module('assessoriaTorrellesApp')
|
6 | 6 | .controller('NotificationController', NotificationController);
|
7 | 7 |
|
8 |
| - NotificationController.$inject = ['$scope', '$state', 'DataUtils', 'Notification', 'ParseLinks', 'AlertService', 'pagingParams', 'paginationConstants']; |
| 8 | + NotificationController.$inject = ['$scope', '$state', 'DataUtils', 'Notification', 'AlertService', 'pagingParams', 'paginationConstants']; |
9 | 9 |
|
10 |
| - function NotificationController ($scope, $state, DataUtils, Notification, ParseLinks, AlertService, pagingParams, paginationConstants) { |
| 10 | + function NotificationController ($scope, $state, DataUtils, Notification, AlertService, pagingParams, paginationConstants) { |
11 | 11 | var vm = this;
|
12 | 12 |
|
13 | 13 | vm.loadPage = loadPage;
|
|
30 | 30 | function onError(error) {
|
31 | 31 | AlertService.error(error.data.message);
|
32 | 32 | }
|
| 33 | + $state.go($state.current); |
33 | 34 | }
|
34 | 35 |
|
35 | 36 | vm.deleteNotifications = function deleteNotifications() {
|
36 |
| - console.log("ids" + getAllChecked()); |
37 |
| - Notification.multipleDelete({"ids" : getAllChecked()}, $state.go($state.current, {}, {reload: true})); |
| 37 | + Notification.multipleDelete({"ids" : getAllChecked()}, reloadView(), console.log("Error")); |
| 38 | + }; |
| 39 | + |
| 40 | + vm.updateNotifications = function updateNotifications() { |
| 41 | + console.log(getAllNotificationsChecked()); |
| 42 | + Notification.setRead(getAllNotificationsChecked(), reloadView(), console.log("ERROR :(")) |
38 | 43 |
|
39 | 44 | };
|
40 | 45 |
|
|
75 | 80 | return allChecked;
|
76 | 81 |
|
77 | 82 | }
|
| 83 | + |
| 84 | + function getAllNotificationsChecked() { |
| 85 | + var allChecked = []; |
| 86 | + angular.forEach(vm.notifications, function (itm) { |
| 87 | + if (itm.selected){ |
| 88 | + allChecked.push(itm); |
| 89 | + } |
| 90 | + }); |
| 91 | + return allChecked; |
| 92 | + } |
| 93 | + |
| 94 | + function reloadView(){ |
| 95 | + $state.go($state.current, {}, {reload: true}); |
| 96 | + } |
78 | 97 | }
|
79 | 98 | })();
|
0 commit comments