|
1 | 1 | angular.module('coala')
|
2 |
| - .directive('projects', ['$http', '$timeout', '$location', 'Languages', 'orderByFilter', function ($http, $timeout, $location, Languages, orderBy) { |
| 2 | + .directive('projects', ['$http', '$timeout', '$location', '$window', 'Languages', 'orderByFilter', function ($http, $timeout, $location, $window, Languages, orderBy) { |
3 | 3 | return {
|
4 | 4 | restrict: 'E',
|
5 | 5 | templateUrl: '/partials/tabs/projects.html',
|
@@ -221,6 +221,7 @@ angular.module('coala')
|
221 | 221 | $scope.projectList = res.data;
|
222 | 222 | $scope.allProjects = res.data;
|
223 | 223 | $scope.projectRequest();
|
| 224 | + $scope.mapReportToProject(); |
224 | 225 | })
|
225 | 226 | }
|
226 | 227 |
|
@@ -397,6 +398,36 @@ angular.module('coala')
|
397 | 398 | }
|
398 | 399 |
|
399 | 400 | $scope.getAllFilters();
|
| 401 | + $scope.redirectToReport = function () { |
| 402 | + $window.open($scope.currentProject.report.url, '_blank'); |
| 403 | + } |
| 404 | + |
| 405 | + $scope.mapReportToProject = function () { |
| 406 | + $http.get('data/reports.liquid') |
| 407 | + .then(function (res) { |
| 408 | + var completedProjects = [] |
| 409 | + angular.forEach($scope.projectList, function(project){ |
| 410 | + if (project.status.includes('completed') && project.mentors.length > 0) { |
| 411 | + completedProjects.push(project) |
| 412 | + } |
| 413 | + }) |
| 414 | + angular.forEach(res.data, function (report) { |
| 415 | + var completed_project = report.project.toLowerCase() |
| 416 | + angular.forEach(completedProjects, function (project) { |
| 417 | + var project_title = project.title.length > 0 ? project.title.toLowerCase() : project.name.toLowerCase() |
| 418 | + if (completed_project === project_title) { |
| 419 | + angular.forEach(project.initiatives, function (initiative) { |
| 420 | + if (report.categories.indexOf(initiative) != -1) { |
| 421 | + report.initiative = initiative |
| 422 | + project.report = report |
| 423 | + return |
| 424 | + } |
| 425 | + }) |
| 426 | + } |
| 427 | + }) |
| 428 | + }) |
| 429 | + }) |
| 430 | + } |
400 | 431 | },
|
401 | 432 | controllerAs: 'lc'
|
402 | 433 | }
|
|
0 commit comments