diff --git a/app/assets/javascripts/darkswarm/directives/active_selector.js.coffee b/app/assets/javascripts/darkswarm/directives/active_selector.js.coffee index 563b5a1716..46be338610 100644 --- a/app/assets/javascripts/darkswarm/directives/active_selector.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/active_selector.js.coffee @@ -6,10 +6,10 @@ Darkswarm.directive "activeSelector", -> replace: true templateUrl: 'active_selector.html' link: (scope, elem, attr)-> - scope.selector.emit = scope.emit - elem.bind "click", -> - scope.$apply -> - scope.selector.active = !scope.selector.active - # This function is a convention, e.g. a callback on the scope applied when active changes - scope.emit() if scope.emit - + unless scope.readOnly && scope.readOnly() + scope.selector.emit = scope.emit + elem.bind "click", -> + scope.$apply -> + scope.selector.active = !scope.selector.active + # This function is a convention, e.g. a callback on the scope applied when active changes + scope.emit() if scope.emit diff --git a/app/assets/javascripts/darkswarm/directives/filter_selector.js.coffee b/app/assets/javascripts/darkswarm/directives/filter_selector.js.coffee index b964219925..28b548d1c3 100644 --- a/app/assets/javascripts/darkswarm/directives/filter_selector.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/filter_selector.js.coffee @@ -5,7 +5,7 @@ Darkswarm.directive "filterSelector", (FilterSelectorsService)-> replace: true scope: objects: "&" - activeSelectors: "=" + activeSelectors: "=?" allSelectors: "=?" # Optional templateUrl: "filter_selector.html" @@ -13,6 +13,9 @@ Darkswarm.directive "filterSelector", (FilterSelectorsService)-> selectors_by_id = {} selectors = null # To get scoping/closure right + scope.readOnly = -> + attr.activeSelectors? + scope.emit = -> scope.activeSelectors = selectors.filter (selector)-> selector.active @@ -23,10 +26,10 @@ Darkswarm.directive "filterSelector", (FilterSelectorsService)-> # when data has been loaded, in order to pass # selectors up scope.$on 'loadFilterSelectors', -> - scope.allSelectors = scope.selectors() + scope.allSelectors = scope.selectors() if attr.allSelectors? scope.$watchCollection "selectors()", (newValue, oldValue) -> - scope.allSelectors = scope.selectors() + scope.allSelectors = scope.selectors() if attr.allSelectors? # Build a list of selectors scope.selectors = -> diff --git a/app/assets/javascripts/templates/filter_selector.html.haml b/app/assets/javascripts/templates/filter_selector.html.haml index cddcd2f523..ecd4fb7d6d 100644 --- a/app/assets/javascripts/templates/filter_selector.html.haml +++ b/app/assets/javascripts/templates/filter_selector.html.haml @@ -1,3 +1,4 @@ -%active-selector{ ng: { repeat: "selector in selectors()", show: "ifDefined(selector.fits, true)" } } - %render-svg{path: "{{selector.object.icon}}", ng: { if: "selector.object.icon"} } - %span {{ selector.object.name }} +%div{ style: "display: inline-block" } + %active-selector{ ng: { repeat: "selector in selectors()", show: "ifDefined(selector.fits, true)" } } + %render-svg{path: "{{selector.object.icon}}", ng: { if: "selector.object.icon"} } + %span {{ selector.object.name }}