@@ -16,16 +16,35 @@ angular.module('crunchinatorApp.controllers')
1616} )
1717
1818. controller ( 'CrunchinatorCtrl' , function CrunchinatorCtrl ( $scope , $http , ENV , CompanyModel , CategoryModel , InvestorModel ) {
19- $scope . select2Options = {
20- minimumInputLength : 2
21- } ;
2219 $scope . environment = ENV ;
2320
2421 $scope . filteredCompaniesList = [ ] ;
2522 $scope . filteredCategoriesList = [ ] ;
2623 $scope . filteredInvestorsList = [ ] ;
2724 $scope . lookingForList = [ ] ;
2825
26+ $scope . select_investor = function ( ) {
27+ if ( $scope . selectedInvestors . indexOf ( $scope . selected_investor ) === - 1 ) {
28+ $scope . selectedInvestors . push ( $scope . selected_investor ) ;
29+ inv_ids = _ . pluck ( $scope . selectedInvestors , 'id' ) ;
30+ $scope . filteredCompanies ( ) ;
31+
32+ $scope . selected_investor = '' ;
33+ $scope . clearLookingFor ( ) ;
34+ }
35+ } ;
36+
37+ $scope . select_company = function ( ) {
38+ if ( $scope . selectedCompanies . indexOf ( $scope . selected_company ) === - 1 ) {
39+ $scope . selectedCompanies . push ( $scope . selected_company ) ;
40+ company_ids = _ . pluck ( $scope . selectedCompanies , 'id' ) ;
41+ $scope . filteredInvestors ( ) ;
42+
43+ $scope . selected_company = '' ;
44+ $scope . clearLookingFor ( ) ;
45+ }
46+ } ;
47+
2948 $scope . geoJsonData = _ . memoize ( function ( filteredCompanies ) {
3049 var geojson = {
3150 'type' : 'FeatureCollection' ,
@@ -50,7 +69,7 @@ angular.module('crunchinatorApp.controllers')
5069 return _ . pluck ( filteredCompanies , 'id' ) . join ( '' ) ;
5170 } ) ;
5271
53- $scope . totalRaisedGraphData = _ . memoize ( function ( filteredCompanies ) {
72+ /* $scope.totalRaisedGraphData = _.memoize(function(filteredCompanies) {
5473 if (!filteredCompanies || !filteredCompanies.length) { return; }
5574 var total_raised_data = [];
5675 for(var i = 1; i <= 10; i++){
@@ -67,7 +86,7 @@ angular.module('crunchinatorApp.controllers')
6786 return total_raised_data;
6887 }, function(filteredCompanies) {
6988 return _.pluck(filteredCompanies, 'id').join('');
70- } ) ;
89+ });*/
7190
7291 $scope . resetSelection = function ( ) {
7392 $scope . selectedCompanies = [ ] ;
@@ -115,7 +134,7 @@ angular.module('crunchinatorApp.controllers')
115134 $scope . filteredCompanies = function ( ) {
116135 if ( crossCompanies ) {
117136 companiesDimension . filterAll ( ) ; //clear filter
118- companiesDimension . filter ( function ( c ) { return ( cat_ids . length === 0 || cat_ids . indexOf ( c . category_id ) > - 1 ) && ( inv_ids . length === 0 || _ . intersection ( c . investor_ids , inv_ids ) . length > 0 ) ; } ) ;
137+ companiesDimension . filter ( function ( c ) { return ( cat_ids . length === 0 || cat_ids . indexOf ( c . category_id ) > - 1 ) && ( inv_ids . length === 0 || _ . intersection ( c . investor_ids [ 0 ] , inv_ids ) . length > 0 ) ; } ) ;
119138
120139 $scope . filteredCompaniesList = companiesByName . bottom ( Infinity ) ;
121140 }
@@ -159,16 +178,11 @@ angular.module('crunchinatorApp.controllers')
159178 var current_count = $scope . lookingForList . length ;
160179 if ( $scope . lookingFor === 'companies' ) {
161180 next_items = $scope . filteredCompaniesList . slice ( current_count , current_count + 50 ) ;
162- console . log ( $scope . filteredCompaniesList . length ) ;
163181 }
164182 else if ( $scope . lookingFor === 'investors' ) {
165183 next_items = $scope . filteredInvestorsList . slice ( current_count , current_count + 50 ) ;
166- console . log ( $scope . filteredInvestorsList . length ) ;
167184 }
168185 $scope . lookingForList = $scope . lookingForList . concat ( next_items ) ;
169-
170- console . log ( next_items ) ;
171-
172186 } ;
173187
174188 $scope . companies = CompanyModel ;
0 commit comments