@@ -36,9 +36,25 @@ app.filter('star', function() {
3636
3737app . filter ( 'projectsFilter' , function ( ) {
3838 return function ( projects , scope ) {
39- console . info ( scope . filterOrder ) ;
40- projects = scope . orderBy ( scope . projects , ( scope . filterOrder ) ? "-" + scope . filterOrder : "-watchers_count" ) ;
41- return projects . slice ( 0 , scope . projLast ) ;
39+ projects = scope . filter ( 'filter' ) ( scope . projects , scope . searchName ) ;
40+ var newProject = new Array ( ) ;
41+
42+ if ( scope . searchLang || scope . searchOrg ) {
43+ for ( var i = 0 ; i < projects . length ; i ++ ) {
44+ var actProj = projects [ i ] ;
45+
46+ var resLang = scope . filter ( 'filter' ) ( actProj . languages , scope . searchLang ) ;
47+ var resOrg = actProj . org . indexOf ( scope . searchOrg ) ;
48+ console . log ( "Org: " , resOrg ) ;
49+ if ( resLang . length && ( resOrg != - 1 || ! scope . searchOrg ) ) {
50+ newProject . push ( actProj ) ;
51+ }
52+ }
53+ } else {
54+ newProject = projects ;
55+ }
56+ projects = scope . filter ( 'orderBy' ) ( projects , ( scope . filterOrder ) ? scope . filterOrder : "-watchers_count" ) ;
57+ return newProject . slice ( 0 , scope . projLast ) ;
4258 } ;
4359} ) ;
4460
@@ -136,12 +152,7 @@ app.factory("ReposAdobe", function($resource) {
136152this . GitHubCtrl = function ( $scope , $filter , ReposAdobe , OrgsAdobe ) {
137153 //Be able to call math functions
138154 $scope . Math = Math ;
139- $scope . orderBy = function ( data , filter ) {
140- newData = $filter ( 'orderBy' ) ( data , filter ) ;
141- console . info ( newData ) ;
142-
143- return newData ;
144- } ;
155+ $scope . filter = $filter ;
145156
146157 //Loading active
147158 $scope . loading = true ;
@@ -181,9 +192,11 @@ app.factory("GitAdobe", function($resource) {
181192
182193//TODO : Manage offline project list when errors
183194this . OfflineCtrl = function ( $scope , $filter , GitAdobe , OrgsAdobe ) {
195+ //Initialize the project array
196+ $scope . projects = new Array ( ) ;
197+ $scope . languages = new Array ( ) ;
198+
184199 $scope . getOffline = function ( ) {
185- //Initialize the project array
186- $scope . projects = new Array ( ) ;
187200
188201 //Loading active
189202 $scope . loading = true ;
@@ -229,6 +242,7 @@ this.OfflineCtrl = function($scope, $filter, GitAdobe, OrgsAdobe) {
229242 for ( var key in repLang ) {
230243 actProj . languages . push ( { name : key , value : repLang [ key ] } ) ;
231244 actProj . languagesTotal += repLang [ key ] ;
245+ $scope . addLanguage ( { name : key , value : repLang [ key ] } ) ;
232246 } ;
233247 } ) ;
234248 } ) ;
@@ -249,8 +263,26 @@ this.OfflineCtrl = function($scope, $filter, GitAdobe, OrgsAdobe) {
249263 } ) ;
250264
251265 } ) ;
252- } ) ;
253- }
266+ } ,
267+ function ( data , status , headers , config ) {
268+ console . log ( response ) ;
269+ } ) ;
270+ } ;
271+
272+ $scope . addLanguage = function ( lang ) {
273+ var isPresent = false ;
274+
275+ for ( var i = 0 ; i < $scope . languages . length ; i ++ ) {
276+ if ( $scope . languages [ i ] . name == lang . name ) {
277+ isPresent = true ;
278+ }
279+ }
280+
281+ console . log ( lang , isPresent , $scope . languages ) ;
282+ if ( $scope . languages [ lang . key ] ) {
283+ $scope . languages . push ( lang ) ;
284+ }
285+ }
254286} ;
255287
256288
0 commit comments