git.net

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

[GitHub] brooklyn-ui pull request #96: Relevance and other composer tweaks


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

    https://github.com/apache/brooklyn-ui/pull/96#discussion_r230381696
  
    --- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js ---
    @@ -247,11 +266,23 @@ function controller($scope, $element, $timeout, $q, $uibModal, $log, $templateCa
             paletteDragAndDropService.dragEnd();
             tryMarkUsed(item);
         };
    +    
         $scope.sortBy = function (order) {
    -        let newOrder = [].concat($scope.state.currentOrder);
    -        newOrder = newOrder.filter( (o) => o !== order.field );
    -        $scope.state.currentOrder = [order.field].concat(newOrder);
    +        let newFirst = {};
    +        if (order) {
    +            newFirst[order.id] = order;
    +        }
    +        $scope.state.currentOrder = Object.assign(newFirst, $scope.state.currentOrder, newFirst);
    +        $scope.state.currentOrderFields = [];
    +        $scope.state.currentOrderValues = [];
    +        Object.values($scope.state.currentOrder).forEach( it => {
    +            $scope.state.currentOrderValues.push(it);
    +            $scope.state.currentOrderFields.push(it.field);
    +        });
    --- End diff --
    
    it's `O(n)` so i don't think there's any major efficiency savings to be had.  anyway `n=5` so it's moot.  the ugliness is around the multiple different lists but when i tried to use a single more sophisticated object angular didn't detect it was changing so seemed simplest to generate the exact different data structures we want.  i could try to revise them each but that feels more brittle.  so not worth changing in my view.


---