git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] brooklyn-ui pull request #94: Composer recent and filters


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

    https://github.com/apache/brooklyn-ui/pull/94#discussion_r228904969
  
    --- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js ---
    @@ -65,58 +110,21 @@ export function catalogSelectorSearchFilter() {
         }
     }
     
    -export function catalogSelectorSortFilter($filter) {
    -    return function (items, family) {
    -        return items.sort(function (left, right) {
    -            let nameLeft;
    -            let nameRight;
    -            if (family) {
    -                switch (family) {
    -                    case EntityFamily.ENTITY:
    -                    case EntityFamily.SPEC:
    -                    case EntityFamily.POLICY:
    -                    case EntityFamily.ENRICHER:
    -                    case EntityFamily.LOCATION:
    -                        nameLeft = $filter('entityName')(left);
    -                        nameRight = $filter('entityName')(right);
    -                        break;
    -                }
    -            }
    -
    -            if (!nameLeft || !nameRight) {
    -                return 0;
    -            }
    -            let nameCompare = nameLeft.localeCompare(nameRight);
    -            if (nameCompare !== 0) {
    -                return nameCompare;
    -            }
    -            let versionCompare = right.version.localeCompare(left.version);
    -            if (versionCompare !== 0) {
    -                return versionCompare
    -            }
    -            // TODO should symbolic name be the sorted field?
    -            let symNameCompare = left.symbolicName.localeCompare(right.symbolicName);
    -            if (symNameCompare !== 0) {
    -                return symNameCompare
    -            }            
    -            let containingBundleCompare = right.containingBundle.localeCompare(left.containingBundle);
    -            if (containingBundleCompare !== 0) {
    -                return containingBundleCompare
    -            }            
    -            return 0;
    -        });
    -    }
    -}
    +function controller($scope, $element, $timeout, $q, $uibModal, $log, $templateCache, paletteApi, paletteDragAndDropService, iconGenerator, composerOverrides, recentlyUsedService) {
    +    this.$timeout = $timeout;
     
    -function controller($scope, $element, $q, $uibModal, $log, $templateCache, paletteApi, paletteDragAndDropService, iconGenerator, composerOverrides) {
    +    $scope.viewModes = PALETTE_VIEW_MODES;
    +    $scope.viewOrders = PALETTE_VIEW_ORDERS;
    +    
    +    if (!$scope.state) $scope.state = {};
    +    if (!$scope.state.viewMode) $scope.state.viewMode = PALETTE_VIEW_MODES.normal;
    +    if (!$scope.state.currentOrder) $scope.state.currentOrder = [ PALETTE_VIEW_ORDERS.name.field, '-version' ];
    --- 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 


---