igxFilter should represent filter functionality for data source of list-base widgets, like list, tabbar, carousel, etc or their items.
igxFilter as a pipe:
<igx-list> <igx-list-item *ngFor="let item of navItems | igxFilter"></igx-list-item> </igx-list>
igxFilter as a directive:
<igx-list [igxFilter]="filterOptions"> <igx-list-item>Item 1</igx-list-item> <igx-list-item>Item 2</igx-list-item> <igx-list-item>Item 3</igx-list-item> </igx-list>
igxFilter should be able to filter data source of widget as a pipe or to be set as a directive on a widget and to filter its items. It should be highly customizable and should support multiple user scenarios. E.g: filter by "contains", "starts with", "ends with" etc. The igxFilter should not be coupled to any widget, just to operates with its items or datasource.
As developer, I want:
- igxFilter to support many scenarios of filtering: "contains", "starts with", "ends with" etc.
- to manipulate the input and output data: such as input value, items, result
- manage how the filter affect the matched and the dissociable items
- to be able to cancel the filtering
As a end user, I want to:
- type into an input field and the widget should filter its items on every change
You should be able to configure the igxFilter by passing an Options object to it. It should be able to override methods of Options object. Also the default behaviors of method should be implemented. The defined options, set as filterOptions should override the default options of igxFilter.
inputValue- should set the input value (filter value).
key- define a key for datasource.
items- should represent items of widget for scenarios where filter is directive.
Type: Array of objects
get_value- should get value (from datasource or from items, depends on whether igxFilter is pipe or directive) that will be tested with the input value.
Default behavior: if key is provided - should return value from datasource, otherwise should return item element text content.
formatter- should be able to manipulate the original text before matching process.
Default behavior: should return text to lower case.
matchFn- should determine whether the item met the condition.
Default behavior: "contains" should be implemented.
metConditionFn- should be able to manipulate every matched item after the matching test.
Default behavior: the matched item should be shown
overdueConditionFn- should be able to manipulate every dissociable item after the matching test.
Default behavior: dissociable item should be hidden
filtering- it should be triggered before the filtering process.
It should be cancelable by the Boolean property
cancelof the input object.
filtered- it should triggered after the filtering is done.
Use Angular 2 pipe to implement igxFilter - https://angular.io/docs/ts/latest/guide/pipes.html. Filtering the datasource comes as a native purpose of Angular 2 pipes:
A pipe takes in data as input and transforms it to a desired output.
For the part where igxFilter should be set as a directive, some additional implementation will be needed.
- Because the items of the widget will be rendered already, the DOM elements of items should be pass to the igxFilter instead of datasource. Use the options object and it property
itemsto pass them.
OnChangeshook should be used to filter which change is significant for the igxFilter - https://angular.io/docs/ts/latest/api/core/index/OnChanges-class.html. We are looking only for the changes of the input value of igxFilter.
- The pipe should implement PipeTransform interface - https://angular.io/docs/ts/latest/api/core/index/PipeTransform-interface.html. It demands implementation of
transformmethod, where all the filtering logic should be embedded.