Github user tbouron commented on a diff in the pull request:

    https://github.com/apache/brooklyn-ui/pull/94#discussion_r228906038
  
    --- Diff: 
ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js
 ---
    @@ -230,16 +248,85 @@ function controller($scope, $element, $q, $uibModal, 
$log, $templateCache, palet
             });
             $scope.items = items;
         });
    -    // this can be overridden for third-party filters.
    -    // it receives result of filtering based on search so filters can 
adjust based on number of search resullts
    -    $scope.filterPaletteItems = (items) => items;
    +    $scope.lastUsedText = (item) => {
    +        let l = (Number)(item.lastUsed);
    +        if (!l || isNaN(l) || l<=0) return "";
    +        if (l < 100000) return 'Preselected for inclusion in "Recent" 
filter.';
    +        return 'Last used: ' + moment(l).fromNow();
    +    }; 
    +    $scope.showPaletteControls = false;
    +    $scope.onFiltersShown = () => {
    +      $timeout( () => {
    +        // check do we need to show the multiline
    +        let filters = 
angular.element($element[0].querySelector(".filters"));
    +        $scope.$apply( () => 
$scope.filterSettings.filtersMultilineAvailable = filters[0].scrollHeight > 
filters[0].offsetHeight );
    +        
    +        repaginate($scope, $element);
    +      } );
    +    };
    +    $scope.togglePaletteControls = () => {
    +        $scope.showPaletteControls = !$scope.showPaletteControls;
    +        $timeout( () => repaginate($scope, $element) );
    +    }
    +    $scope.toggleShowAllFilters = () => {
    +        $scope.filterSettings.showAllFilters = 
!$scope.filterSettings.showAllFilters;
    +        $timeout( () => repaginate($scope, $element) );
    +    };
    +    $scope.filterSettings = {};
    +
    +    $scope.filters = [
    +        { label: 'Recent', icon: 'clock-o', title: "Recently used and 
standard favorites", limitToOnePage: true,
    +            filterInit: items => {
    +                $scope.recentItems = items.filter( i => i.lastUsed && 
i.lastUsed > 0 );
    +                $scope.recentItems.sort( (a,b) => b.lastUsed - a.lastUsed 
);
    +                return $scope.recentItems; 
    +            }, enabled: false },
    +    ];
    +    $scope.disableFilters = (showFilters) => {
    +        $scope.filters.forEach( f => f.enabled = false );
    +        if (showFilters !== false) $scope.showPaletteControls = true;
    --- End diff --
    
    Could you use curly brackets for the `if` statements in order to be 
consistent with the codebase please? It also makes it easier to read 


---

Reply via email to