Commit 4a22ff5191c15e3881933d19be65b06644219502
1 parent
03995bff
Exists in
master
and in
8 other branches
Fix canUnselect category-list
Showing
1 changed file
with
17 additions
and
9 deletions
Show diff stats
src/app/components/category-list/category-list.directive.js
| ... | ... | @@ -30,27 +30,35 @@ |
| 30 | 30 | if(!vm.isCollapsed){ |
| 31 | 31 | vm.isCollapsed = false; |
| 32 | 32 | } |
| 33 | + }; | |
| 34 | + | |
| 35 | + CategoryListController.prototype._canUnselect = function() { | |
| 36 | + var vm = this; | |
| 33 | 37 | |
| 34 | - if(angular.isUndefined(vm.canUnselect) || vm.canUnselect === null){ | |
| 35 | - vm.canUnselect = true; | |
| 36 | - } else { | |
| 37 | - vm.canUnselect = !(vm.canUnselect == 'false'); | |
| 38 | + if(vm.canUnselect && vm.canUnselect === 'false'){ | |
| 39 | + return false; | |
| 38 | 40 | } |
| 41 | + | |
| 42 | + return true; | |
| 39 | 43 | }; |
| 40 | 44 | |
| 45 | + | |
| 41 | 46 | CategoryListController.prototype.selectCategory = function(category, $event) { |
| 42 | 47 | var vm = this; |
| 43 | 48 | |
| 44 | 49 | // prevent glitch |
| 45 | 50 | $event.stopPropagation(); |
| 46 | 51 | |
| 47 | - if(!category && !vm.canUnselect){ | |
| 48 | - vm.$log.info('Unselect is disabled.'); | |
| 49 | - return; | |
| 50 | - } | |
| 51 | - | |
| 52 | 52 | if (category !== vm.selectedCategory) { |
| 53 | 53 | vm.selectedCategory = category; |
| 54 | + }else{ | |
| 55 | + | |
| 56 | + if(!vm._canUnselect()){ | |
| 57 | + vm.$log.info('Unselect is disabled.'); | |
| 58 | + return; | |
| 59 | + } | |
| 60 | + | |
| 61 | + vm.selectedCategory = null; | |
| 54 | 62 | } |
| 55 | 63 | |
| 56 | 64 | // send event to all controllers | ... | ... |