Skip to content

Conversation

@dtaylor113
Copy link
Member

Description

Filter Panel with Filter Result Tags which may contain multiple values:

image

Here is the ngDoc. I recommend reading the ngDoc descriptions before reviewing the code -it explains many of the functions and parameters.
I was able to post the ngDoc example by creating a new branch off of this PR branch; then in .gitignore I removed the '/doc' rule, then pushed the new ngDoc branch with all of the /doc files. (Note the rawgit url contains 'pfFilterPanelDocs' branch name).

JIRA: https://patternfly.atlassian.net/browse/OSUX-108
@serenamarie125

PR Checklist

  • Unit tests are included
  • Screenshots are attached (if there are visual changes in the UI)
  • A Designer (@beanh66) is assigned as a reviewer
  • A CSS rep (@cshinn) is assigned as a reviewer
  • Link to example/ngDoc

@serenamarie125
Copy link
Member

@dtaylor113 this looks great!

Just checking that this implementation will not restrict what we need in OpenShift. There we will need the keyword search to match multiple fields associated with the item ( name, description, label, etc ). I'm pretty sure that you already mentioned it's up to the developer using the filter panel, but wanted to verify.

+1 to allowing us to see ngDocs and run the example without having to build 😃 👍

* @description
* The Filter Panel is opened and closed by clicking on the Filter button. It can contain any HTML desired by
* the end user. As such, the end user is repsonsible for constructing the <code>appliedFilters</code> array which is passed to
* the filter results tags.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"end user" should probably say "application" or "application developer"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, Fixed, thanks

updateFilterPanelModel(changedFilterId, changedFilterValue);
} else {
// the 'Clear All Filters' link was clicked
resetFilterPanelModel();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I like this being stated as the way to determine that clear all was clicked. The appliedFilters list would be empty, that is all that should need to be known.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It they click on the 'x' for all the values of all filter, then the appliedFilters list would be empty, but they didn't click on the clear all. I could program it that way, but it's less efficient in the scenario I just mentioned because clicking on the last 'x' would trigger resetFilterPanelModel() which goes through the entire model (as opposed to just clearing the last filter value whose 'x' was clicked)

var matches = true;
_.forEach(filters, function(filter) {
if (!matchesFilter(item, filter)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: would be nice to be consistent in the forEach use, either lodash or array.forEach

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would have to be lodash because we need to break out of these loops and you can't break out of an array.forEach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, switch to lodash _forEach.

<span class="toolbar-pf-results">
<h5>
{{$ctrl.config.resultsCount}}
<span ng-if="$ctrl.config.appliedFilters.length > 0"> of {{$ctrl.config.totalCount}}</span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could remove the '> 0'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

<ul class="list-inline category-values">
<li ng-repeat="value in filter.values">
<span class="active-filter label label-info">{{value}}
<a><span ng-click="$ctrl.clearFilter($parent.$index, $index)" class="pficon pficon-close"></span></a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use filter and value here and not then need to look them up in the controller?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, got a little crazy here, a few rounds of implementation.
Fixed, removed the use of indexes.

}
}

.label-category {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems too generic to me, how about pf-filter-label-category ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}
}
.list-inline > li {
padding-right: 0px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the px

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


.category-option-label {
vertical-align: text-bottom;
font-size: 12px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: alpha

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

background-color: @color-pf-blue-500;
font-weight: 700;
padding-right: 2px;
padding-left: 0px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove px

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

padding-right: 0px;
@media(max-width: @screen-md-min) {
margin-bottom: 3px;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Played with the responsiveness a bunch, there are some issues with the patternfly implementation here and the general layout. I don't think adding the 3px bottom margin does enough to fix this to warrant the need to include bootstrap's variables.less file. I worry that adding that could cause issues for applications pulling in the less files to build (as far as path and overrides and such).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but not sure what you are suggesting? Do more to resolve the responsiveness, remove the bootstrap variables.less usage, perhaps add our own @pf-screen-md-min, etc..?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm suggesting removing the @media setting all together. It doesn't do enough to help with responsiveness to warrant having it and adding in bootstrap's less file dependency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, removed the import of bootstrap variables.less and the use of @media.
Filed Issue #543 to track.

@beanh66
Copy link
Member

beanh66 commented Aug 2, 2017

This looks great @dtaylor113!

@dtaylor113
Copy link
Member Author

it's up to the developer using the filter panel, but wanted to verify.

Yes, the app. developer has complete control on how they want to apply the filters.

@cshinn
Copy link
Member

cshinn commented Aug 2, 2017

@dtaylor113 lgtm

Copy link
Member

@jeff-phillips-18 jeff-phillips-18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @dtaylor113

Copy link
Member

@cdcabrera cdcabrera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, some minor nits related to semicolons and left over comment but overall... kudos!

// called when filter is changed in the filter panel
$scope.filterChanged = function() {
applyFilters();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, missing semicolon..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed

delete $scope.filterPanelModel[0].value;
applyFilters();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, missing semicolon..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

title: filter.title,
values: values
};
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, missing semicolon..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

// do a deep compare on config
if (!angular.equals(ctrl.config, prevConfig)) {
// setupConfig();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, leftover comment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, leftover, removed/fixed.

@dtaylor113
Copy link
Member Author

I believe I've addressed all review issues. Squashed commits. Thanks for the review comments :-)

@jeff-phillips-18 jeff-phillips-18 merged commit 9742960 into patternfly:master Aug 2, 2017
@dtaylor113 dtaylor113 deleted the pfFilterPanel branch October 19, 2017 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants