@@ -165,8 +165,95 @@ angular.module('myApp.controllers', [])
165
165
$scope . bugs = [ ] ;
166
166
bzService . getBugs ( $scope . m . whiteboard , function ( data ) {
167
167
$scope . bugs = data ;
168
- $ ( ".selected" , "#milestonesOf" + $routeParams . id ) . removeClass ( "selected" ) ;
169
- $ ( "#milestonesOf" + $routeParams . id ) . show ( ) ;
168
+ $scope . filtered_bugs = data ;
169
+ console . log ( data ) ;
170
+ $scope . whiteboard = "" ;
171
+ $scope . component = "" ;
172
+ $scope . assigned_to = "" ;
173
+ $scope . status = "" ;
174
+ // Multiple filter criteria, Split by commas in the input boxes
175
+ $scope . filter_bug = function ( ) {
176
+ // Splitting the whiteboard input elements.
177
+ whiteboard_split = $scope . whiteboard . split ( ',' ) ;
178
+ $scope . filtered_bugs = [ ] ;
179
+ if ( $scope . whiteboard != "" ) {
180
+ for ( var whiteboardElement = 0 ; whiteboardElement < whiteboard_split . length ; whiteboardElement ++ ) {
181
+ if ( whiteboard_split [ whiteboardElement ] == "" )
182
+ continue ;
183
+ for ( var searchIndex = 0 ; searchIndex < $scope . bugs . length ; searchIndex ++ ) {
184
+ var returnedVal = $scope . bugs [ searchIndex ] . whiteboard . toLowerCase ( ) . search ( whiteboard_split [ whiteboardElement ] . toLowerCase ( ) . trim ( ) ) ;
185
+ if ( returnedVal != - 1 ) {
186
+ $scope . filtered_bugs . push ( $scope . bugs [ searchIndex ] ) ;
187
+ }
188
+ } ;
189
+ } ;
190
+ }
191
+ else {
192
+ $scope . filtered_bugs = $scope . bugs ;
193
+ }
194
+
195
+ // Splitting the component input elements.
196
+ component_split = $scope . component . split ( ',' ) ;
197
+ filtered_bugs_component = [ ] ;
198
+ flag_component = false ;
199
+ if ( $scope . component . length != 0 ) {
200
+ for ( var componentElement = 0 ; componentElement < component_split . length ; componentElement ++ ) {
201
+ if ( component_split [ componentElement ] == "" )
202
+ continue ;
203
+ for ( var searchIndex = 0 ; searchIndex < $scope . filtered_bugs . length ; searchIndex ++ ) {
204
+ for ( var componentIndexArr = 0 ; componentIndexArr < $scope . filtered_bugs [ searchIndex ] . component . length ; componentIndexArr ++ ) {
205
+ var returnedVal = $scope . filtered_bugs [ searchIndex ] . component [ componentIndexArr ] . toLowerCase ( ) . search ( component_split [ componentElement ] . toLowerCase ( ) . trim ( ) ) ;
206
+ if ( returnedVal != - 1 ) {
207
+ flag_component = true ;
208
+ filtered_bugs_component . push ( $scope . filtered_bugs [ searchIndex ] ) ;
209
+ break ;
210
+ }
211
+ } ;
212
+ } ;
213
+ } ;
214
+ $scope . filtered_bugs = filtered_bugs_component ;
215
+ }
216
+
217
+ // Splitting the assignment input elements.
218
+ var flag_assigned = false ;
219
+ assigned_to_split = $scope . assigned_to . split ( ',' ) ;
220
+ var filtered_bugs_assigned = [ ] ;
221
+ if ( ! $scope . assigned_to == "" ) {
222
+ for ( var assignedElement = 0 ; assignedElement < assigned_to_split . length ; assignedElement ++ ) {
223
+ if ( assigned_to_split [ assignedElement ] == "" )
224
+ continue ;
225
+ for ( var assignedIndex = 0 ; assignedIndex < $scope . filtered_bugs . length ; assignedIndex ++ ) {
226
+ var assignedVal = $scope . filtered_bugs [ assignedIndex ] . assigned_to . toLowerCase ( ) . search ( assigned_to_split [ assignedElement ] . toLowerCase ( ) . trim ( ) ) ;
227
+ if ( assignedVal != - 1 ) {
228
+ flag_assigned = true ;
229
+ filtered_bugs_assigned . push ( $scope . filtered_bugs [ assignedIndex ] ) ;
230
+ }
231
+ } ;
232
+ } ;
233
+ $scope . filtered_bugs = filtered_bugs_assigned ;
234
+ }
235
+
236
+ // Splitting the status input element.
237
+ var flag_status = false ;
238
+ status_to_split = $scope . status . split ( ',' ) ;
239
+ var filtered_bugs_status = [ ] ;
240
+ if ( ! $scope . status == "" ) {
241
+ for ( var statusElement = 0 ; statusElement < status_to_split . length ; statusElement ++ ) {
242
+ if ( status_to_split [ statusElement ] == "" )
243
+ continue ;
244
+ for ( var statusIndex = 0 ; statusIndex < $scope . filtered_bugs . length ; statusIndex ++ ) {
245
+ var statusVal = $scope . filtered_bugs [ statusIndex ] . status . toLowerCase ( ) . search ( status_to_split [ statusElement ] . toLowerCase ( ) . trim ( ) ) ;
246
+ if ( statusVal != - 1 ) {
247
+ flag_status = true ;
248
+ filtered_bugs_status . push ( $scope . filtered_bugs [ statusIndex ] ) ;
249
+ }
250
+ } ;
251
+ } ;
252
+ $scope . filtered_bugs = filtered_bugs_status ;
253
+ }
254
+ }
255
+ $ ( '.selected' , '#milestonesOf' + $routeParams . id ) . removeClass ( 'selected' ) ;
256
+ $ ( '#milestonesOf' + $routeParams . id ) . show ( ) ;
170
257
171
258
// Caching data locally for the milestones
172
259
data = { meta : $scope . m , bugs : data }
0 commit comments