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_r230389759
  
    --- Diff: ui-modules/blueprint-composer/app/components/catalog-selector/catalog-selector.directive.js ---
    @@ -88,23 +89,42 @@ export function catalogSelectorSearchFilter() {
         return function (items, search) {
             if (search) {
                 return items.filter(function (item) {
    -                return search.toLowerCase().split(' ').reduce( (found, part) => 
    -                    found &&
    -                    FIELDS_TO_SEARCH
    -                        .filter(field => item.hasOwnProperty(field) && item[field])
    -                        .reduce((match, field) => {
    +                item.relevance = 0;
    +                let wordNum = 0;
    +                return search.toLowerCase().split(' ').reduce( (found, part) => {
    +                    wordNum++;
    +                    let fieldNum = 0;
    +                    return found &&
    +                        FIELDS_TO_SEARCH.reduce((match, field) => {
                                 if (match) return true;
    +                            fieldNum++;
    +                            if (!item.hasOwnProperty(field) || !item[field]) return false;
    --- End diff --
    
    it adds 6 lines making the code in my view a lot harder to follow.  there is a reason languages allow one-line if consequents to be inlined :) .  i've done it as you request but hope you see the light and conclude the verbosity is worse than the inconsistency!


---