|
14 | 14 | * <li>.id - (String) Optional unique Id for the filter field, useful for comparisons |
15 | 15 | * <li>.title - (String) The title to display for the filter field |
16 | 16 | * <li>.placeholder - (String) Text to display when no filter value has been entered |
17 | | - * <li>.filterType - (String) The filter input field type (any html input type, or 'select' for a single select box) |
18 | | - * <li>.filterValues - (Array) List of valid select values used when filterType is 'select' |
| 17 | + * <li>.filterMultiselect - (Boolean) In `complex-select`, allow selection of multiple values per category. Optional, default is `false` |
| 18 | + * <li>.filterType - (String) The filter input field type (any html input type, or 'select' for a single select box or 'complex-select' for a category select box) |
| 19 | + * <li>.filterValues - (Array) List of valid select values used when filterType is 'select' or 'complex-select' (in where these values serve as case insensitve keys for .filterCategories objects) |
| 20 | + * <li>.filterCategories - (Array of (Objects)) For 'complex-select' only, array of objects whoes keys (case insensitive) match the .filterValues, these objects include each of the filter fields above (sans .placeholder) |
| 21 | + * <li>.filterCategoriesPlaceholder - (String) Text to display in `complex-select` category value select when no filter value has been entered, Optional |
| 22 | + * <li>.filterDelimiter - (String) Delimiter separating 'complex-select' category and value. Optional, default is a space, ' ' |
19 | 23 | * </ul> |
20 | 24 | * <li>.appliedFilters - (Array) List of the currently applied filters |
21 | 25 | * <li>.resultsCount - (int) The number of results returned after the current applied filters have been applied |
|
45 | 49 | <div class="col-md-2"> |
46 | 50 | <span>{{item.birthMonth}}</span> |
47 | 51 | </div> |
| 52 | + <div class="col-md-4"> |
| 53 | + <span>{{item.car}}</span> |
| 54 | + </div> |
48 | 55 | </div> |
49 | 56 | </div> |
50 | 57 | </div> |
|
67 | 74 | { |
68 | 75 | name: "Fred Flintstone", |
69 | 76 | address: "20 Dinosaur Way, Bedrock, Washingstone", |
70 | | - birthMonth: 'February' |
| 77 | + birthMonth: 'February', |
| 78 | + car: 'Toyota-Echo' |
71 | 79 | }, |
72 | 80 | { |
73 | 81 | name: "John Smith", |
74 | 82 | address: "415 East Main Street, Norfolk, Virginia", |
75 | | - birthMonth: 'October' |
| 83 | + birthMonth: 'October', |
| 84 | + car: 'Subaru-Outback' |
| 85 | +
|
76 | 86 | }, |
77 | 87 | { |
78 | 88 | name: "Frank Livingston", |
79 | 89 | address: "234 Elm Street, Pittsburgh, Pennsylvania", |
80 | | - birthMonth: 'March' |
| 90 | + birthMonth: 'March', |
| 91 | + car: 'Toyota-Prius' |
81 | 92 | }, |
82 | 93 | { |
83 | 94 | name: "Judy Green", |
84 | 95 | address: "2 Apple Boulevard, Cincinatti, Ohio", |
85 | | - birthMonth: 'December' |
| 96 | + birthMonth: 'December', |
| 97 | + car: 'Subaru-Impreza' |
86 | 98 | }, |
87 | 99 | { |
88 | 100 | name: "Pat Thomas", |
89 | 101 | address: "50 Second Street, New York, New York", |
90 | | - birthMonth: 'February' |
| 102 | + birthMonth: 'February', |
| 103 | + car: 'Subaru-Outback' |
91 | 104 | } |
92 | 105 | ]; |
93 | 106 | $scope.items = $scope.allItems; |
|
102 | 115 | match = item.address.match(re) !== null; |
103 | 116 | } else if (filter.id === 'birthMonth') { |
104 | 117 | match = item.birthMonth === filter.value; |
| 118 | + } else if (filter.id === 'car') { |
| 119 | + match = item.car === filter.value; |
105 | 120 | } |
106 | 121 | return match; |
107 | 122 | }; |
|
160 | 175 | placeholder: 'Filter by Birth Month', |
161 | 176 | filterType: 'select', |
162 | 177 | filterValues: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] |
| 178 | + }, |
| 179 | + { |
| 180 | + id: 'car', |
| 181 | + title: 'Car', |
| 182 | + placeholder: 'Filter by Car Make', |
| 183 | + filterType: 'complex-select', |
| 184 | + filterValues: ['Subaru', 'Toyota'], |
| 185 | + filterDelimiter: '-', |
| 186 | + filterCategoriesPlaceholder: 'Filter by Car Model', |
| 187 | + filterCategories: {subaru: { |
| 188 | + id: 'subaru', |
| 189 | + title: 'Subaru', |
| 190 | + filterValues: ['Outback', 'Crosstrek', 'Impreza']}, |
| 191 | + toyota: { |
| 192 | + id: 'toyota', |
| 193 | + title: 'Toyota', |
| 194 | + filterValues: ['Prius', 'Corolla', 'Echo']} |
| 195 | + } |
163 | 196 | } |
164 | 197 | ], |
165 | 198 | resultsCount: $scope.items.length, |
|
0 commit comments