Commit 38fb02dd9735428ad4aa071377cb353ed3806231
Exists in
master
and in
6 other branches
Merge branch 'merlin' into staging
Showing
26 changed files
with
581 additions
and
338 deletions
Show diff stats
src/app/components/app-paginator/app-paginator.directive.js
0 → 100644
... | ... | @@ -0,0 +1,71 @@ |
1 | +(function() { | |
2 | + 'use strict'; | |
3 | + | |
4 | + angular | |
5 | + .module('dialoga') | |
6 | + .directive('appPaginator', appPaginator); | |
7 | + | |
8 | + /** @ngInject */ | |
9 | + function appPaginator() { | |
10 | + | |
11 | + /** @ngInject */ | |
12 | + function AppPaginatorController($log) { | |
13 | + var vm = this; | |
14 | + | |
15 | + vm.$log = $log; | |
16 | + | |
17 | + vm.init(); | |
18 | + | |
19 | + $log.debug('AppPaginatorController'); | |
20 | + } | |
21 | + | |
22 | + AppPaginatorController.prototype.init = function() { | |
23 | + var vm = this; | |
24 | + | |
25 | + vm.page = vm.page || 1; | |
26 | + vm.perPage = vm.perPage || 20; | |
27 | + vm.total = vm.total || 0; | |
28 | + | |
29 | + if ((vm.total % vm.perPage) === 0) { | |
30 | + vm.pages = vm.total / vm.perPage; | |
31 | + } else { | |
32 | + vm.pages = (vm.total / vm.perPage) + 1; | |
33 | + } | |
34 | + | |
35 | + vm.arraypages = new Array(Math.floor(vm.pages)); | |
36 | + }; | |
37 | + | |
38 | + AppPaginatorController.prototype.showPage = function(pageIndex) { | |
39 | + var vm = this; | |
40 | + | |
41 | + if (pageIndex < 1) { | |
42 | + pageIndex = 1; | |
43 | + } | |
44 | + | |
45 | + if (pageIndex > vm.pages) { | |
46 | + pageIndex = vm.pages; | |
47 | + } | |
48 | + | |
49 | + if (vm.changePage) { | |
50 | + vm.changePage({pageIndex: pageIndex}); | |
51 | + } | |
52 | + }; | |
53 | + | |
54 | + var directive = { | |
55 | + restrict: 'E', | |
56 | + templateUrl: 'app/components/app-paginator/app-paginator.html', | |
57 | + scope: { | |
58 | + page: '=', | |
59 | + perPage: '=', | |
60 | + total: '=', | |
61 | + changePage: '&' | |
62 | + }, | |
63 | + controller: AppPaginatorController, | |
64 | + controllerAs: 'vm', | |
65 | + bindToController: true | |
66 | + }; | |
67 | + | |
68 | + return directive; | |
69 | + } | |
70 | + | |
71 | +})(); | ... | ... |
... | ... | @@ -0,0 +1,17 @@ |
1 | +<nav class="app-paginator" ng-if="vm.arraypages.length > 1"> | |
2 | + <ul class="pagination"> | |
3 | + <li ng-style="{'visibility': (vm.page === 1) ? 'hidden' : 'visible'}"> | |
4 | + <a class="btn-pagination" href="#" aria-label="Previous" ng-click="vm.showPage(vm.page-1)"> | |
5 | + <span aria-hidden="true" class="glyphicon glyphicon-chevron-left pagination-icon"></span> | |
6 | + </a> | |
7 | + </li> | |
8 | + <li ng-repeat="paginas in vm.arraypages track by $index" ng-class="{ 'active' : ($index) === (vm.page - 1) }" > | |
9 | + <a class="btn-pagination" href="#" ng-click="vm.showPage($index + 1)">{{::($index)+1}}</a> | |
10 | + </li> | |
11 | + <li ng-style="{'visibility': (vm.page === vm.arraypages.length) ? 'hidden' : 'visible'}"> | |
12 | + <a class="btn-pagination" href="#" aria-label="Next" ng-click="vm.showPage(vm.page+1)"> | |
13 | + <span aria-hidden="true" class="glyphicon glyphicon-chevron-right pagination-icon"></span> | |
14 | + </a> | |
15 | + </li> | |
16 | + </ul> | |
17 | +</nav> | ... | ... |
... | ... | @@ -0,0 +1,40 @@ |
1 | +.app-paginator { | |
2 | + text-align: center; | |
3 | + | |
4 | + .btn-pagination { | |
5 | + background-color: transparent; | |
6 | + border: none; | |
7 | + border-radius: 100%; | |
8 | + font-weight: bold; | |
9 | + font-size: 20px; | |
10 | + padding: 0px 8px; | |
11 | + width: 28px; | |
12 | + height: 28px; | |
13 | + text-decoration: underline; | |
14 | + color: $defaultblue; | |
15 | + } | |
16 | + | |
17 | + .pagination-icon { | |
18 | + color: $defaultblue; | |
19 | + } | |
20 | + | |
21 | + .pagination > .active > a, | |
22 | + .pagination > .active > a:hover, | |
23 | + .pagination > .active > a:focus, | |
24 | + .pagination > .active > span, | |
25 | + .pagination > .active > span:hover, | |
26 | + .pagination > .active > span:focus { | |
27 | + background-color: $defaultblue; | |
28 | + text-decoration: none; | |
29 | + | |
30 | + } | |
31 | + | |
32 | + .pagination > .disabled > span, | |
33 | + .pagination > .disabled > span:hover, | |
34 | + .pagination > .disabled > span:focus, | |
35 | + .pagination > .disabled > a, | |
36 | + .pagination > .disabled > a:hover, | |
37 | + .pagination > .disabled > a:focus { | |
38 | + background-color: transparent; | |
39 | + } | |
40 | +} | ... | ... |
src/app/components/article-service/article.service.js
... | ... | @@ -96,16 +96,6 @@ |
96 | 96 | } |
97 | 97 | |
98 | 98 | function getProposals (params, cbSuccess, cbError) { |
99 | - // Ex.: /api/v1/articles/103358?fields= | |
100 | - | |
101 | - // var url = service.apiArticles + API.articleId.home; | |
102 | - | |
103 | - // UtilService.get(url, {params: paramsExtended}).then(function(data){ | |
104 | - // cbSuccess(data); | |
105 | - // }).catch(function(error){ | |
106 | - // cbError(error); | |
107 | - // }); | |
108 | - | |
109 | 99 | var paramsExtended = angular.extend({ |
110 | 100 | query: '' |
111 | 101 | }, params); |
... | ... | @@ -253,8 +243,9 @@ |
253 | 243 | // Ex.: /api/v1/search/article?type=ProposalsDiscussionPlugin::Proposal&query=cisternas |
254 | 244 | var url = '/api/v1/search/article'; |
255 | 245 | var paramsExtended = angular.extend({ |
256 | - // 'fields[]': ['id', 'title', 'slug', 'abstract', 'categories', 'setting', 'children_count', 'hits'], | |
257 | - 'type': 'ProposalsDiscussionPlugin::Proposal' | |
246 | + page: 1, | |
247 | + per_page: 20, | |
248 | + type: 'ProposalsDiscussionPlugin::Proposal' | |
258 | 249 | }, params); |
259 | 250 | |
260 | 251 | UtilService.get(url, {params: paramsExtended}).then(function(data){ | ... | ... |
src/app/components/auth/auth.service.js
... | ... | @@ -102,10 +102,13 @@ |
102 | 102 | }); |
103 | 103 | } |
104 | 104 | |
105 | - function forgotPassword (form){ | |
106 | - var url = '/api/v1/forgot_password'; | |
107 | - var data = form.serialize(); | |
108 | - var encodedData = data; | |
105 | + function forgotPassword (data){ | |
106 | + var url = 'http://hom.login.dialoga.gov.br/api/v1/forgot_password'; | |
107 | + var encodedData = ([ | |
108 | + 'value=' + data.login, | |
109 | + 'captcha_text=' + data.captcha_text, | |
110 | + 'txtToken_captcha_serpro_gov_br=' + data.txtToken_captcha_serpro_gov_br | |
111 | + ]).join('&'); | |
109 | 112 | |
110 | 113 | return $http |
111 | 114 | .post(url, encodedData) |
... | ... | @@ -114,11 +117,14 @@ |
114 | 117 | |
115 | 118 | // 'Verifique seu email para efetuar a troca da senha.' |
116 | 119 | $rootScope.$broadcast(AUTH_EVENTS.forgotPasswordSuccess, response); |
120 | + | |
117 | 121 | return response; |
118 | 122 | }, function(response) { |
119 | 123 | // 'Não foi possível requisitar a troca de senha para os dados informados.' |
120 | 124 | $log.debug('AuthService.forgotPassword [FAIL] response', response); |
121 | 125 | $rootScope.$broadcast(AUTH_EVENTS.forgotPasswordFailed); |
126 | + | |
127 | + return response; | |
122 | 128 | }); |
123 | 129 | } |
124 | 130 | ... | ... |
src/app/components/dialoga-service/dialoga.service.js
... | ... | @@ -160,7 +160,7 @@ |
160 | 160 | var result = CACHE.programs.filter(function filterProgramBySlug (program) { |
161 | 161 | var category = program.categories[0]; |
162 | 162 | |
163 | - if(angular.equals(category.id, themeId)) { | |
163 | + if(category && angular.equals(category.id, themeId)) { | |
164 | 164 | return true; |
165 | 165 | } |
166 | 166 | return false; |
... | ... | @@ -226,8 +226,8 @@ |
226 | 226 | ArticleService.searchTopics({query: query}, cbSuccess, cbError); |
227 | 227 | } |
228 | 228 | |
229 | - function searchProposals (query, cbSuccess, cbError) { | |
230 | - ArticleService.searchProposals({query: query}, cbSuccess, cbError); | |
229 | + function searchProposals (params, cbSuccess, cbError) { | |
230 | + ArticleService.searchProposals(params, cbSuccess, cbError); | |
231 | 231 | } |
232 | 232 | |
233 | 233 | function _pipeHandleYoutube (data) { | ... | ... |
src/app/components/proposal-list/proposal-list.directive.js
... | ... | @@ -9,20 +9,16 @@ |
9 | 9 | function proposalList() { |
10 | 10 | |
11 | 11 | /** @ngInject */ |
12 | - function ProposalListController(ArticleService, $state, $scope, $element, $timeout, $log) { | |
12 | + function ProposalListController($state, $element, $timeout, $log) { | |
13 | 13 | $log.debug('ProposalListController'); |
14 | 14 | |
15 | 15 | var vm = this; |
16 | - vm.ArticleService = ArticleService; | |
17 | 16 | vm.$state = $state; |
18 | - vm.$scope = $scope; | |
19 | 17 | vm.$element = $element; |
20 | 18 | vm.$timeout = $timeout; |
21 | 19 | vm.$log = $log; |
22 | 20 | |
23 | 21 | vm.init(); |
24 | - vm.loadData(); | |
25 | - vm.attachListeners(); | |
26 | 22 | } |
27 | 23 | |
28 | 24 | ProposalListController.prototype.init = function () { |
... | ... | @@ -33,75 +29,11 @@ |
33 | 29 | throw { name: 'NotDefined', message: 'The attribute "proposals" is undefined.'}; |
34 | 30 | } |
35 | 31 | |
36 | - if(!vm.perPage){ | |
37 | - vm.perPage = 5; | |
38 | - } | |
39 | - | |
40 | - vm.initPorposalList(); | |
41 | - }; | |
42 | - | |
43 | - ProposalListController.prototype.initPorposalList = function () { | |
44 | - var vm = this; | |
45 | - | |
46 | - vm.currentPageIndex = 0; | |
47 | - | |
48 | - vm.proposalsPerPage = vm.getProposalsPerPage(0); | |
49 | - | |
50 | - vm.proposalsLength = vm.proposals.length; | |
51 | - | |
52 | - | |
53 | - if ((vm.proposalsLength % vm.perPage) === 0) { | |
54 | - vm.pages = vm.proposalsLength / vm.perPage; | |
55 | - } else{ | |
56 | - vm.pages = (vm.proposalsLength / vm.perPage) + 1; | |
57 | - } | |
58 | - | |
59 | - // vm.arraypages = new Array(Math.ceil(vm.pages)); | |
60 | - vm.arraypages = new Array(Math.floor(vm.pages)); | |
61 | - }; | |
62 | - | |
63 | - ProposalListController.prototype.loadData = function () { | |
64 | - // async values | |
65 | - var vm = this; | |
66 | - | |
67 | - // requeue to wait until DOM be created | |
68 | 32 | vm.$timeout(function(){ |
69 | 33 | attachPopover.call(vm); |
70 | 34 | }, 1000); |
71 | 35 | }; |
72 | 36 | |
73 | - ProposalListController.prototype.attachListeners = function () { | |
74 | - var vm = this; | |
75 | - | |
76 | - vm.$scope.$watch('vm.proposals', function(/*newValue, oldValue*/) { | |
77 | - vm.initPorposalList(); | |
78 | - }); | |
79 | - }; | |
80 | - | |
81 | - ProposalListController.prototype.getProposalsPerPage = function (pageIndex) { | |
82 | - var vm = this; | |
83 | - | |
84 | - var initialIndex = pageIndex * vm.perPage; | |
85 | - var finalIndex = initialIndex + vm.perPage; | |
86 | - | |
87 | - return vm.proposals.slice(initialIndex, finalIndex); | |
88 | - }; | |
89 | - | |
90 | - ProposalListController.prototype.showPage = function (pageIndex) { | |
91 | - var vm = this; | |
92 | - | |
93 | - if (pageIndex < 0) { | |
94 | - pageIndex = 0; | |
95 | - } | |
96 | - | |
97 | - if (pageIndex > (vm.arraypages.length-1)) { | |
98 | - pageIndex = vm.arraypages.length-1; | |
99 | - } | |
100 | - | |
101 | - vm.proposalsPerPage = vm.getProposalsPerPage(pageIndex); | |
102 | - vm.currentPageIndex = pageIndex; | |
103 | - }; | |
104 | - | |
105 | 37 | ProposalListController.prototype.showContent = function (proposal) { |
106 | 38 | var vm = this; |
107 | 39 | |
... | ... | @@ -131,8 +63,7 @@ |
131 | 63 | restrict: 'E', |
132 | 64 | templateUrl: 'app/components/proposal-list/proposal-list.html', |
133 | 65 | scope: { |
134 | - proposals: '=', | |
135 | - perPage: '=' | |
66 | + proposals: '=' | |
136 | 67 | }, |
137 | 68 | controller: ProposalListController, |
138 | 69 | controllerAs: 'vm', | ... | ... |
src/app/components/proposal-list/proposal-list.html
1 | 1 | <div class="proposal-list"> |
2 | - <div class="" ng-if="vm.loading"> | |
3 | - <div class="">Carregando...</div> | |
4 | - </div> | |
5 | - <div class="" ng-if="!vm.loading && vm.proposalsPerPage"> | |
2 | + <div class="" ng-if="vm.proposals"> | |
6 | 3 | <table class="table table-striped"> |
7 | 4 | <thead> |
8 | 5 | <tr> |
... | ... | @@ -14,7 +11,7 @@ |
14 | 11 | </tr> |
15 | 12 | </thead> |
16 | 13 | <tbody> |
17 | - <tr ng-repeat="proposal in vm.proposalsPerPage"> | |
14 | + <tr ng-repeat="proposal in vm.proposals"> | |
18 | 15 | <td class="color-theme-fg"> |
19 | 16 | <span class="position">{{::proposal.ranking_position}}º</span> |
20 | 17 | </td> |
... | ... | @@ -38,22 +35,5 @@ |
38 | 35 | </tr> |
39 | 36 | </tbody> |
40 | 37 | </table> |
41 | - <nav ng-if="vm.arraypages.length > 1"> | |
42 | - <ul class="pagination"> | |
43 | - <li ng-style="{'visibility': (vm.currentPageIndex === 0) ? 'hidden' : 'visible'}"> | |
44 | - <a class="btn-pagination" href="#" aria-label="Previous" ng-click="vm.showPage(vm.currentPageIndex-1)"> | |
45 | - <span aria-hidden="true" class="glyphicon glyphicon-chevron-left pagination-icon"></span> | |
46 | - </a> | |
47 | - </li> | |
48 | - <li ng-repeat="paginas in vm.arraypages track by $index" ng-class="{ 'active' : ($index) == vm.currentPageIndex }" > | |
49 | - <a class="btn-pagination" href="#" ng-click="vm.showPage($index)">{{::($index)+1}}</a> | |
50 | - </li> | |
51 | - <li ng-style="{'visibility': (vm.currentPageIndex === (vm.arraypages.length -1)) ? 'hidden' : 'visible'}"> | |
52 | - <a class="btn-pagination" href="#" aria-label="Next" ng-click="vm.showPage(vm.currentPageIndex+1)"> | |
53 | - <span aria-hidden="true" class="glyphicon glyphicon-chevron-right pagination-icon"></span> | |
54 | - </a> | |
55 | - </li> | |
56 | - </ul> | |
57 | - </nav> | |
58 | 38 | </div> |
59 | 39 | </div> | ... | ... |
src/app/components/proposal-list/proposal-list.scss
... | ... | @@ -80,45 +80,4 @@ |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - .btn-pagination { | |
84 | - background-color: transparent; | |
85 | - border: none; | |
86 | - border-radius: 100%; | |
87 | - font-weight: bold; | |
88 | - font-size: 20px; | |
89 | - padding: 0px 8px; | |
90 | - width: 28px; | |
91 | - height: 28px; | |
92 | - text-decoration: underline; | |
93 | - color: $defaultblue; | |
94 | - } | |
95 | - | |
96 | - .pagination-icon { | |
97 | - color: $defaultblue; | |
98 | - } | |
99 | - | |
100 | - .pagination > .active > a, | |
101 | - .pagination > .active > a:hover, | |
102 | - .pagination > .active > a:focus, | |
103 | - .pagination > .active > span, | |
104 | - .pagination > .active > span:hover, | |
105 | - .pagination > .active > span:focus { | |
106 | - background-color: $defaultblue; | |
107 | - text-decoration: none; | |
108 | - | |
109 | - } | |
110 | - | |
111 | - .pagination > .disabled > span, | |
112 | - .pagination > .disabled > span:hover, | |
113 | - .pagination > .disabled > span:focus, | |
114 | - .pagination > .disabled > a, | |
115 | - .pagination > .disabled > a:hover, | |
116 | - .pagination > .disabled > a:focus { | |
117 | - background-color: transparent; | |
118 | - } | |
119 | - | |
120 | - nav { | |
121 | - text-align: center; | |
122 | - } | |
123 | - | |
124 | 83 | } | ... | ... |
src/app/components/social-share/social-share.html
... | ... | @@ -3,11 +3,12 @@ |
3 | 3 | </div> |
4 | 4 | <ul class="social-share list-inline"> |
5 | 5 | <li> |
6 | + <!-- socialshare-via="687948707977695" --> | |
6 | 7 | <a href="#" role="button" |
7 | 8 | socialshare |
8 | 9 | socialshare-provider="facebook" |
9 | 10 | socialshare-type="feed" |
10 | - socialshare-via="687948707977695" | |
11 | + socialshare-via="476168325877872" | |
11 | 12 | socialshare-url="http://dialoga.gov.br" |
12 | 13 | socialshare-redirect-uri="https://dialoga.gov.br/" |
13 | 14 | socialshare-media="http://dialoga.gov.br/images/logo.png" | ... | ... |
src/app/components/util-service/utils.service.js
src/app/index.constants.js
src/app/index.route.js
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | }) |
34 | 34 | .state('recuperar', { |
35 | 35 | url: '/recuperar', |
36 | - ncyBreadcrumb: {label: 'Recuperar'}, | |
36 | + ncyBreadcrumb: {label: 'Recuperar senha'}, | |
37 | 37 | views: { |
38 | 38 | 'main': { |
39 | 39 | templateUrl: 'app/pages/auth/recover.html', |
... | ... | @@ -106,12 +106,12 @@ |
106 | 106 | .state('ranking', { |
107 | 107 | url: '/ranking?tema&programa&filtro', |
108 | 108 | reloadOnSearch: false, |
109 | - ncyBreadcrumb: {label: 'Propostas'}, | |
109 | + ncyBreadcrumb: {label: 'Ranking'}, | |
110 | 110 | views: { |
111 | 111 | 'main': { |
112 | - templateUrl: 'app/pages/propostas/ranking.html', | |
113 | - controller: 'PropostasPageController', | |
114 | - controllerAs: 'pagePropostas' | |
112 | + templateUrl: 'app/pages/ranking/ranking.html', | |
113 | + controller: 'RankingPageController', | |
114 | + controllerAs: 'pageRanking' | |
115 | 115 | } |
116 | 116 | } |
117 | 117 | }) | ... | ... |
src/app/index.run.js
... | ... | @@ -81,7 +81,7 @@ |
81 | 81 | } |
82 | 82 | |
83 | 83 | /** @ngInject */ |
84 | - function runSocialAuth($window, $rootScope, $interval, $log) { | |
84 | + function runSocialAuth($window, $rootScope, $interval) { | |
85 | 85 | |
86 | 86 | $window.oauthClientAction = function(url) { |
87 | 87 | var child = $window.open(url, '_blank'); |
... | ... | @@ -103,7 +103,7 @@ |
103 | 103 | }; |
104 | 104 | |
105 | 105 | $window.addEventListener('message', function(eventMessage) { |
106 | - $log.debug('eventMessage', eventMessage); | |
106 | + // $log.debug('eventMessage', eventMessage); | |
107 | 107 | |
108 | 108 | if (eventMessage.data.message === 'oauthClientPluginResult') { |
109 | 109 | $rootScope.$broadcast('oauthClientPluginResult', eventMessage); | ... | ... |
src/app/layout.scss
... | ... | @@ -123,6 +123,11 @@ |
123 | 123 | margin-left: -2px; |
124 | 124 | } |
125 | 125 | |
126 | +.vertical-padding { | |
127 | + padding-top: 15px; | |
128 | + padding-bottom: 15px; | |
129 | +} | |
130 | + | |
126 | 131 | .no-space-left { margin-left: 0; padding-left: 0;} |
127 | 132 | .no-space-right { margin-right: 0; padding-right: 0;} |
128 | 133 | ... | ... |
src/app/pages/auth/auth.controller.js
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | .controller('AuthPageController', AuthPageController); |
7 | 7 | |
8 | 8 | /** @ngInject */ |
9 | - function AuthPageController($scope, $rootScope, $window, $location, $state, $timeout, $interval, AUTH_EVENTS, AuthService, DialogaService, Session, $log) { | |
9 | + function AuthPageController($scope, $rootScope, $window, $location, $state, $timeout, $interval, APP, AUTH_EVENTS, AuthService, DialogaService, Session, $log) { | |
10 | 10 | var vm = this; |
11 | 11 | |
12 | 12 | vm.$scope = $scope; |
... | ... | @@ -16,6 +16,7 @@ |
16 | 16 | vm.$state = $state; |
17 | 17 | vm.$timeout = $timeout; |
18 | 18 | vm.$interval = $interval; |
19 | + vm.APP = APP; | |
19 | 20 | vm.AUTH_EVENTS = AUTH_EVENTS; |
20 | 21 | vm.AuthService = AuthService; |
21 | 22 | vm.DialogaService = DialogaService; |
... | ... | @@ -172,6 +173,41 @@ |
172 | 173 | }); |
173 | 174 | }; |
174 | 175 | |
176 | + AuthPageController.prototype.submitRecover = function($event, recoverForm) { | |
177 | + var vm = this; | |
178 | + | |
179 | + // get form data | |
180 | + var data = { | |
181 | + login: recoverForm.login.$modelValue, | |
182 | + captcha_text: recoverForm.captcha_text.$modelValue | |
183 | + }; | |
184 | + | |
185 | + // get captcha token | |
186 | + var target = $event.target; | |
187 | + var $target = angular.element(target); | |
188 | + var $captcha = $target.find('[name="txtToken_captcha_serpro_gov_br"]'); | |
189 | + data.txtToken_captcha_serpro_gov_br = $captcha.val(); | |
190 | + | |
191 | + vm.AuthService.forgotPassword(data).then(function(response) { | |
192 | + vm.$log.debug('recover success.response', response); | |
193 | + | |
194 | + vm.successRecoverMessageTitle = 'Pedido enviado sucesso!'; | |
195 | + vm.successRecoverMessage = 'Verifique seu e-mail. Em instantes você receberá um e-mail com um link para redefinir sua senha.'; | |
196 | + // vm.redirectBack(); | |
197 | + }, function(response){ | |
198 | + vm.$log.debug('recover error.response', response); | |
199 | + | |
200 | + var message = response.data.message; | |
201 | + vm.errorRecoverMessage = message; | |
202 | + | |
203 | + if(response.data.code === 500){ | |
204 | + vm.internalError = true; | |
205 | + } | |
206 | + }).catch(function(error){ | |
207 | + vm.$log.debug('recover catch.error', error); | |
208 | + }); | |
209 | + }; | |
210 | + | |
175 | 211 | AuthPageController.prototype.redirectBack = function() { |
176 | 212 | var vm = this; |
177 | 213 | |
... | ... | @@ -216,14 +252,15 @@ |
216 | 252 | |
217 | 253 | AuthPageController.prototype.authWithFacebook = function() { |
218 | 254 | var vm = this; |
219 | - var url = 'http://login.dialoga.gov.br/plugin/oauth_client/facebook?oauth_client_popup=true&id=1'; | |
255 | + // var url = 'http://login.dialoga.gov.br/plugin/oauth_client/facebook?oauth_client_popup=true&id=1'; | |
256 | + var url = 'http://login.dialoga.gov.br/plugin/oauth_client/facebook?oauth_client_popup=true&id=' + vm.APP.facebook_app_id; | |
220 | 257 | vm.$window.oauthClientAction(url); |
221 | 258 | }; |
222 | 259 | |
223 | 260 | AuthPageController.prototype.authWithGooglePlus = function() { |
224 | 261 | var vm = this; |
225 | 262 | |
226 | - var url = 'http://login.dialoga.gov.br/plugin/oauth_client/google_oauth2?oauth_client_popup=true&id=4'; | |
263 | + var url = 'http://login.dialoga.gov.br/plugin/oauth_client/google_oauth2?oauth_client_popup=true&id=' + vm.APP.goople_app_id; | |
227 | 264 | vm.$window.oauthClientAction(url); |
228 | 265 | }; |
229 | 266 | })(); | ... | ... |
src/app/pages/auth/recover.html
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | </div> |
10 | 10 | </div> |
11 | 11 | </div> |
12 | - <section role="main" class="section-gray"> | |
12 | + <section role="main" class="section-gray vertical-padding"> | |
13 | 13 | <div class="container"> |
14 | 14 | <div class="row"> |
15 | 15 | <div ng-if="pageSignin.successRecoverMessage"> |
... | ... | @@ -20,10 +20,15 @@ |
20 | 20 | title="pageSignin.successRecoverMessageTitle || 'Pronto!'" |
21 | 21 | message="pageSignin.successRecoverMessage" |
22 | 22 | ></show-message> |
23 | + <div class="row"> | |
24 | + <div class="col-sm-8 col-sm-offset-4"> | |
25 | + <p><a ui-sref="inicio">Ir para página inicial</a></p> | |
26 | + </div> | |
27 | + </div> | |
23 | 28 | </div> |
24 | 29 | </div> |
25 | 30 | </div> |
26 | - <div ng-if="!pageSignin.currentUser"> | |
31 | + <div ng-if="!pageSignin.successRecoverMessage"> | |
27 | 32 | <br> |
28 | 33 | <div class="col-sm-8 col-sm-offset-2"> |
29 | 34 | <div class="row" ng-if="pageSignin.errorRecoverMessage"> |
... | ... | @@ -38,11 +43,11 @@ |
38 | 43 | </div> |
39 | 44 | <div class="row"> |
40 | 45 | <div class="col-md-12"> |
41 | - <form name="recoverPassForm" ng-submit="pageSignin.submitRecover(pageSignin.credentials)"> | |
46 | + <form name="recoverPassForm" ng-submit="pageSignin.submitRecover($event, recoverPassForm)"> | |
42 | 47 | <div class="form-group"> |
43 | - <label for="inputUsername">E-mail*</label> | |
44 | - <input type="email" id="inputUsername" name="inputUsername" class="form-control input-lg" ng-class="{ 'has-error' : recoverPassForm.inputUsername.$invalid && recoverPassForm.inputUsername.$touched }" ng-model="pageSignin.credentials.username" required /> | |
45 | - <validation-messages field=" recoverPassForm.inputUsername"></validation-messages> | |
48 | + <label for="recover-login">E-mail*</label> | |
49 | + <input type="email" id="recover-login" name="login" class="form-control input-lg" ng-class="{ 'has-error' : recoverPassForm.login.$invalid && recoverPassForm.login.$touched }" ng-model="pageSignin.credentials.username" required /> | |
50 | + <validation-messages field=" recoverPassForm.login"></validation-messages> | |
46 | 51 | </div> |
47 | 52 | <div class="form-group"> |
48 | 53 | <div id="serpro_captcha" class="captcha"> |
... | ... | @@ -52,7 +57,7 @@ |
52 | 57 | </div> |
53 | 58 | <div class="captcha"> |
54 | 59 | <input type="text" name="captcha_text" id="captcha_text" aria-label="Escreva os caracteres do captcha aqui" ng-model="pageSignin.signup.captcha_text" ng-minlength="" ng-maxlength="" required> |
55 | - <validation-messages field="signupForm.captcha_text"></validation-messages> | |
60 | + <validation-messages field="recoverPassForm.captcha_text"></validation-messages> | |
56 | 61 | </div> |
57 | 62 | </div> |
58 | 63 | <div class="form-group"> | ... | ... |
src/app/pages/auth/signin.html
... | ... | @@ -53,6 +53,9 @@ |
53 | 53 | <div class="form-group"> |
54 | 54 | <button class="btn btn-lg btn-block btn-submit" type="submit">Entrar</button> |
55 | 55 | </div> |
56 | + <div class="form-group"> | |
57 | + <a ui-sref="recuperar" class="btn btn-lg btn-link">Esqueci minha senha</a> | |
58 | + </div> | |
56 | 59 | </form> |
57 | 60 | </div> |
58 | 61 | </div> | ... | ... |
src/app/pages/inicio/inicio.controller.js
... | ... | @@ -220,7 +220,7 @@ |
220 | 220 | var filter = vm.$filter('filter'); |
221 | 221 | |
222 | 222 | if (selectedTheme) { |
223 | - output = _filterByCategory(output, selectedTheme); | |
223 | + output = vm._filterByCategory(output, selectedTheme); | |
224 | 224 | } |
225 | 225 | |
226 | 226 | if (query) { |
... | ... | @@ -234,7 +234,9 @@ |
234 | 234 | return output; |
235 | 235 | }; |
236 | 236 | |
237 | - function _filterByCategory (input, category) { | |
237 | + InicioPageController.prototype._filterByCategory = function (input, category) { | |
238 | + var vm = this; | |
239 | + | |
238 | 240 | input = input || []; |
239 | 241 | |
240 | 242 | if (!category) { |
... | ... | @@ -245,6 +247,12 @@ |
245 | 247 | var out = []; |
246 | 248 | for (var i = 0; i < input.length; i++) { |
247 | 249 | var program = input[i]; |
250 | + | |
251 | + if(!program.categories || program.categories.length === 0){ | |
252 | + vm.$log.warn('Program without theme (category)', program.slug); | |
253 | + continue; | |
254 | + } | |
255 | + | |
248 | 256 | if (program.categories[0].slug === category.slug) { |
249 | 257 | out.push(program); |
250 | 258 | } | ... | ... |
src/app/pages/programas/programas.controller.js
... | ... | @@ -173,7 +173,7 @@ |
173 | 173 | var filter = vm.$filter('filter'); |
174 | 174 | |
175 | 175 | if (selectedTheme) { |
176 | - output = _filterByCategory(output, selectedTheme); | |
176 | + output = vm._filterByCategory(output, selectedTheme); | |
177 | 177 | } |
178 | 178 | |
179 | 179 | if (query) { |
... | ... | @@ -181,13 +181,15 @@ |
181 | 181 | } |
182 | 182 | |
183 | 183 | if(!query && !selectedTheme && vm._showAllFlag){ |
184 | - output = _balanceByCategory(output); | |
184 | + output = vm._balanceByCategory(output); | |
185 | 185 | } |
186 | 186 | |
187 | 187 | return output; |
188 | 188 | }; |
189 | 189 | |
190 | - function _filterByCategory (input, category) { | |
190 | + ProgramasPageController.prototype._filterByCategory = function (input, category) { | |
191 | + var vm = this; | |
192 | + | |
191 | 193 | input = input || []; |
192 | 194 | |
193 | 195 | if (!category) { |
... | ... | @@ -198,6 +200,12 @@ |
198 | 200 | var out = []; |
199 | 201 | for (var i = 0; i < input.length; i++) { |
200 | 202 | var program = input[i]; |
203 | + | |
204 | + if(!program.categories || program.categories.length === 0){ | |
205 | + vm.$log.warn('Program without theme (category)', program.slug); | |
206 | + continue; | |
207 | + } | |
208 | + | |
201 | 209 | if (program.categories[0].slug === category.slug) { |
202 | 210 | out.push(program); |
203 | 211 | } |
... | ... | @@ -206,13 +214,21 @@ |
206 | 214 | return out; |
207 | 215 | } |
208 | 216 | |
209 | - function _balanceByCategory (input) { | |
217 | + ProgramasPageController.prototype._balanceByCategory = function (input) { | |
218 | + var vm = this; | |
219 | + | |
210 | 220 | var result = []; |
211 | 221 | var resultByCategory = {}; |
212 | 222 | |
213 | 223 | // divide by categories |
214 | 224 | for (var i = 0; i < input.length; i++) { |
215 | 225 | var program = input[i]; |
226 | + | |
227 | + if(!program.categories || program.categories.length === 0){ | |
228 | + vm.$log.warn('Program without theme (category)', program.slug); | |
229 | + continue; | |
230 | + } | |
231 | + | |
216 | 232 | var categorySlug = program.categories[0].slug; |
217 | 233 | |
218 | 234 | if (!resultByCategory[categorySlug]) { | ... | ... |
src/app/pages/propostas/propostas.controller.js
1 | -/** | |
2 | - * Controlador das páginas: | |
3 | - * - Propostas | |
4 | - * - Ranking | |
5 | - */ | |
6 | 1 | (function() { |
7 | 2 | 'use strict'; |
8 | 3 | |
... | ... | @@ -50,10 +45,7 @@ |
50 | 45 | |
51 | 46 | // Behaviour: |
52 | 47 | // 1. Load themes |
53 | - // 2. Select a Random Theme (T) | |
54 | - // 3. Load programs of T | |
55 | - // 4. Select a random program of T | |
56 | - // 5. Filter the list of proposals | |
48 | + // 1. Load Proposals per_page | |
57 | 49 | // END. |
58 | 50 | |
59 | 51 | // 1. Load themes |
... | ... | @@ -63,30 +55,8 @@ |
63 | 55 | vm.loadingThemes = false; |
64 | 56 | vm.loading = false; |
65 | 57 | |
66 | - // 2. Select a Random Theme (T) | |
67 | - var selectedTheme = null; | |
68 | - if(vm.search.tema){ | |
69 | - | |
70 | - // vanilla filter | |
71 | - var results = vm.themes.filter(function(t){ | |
72 | - return t.slug === vm.search.tema; | |
73 | - }); | |
74 | - | |
75 | - if(results && results.length > 0){ | |
76 | - selectedTheme = results[0]; | |
77 | - vm.selectedTheme = selectedTheme; | |
78 | - } | |
79 | - } | |
80 | - | |
81 | - if(!selectedTheme){ | |
82 | - vm.selectedTheme = vm.themes[Math.floor(Math.random() * vm.themes.length)]; | |
83 | - } | |
84 | - | |
85 | - // 3. Load programs of T | |
86 | - // (AND 4) | |
87 | - var themeId = vm.selectedTheme.id; | |
88 | - vm.loadPrograms(themeId, function(){ | |
89 | - vm.loadProposals(); | |
58 | + vm.loadProposals(function (){ | |
59 | + vm.attachListeners(); | |
90 | 60 | }); |
91 | 61 | }, function (error) { |
92 | 62 | vm.error = error; |
... | ... | @@ -96,44 +66,7 @@ |
96 | 66 | }); |
97 | 67 | }; |
98 | 68 | |
99 | - PropostasPageController.prototype.loadPrograms = function (themeId, cb) { | |
100 | - var vm = this; | |
101 | - | |
102 | - vm.DialogaService.getProgramsByThemeId(themeId, function (programs){ | |
103 | - | |
104 | - vm.filtredPrograms = programs; | |
105 | - | |
106 | - // 4. Select a random program of T | |
107 | - var selectedProgram = null; | |
108 | - if(vm.search.programa){ | |
109 | - | |
110 | - // vanilla filter | |
111 | - var results = vm.filtredPrograms.filter(function(p){ | |
112 | - return p.slug === vm.search.programa; | |
113 | - }); | |
114 | - | |
115 | - if(results && results.length > 0){ | |
116 | - selectedProgram = results[0]; | |
117 | - vm.selectedProgram = selectedProgram; | |
118 | - } | |
119 | - } | |
120 | - | |
121 | - if(!selectedProgram){ | |
122 | - vm.selectedProgram = vm.filtredPrograms[Math.floor(Math.random() * vm.filtredPrograms.length)]; | |
123 | - } | |
124 | - | |
125 | - if(cb){ | |
126 | - cb(); | |
127 | - } | |
128 | - }, function(error){ | |
129 | - vm.$log.error(error); | |
130 | - if(cb){ | |
131 | - cb(); | |
132 | - } | |
133 | - }); | |
134 | - }; | |
135 | - | |
136 | - PropostasPageController.prototype.loadProposals = function () { | |
69 | + PropostasPageController.prototype.loadProposals = function (cb) { | |
137 | 70 | var vm = this; |
138 | 71 | |
139 | 72 | // load Proposals |
... | ... | @@ -144,7 +77,9 @@ |
144 | 77 | vm.loadingProposals = false; |
145 | 78 | vm.loading = false; |
146 | 79 | |
147 | - vm.attachListeners(); | |
80 | + if(cb){ | |
81 | + cb(); | |
82 | + } | |
148 | 83 | }, function (error) { |
149 | 84 | vm.error = error; |
150 | 85 | vm.$log.error(error); |
... | ... | @@ -163,12 +98,7 @@ |
163 | 98 | vm.$scope.$watch('pagePropostas.selectedTheme', function(newValue, oldValue) { |
164 | 99 | vm.search.tema = newValue ? newValue.slug : null; |
165 | 100 | vm.$location.search('tema', vm.search.tema); |
166 | - | |
167 | - if(vm.selectedTheme && vm.selectedTheme.id){ | |
168 | - vm.loadPrograms(vm.selectedTheme.id, function(){ | |
169 | - vm.filtredProposals = vm.getFiltredProposals(); | |
170 | - }); | |
171 | - } | |
101 | + vm.filtredProposals = vm.getFiltredProposals(); | |
172 | 102 | }); |
173 | 103 | |
174 | 104 | vm.$scope.$on('change-selectedTopic', function (event, selectedTopic) { |
... | ... | @@ -188,17 +118,6 @@ |
188 | 118 | }); |
189 | 119 | }; |
190 | 120 | |
191 | - PropostasPageController.prototype.showAllPrograms = function($event) { | |
192 | - var vm = this; | |
193 | - $event.stopPropagation(); | |
194 | - | |
195 | - vm.resetFilterValues(); | |
196 | - | |
197 | - vm._showAllFlag = true; | |
198 | - | |
199 | - vm.filtredPrograms = vm.getFiltredPrograms(); | |
200 | - }; | |
201 | - | |
202 | 121 | PropostasPageController.prototype.resetFilterValues = function() { |
203 | 122 | var vm = this; |
204 | 123 | |
... | ... | @@ -223,11 +142,11 @@ |
223 | 142 | var filter = vm.$filter('filter'); |
224 | 143 | |
225 | 144 | if (selectedTheme) { |
226 | - output = _filterByCategory(output, selectedTheme); | |
145 | + output = vm._filterByCategory(output, selectedTheme); | |
227 | 146 | } |
228 | 147 | |
229 | 148 | if (selectedProgram) { |
230 | - output = _filterByProgram(output, selectedProgram); | |
149 | + output = vm._filterByProgram(output, selectedProgram); | |
231 | 150 | } |
232 | 151 | |
233 | 152 | if (query) { |
... | ... | @@ -241,7 +160,9 @@ |
241 | 160 | return output; |
242 | 161 | }; |
243 | 162 | |
244 | - function _filterByCategory (input, category) { | |
163 | + PropostasPageController.prototype._filterByCategory = function (input, category) { | |
164 | + var vm = this; | |
165 | + | |
245 | 166 | input = input || []; |
246 | 167 | |
247 | 168 | if (!category) { |
... | ... | @@ -260,7 +181,9 @@ |
260 | 181 | return out; |
261 | 182 | } |
262 | 183 | |
263 | - function _filterByProgram (input, program) { | |
184 | + PropostasPageController.prototype._filterByProgram = function (input, program) { | |
185 | + var vm = this; | |
186 | + | |
264 | 187 | input = input || []; |
265 | 188 | |
266 | 189 | if (!program) { | ... | ... |
src/app/pages/propostas/ranking.html
... | ... | @@ -1,68 +0,0 @@ |
1 | -<div class="container"> | |
2 | - <div class="row"> | |
3 | - <div class="col-sm-12"> | |
4 | - <div ncy-breadcrumb></div> | |
5 | - </div> | |
6 | - </div> | |
7 | -</div> | |
8 | - | |
9 | -<div class="page--propostas"> | |
10 | - <section class="section--info"> | |
11 | - <div class="container"> | |
12 | - <div class="row"> | |
13 | - <div class="col-sm-12"> | |
14 | - <h1>Ranking</h1> | |
15 | - </div> | |
16 | - </div> | |
17 | - </div> | |
18 | - </section> | |
19 | - <section class="section--articles section-gray section-space-up" ng-if="pagePropostas.proposals"> | |
20 | - <div class="container"> | |
21 | - <div id="lista-de-propostas" class="row"> | |
22 | - <div class="col-sm-4 col-md-3"> | |
23 | - <div ng-if="pagePropostas.themes"> | |
24 | - <category-list categories="pagePropostas.themes" selected-category="pagePropostas.selectedTheme" disable-unselect="true"></category-list> | |
25 | - </div> | |
26 | - <div ng-if="pagePropostas.filtredPrograms && pagePropostas.selectedProgram" class="topics-select--wrapper"> | |
27 | - <topics-select topics="pagePropostas.filtredPrograms" selected-topic="pagePropostas.selectedProgram"></topics-select> | |
28 | - </div> | |
29 | - <div ng-if="!pagePropostas.themes && pagePropostas.loadingThemes"> | |
30 | - <div class="alert alert-info" role="alert"> | |
31 | - Carregando temas. | |
32 | - </div> | |
33 | - </div> | |
34 | - <div ng-if="!pagePropostas.themes && pagePropostas.themesError"> | |
35 | - <div class="alert alert-danger" role="alert"> | |
36 | - Não foi possível carregar a lista de temas neste momento. | |
37 | - </div> | |
38 | - </div> | |
39 | - </div> | |
40 | - <div class="col-sm-8 col-md-9"> | |
41 | - <div class="row"> | |
42 | - <div class="col-sm-12"> | |
43 | - <header class="header"> | |
44 | - <h2 style="margin-top:0;">Total de Propostas: "<span>{{pagePropostas.filtredProposals.length}} propostas</span>"</h2> | |
45 | - </header> | |
46 | - </div> | |
47 | - </div> | |
48 | - | |
49 | - <div class="row"> | |
50 | - <div class="col-sm-12" ng-if="pagePropostas.proposals"> | |
51 | - <proposal-list proposals="pagePropostas.filtredProposals" per-page="10"></proposal-list> | |
52 | - </div> | |
53 | - <div ng-if="!pagePropostas.proposals && pagePropostas.loadingProposals"> | |
54 | - <div class="alert alert-info" role="alert"> | |
55 | - Carregando propostas. | |
56 | - </div> | |
57 | - </div> | |
58 | - <div ng-if="!pagePropostas.proposals && pagePropostas.proposalsError"> | |
59 | - <div class="alert alert-danger" role="alert"> | |
60 | - Não foi possível carregar a lista de propostas neste momento. | |
61 | - </div> | |
62 | - </div> | |
63 | - </div> | |
64 | - </div> | |
65 | - </div> | |
66 | - </div> | |
67 | - </section> | |
68 | -</div> |
... | ... | @@ -0,0 +1,239 @@ |
1 | +(function() { | |
2 | + 'use strict'; | |
3 | + | |
4 | + angular | |
5 | + .module('dialoga') | |
6 | + .controller('RankingPageController', RankingPageController); | |
7 | + | |
8 | + /** @ngInject */ | |
9 | + function RankingPageController(DialogaService, $scope, $location, $filter, $log) { | |
10 | + var vm = this; | |
11 | + | |
12 | + vm.DialogaService = DialogaService; | |
13 | + vm.$scope = $scope; | |
14 | + vm.$location = $location; | |
15 | + vm.$filter = $filter; | |
16 | + vm.$log = $log; | |
17 | + | |
18 | + vm.init(); | |
19 | + vm.loadData(); | |
20 | + // vm.attachListeners(); // attach listeners after load data (SYNC) | |
21 | + | |
22 | + $log.debug('RankingPageController'); | |
23 | + } | |
24 | + | |
25 | + RankingPageController.prototype.init = function () { | |
26 | + var vm = this; | |
27 | + | |
28 | + vm.page = 1; | |
29 | + vm.per_page = 20; | |
30 | + vm.themes = null; | |
31 | + vm.selectedTheme = null; | |
32 | + vm.filtredPrograms = null; | |
33 | + vm.selectedProgram = null; | |
34 | + vm.proposals = null; | |
35 | + vm.filtredProposals = null; | |
36 | + vm.query = null; | |
37 | + vm.search = vm.$location.search(); | |
38 | + | |
39 | + vm.loading = null; | |
40 | + vm.error = null; | |
41 | + }; | |
42 | + | |
43 | + RankingPageController.prototype.loadData = function () { | |
44 | + var vm = this; | |
45 | + | |
46 | + vm.loading = true; | |
47 | + | |
48 | + // Behaviour: | |
49 | + // 1. Load themes | |
50 | + // 2. Select a Random Theme (T) | |
51 | + // 3. Load programs of T | |
52 | + // 4. Select a random program of T | |
53 | + // 5. Filter the list of proposals | |
54 | + // END. | |
55 | + | |
56 | + // 1. Load themes | |
57 | + vm.loadingThemes = true; | |
58 | + vm.DialogaService.getThemes(function(themes){ | |
59 | + vm.themes = themes; | |
60 | + vm.loadingThemes = false; | |
61 | + | |
62 | + // 2. Select a Random Theme (T) | |
63 | + var selectedTheme = null; | |
64 | + if(vm.search.tema){ | |
65 | + | |
66 | + // vanilla filter | |
67 | + var results = vm.themes.filter(function(t){ | |
68 | + return t.slug === vm.search.tema; | |
69 | + }); | |
70 | + | |
71 | + if(results && results.length > 0){ | |
72 | + selectedTheme = results[0]; | |
73 | + vm.selectedTheme = selectedTheme; | |
74 | + } | |
75 | + } | |
76 | + | |
77 | + if(!selectedTheme){ | |
78 | + vm.selectedTheme = vm.themes[Math.floor(Math.random() * vm.themes.length)]; | |
79 | + } | |
80 | + | |
81 | + // 3. Load programs of T | |
82 | + // (AND 4) | |
83 | + var themeId = vm.selectedTheme.id; | |
84 | + vm.loadPrograms(themeId, function(){ | |
85 | + vm.loadProposals(); | |
86 | + vm.loading = false; | |
87 | + }); | |
88 | + }, function (error) { | |
89 | + vm.error = error; | |
90 | + vm.$log.error(error); | |
91 | + vm.loadingThemes = false; | |
92 | + vm.loading = false; | |
93 | + }); | |
94 | + }; | |
95 | + | |
96 | + RankingPageController.prototype.loadPrograms = function (themeId, cb) { | |
97 | + var vm = this; | |
98 | + | |
99 | + vm.DialogaService.getProgramsByThemeId(themeId, function (programs){ | |
100 | + | |
101 | + vm.filtredPrograms = programs; | |
102 | + | |
103 | + // 4. Select a random program of T | |
104 | + var selectedProgram = null; | |
105 | + if(vm.search.programa){ | |
106 | + | |
107 | + // vanilla filter | |
108 | + var results = vm.filtredPrograms.filter(function(p){ | |
109 | + return p.slug === vm.search.programa; | |
110 | + }); | |
111 | + | |
112 | + if(results && results.length > 0){ | |
113 | + selectedProgram = results[0]; | |
114 | + vm.selectedProgram = selectedProgram; | |
115 | + } | |
116 | + } | |
117 | + | |
118 | + if(!selectedProgram){ | |
119 | + vm.selectedProgram = vm.filtredPrograms[Math.floor(Math.random() * vm.filtredPrograms.length)]; | |
120 | + } | |
121 | + | |
122 | + if(cb){ | |
123 | + cb(); | |
124 | + } | |
125 | + }, function(error){ | |
126 | + vm.$log.error(error); | |
127 | + if(cb){ | |
128 | + cb(); | |
129 | + } | |
130 | + }); | |
131 | + }; | |
132 | + | |
133 | + RankingPageController.prototype.loadProposals = function () { | |
134 | + var vm = this; | |
135 | + | |
136 | + // load Proposals | |
137 | + vm.loadingProposals = true; | |
138 | + vm.DialogaService.getProposals({ | |
139 | + page: vm.page, | |
140 | + per_page: vm.per_page | |
141 | + }, function(data){ | |
142 | + vm.proposals = data.articles; | |
143 | + vm.filtredProposals = vm.proposals; | |
144 | + vm.loadingProposals = false; | |
145 | + | |
146 | + vm.attachListeners(); | |
147 | + }, function (error) { | |
148 | + vm.error = error; | |
149 | + vm.$log.error(error); | |
150 | + vm.loadingProposals = false; | |
151 | + }); | |
152 | + }; | |
153 | + | |
154 | + RankingPageController.prototype.attachListeners = function() { | |
155 | + var vm = this; | |
156 | + | |
157 | + vm.$scope.$on('change-selectedCategory', function (event, selectedCategory) { | |
158 | + vm.selectedTheme = selectedCategory; | |
159 | + }); | |
160 | + | |
161 | + vm.$scope.$watch('pageRanking.selectedTheme', function(newValue/*, oldValue*/) { | |
162 | + vm.search.tema = newValue ? newValue.slug : null; | |
163 | + vm.$location.search('tema', vm.search.tema); | |
164 | + | |
165 | + if(vm.selectedTheme && vm.selectedTheme.id){ | |
166 | + vm.loadPrograms(vm.selectedTheme.id, function(){ | |
167 | + vm.filterProposals(); | |
168 | + }); | |
169 | + } | |
170 | + }); | |
171 | + | |
172 | + vm.$scope.$on('change-selectedTopic', function (event, selectedTopic) { | |
173 | + vm.selectedProgram = selectedTopic; | |
174 | + }); | |
175 | + | |
176 | + vm.$scope.$watch('pageRanking.selectedProgram', function(newValue/*, oldValue*/) { | |
177 | + vm.search.programa = newValue ? newValue.slug : null; | |
178 | + vm.$location.search('programa', vm.search.programa); | |
179 | + vm.filterProposals(); | |
180 | + }); | |
181 | + | |
182 | + vm.$scope.$watch('pageRanking.query', function(newValue/*, oldValue*/) { | |
183 | + vm.search.filtro = newValue ? newValue : null; | |
184 | + vm.$location.search('filtro', vm.search.filtro); | |
185 | + vm.filterProposals(); | |
186 | + }); | |
187 | + }; | |
188 | + | |
189 | + RankingPageController.prototype.resetFilterValues = function() { | |
190 | + var vm = this; | |
191 | + | |
192 | + vm.query = null; | |
193 | + vm.selectedTheme = null; | |
194 | + }; | |
195 | + | |
196 | + RankingPageController.prototype.changePage = function(pageIndex) { | |
197 | + var vm = this; | |
198 | + | |
199 | + vm.page = pageIndex; | |
200 | + vm.filterProposals(pageIndex); | |
201 | + }; | |
202 | + | |
203 | + RankingPageController.prototype.filterProposals = function(_page, _per_page) { | |
204 | + var vm = this; | |
205 | + | |
206 | + if (vm.loadingProposals){ | |
207 | + vm.$log.debug('Content is not loaded yet.'); | |
208 | + return; | |
209 | + } | |
210 | + | |
211 | + var page = _page || vm.page; | |
212 | + var per_page = _per_page || vm.per_page; | |
213 | + var query = vm.query; | |
214 | + var selectedProgram = vm.selectedProgram; | |
215 | + | |
216 | + if (selectedProgram) { | |
217 | + var params = { | |
218 | + page: page, | |
219 | + per_page: per_page, | |
220 | + parent_id: selectedProgram.id | |
221 | + }; | |
222 | + | |
223 | + if (query) {params.query = query; } | |
224 | + | |
225 | + vm.loadingProposals = true; | |
226 | + vm.DialogaService.searchProposals(params, function(data){ | |
227 | + vm.total_proposals = parseInt(data._obj.headers('total')); | |
228 | + vm.filtredProposals = data.articles; | |
229 | + vm.loadingProposals = false; | |
230 | + }, function (error) { | |
231 | + vm.error = error; | |
232 | + vm.$log.error(error); | |
233 | + vm.loadingProposals = false; | |
234 | + }); | |
235 | + } else { | |
236 | + vm.filtredProposals = []; | |
237 | + } | |
238 | + }; | |
239 | +})(); | ... | ... |
... | ... | @@ -0,0 +1,74 @@ |
1 | +<div class="container"> | |
2 | + <div class="row"> | |
3 | + <div class="col-sm-12"> | |
4 | + <div ncy-breadcrumb></div> | |
5 | + </div> | |
6 | + </div> | |
7 | +</div> | |
8 | + | |
9 | +<div class="page--propostas"> | |
10 | + <section class="section--info"> | |
11 | + <div class="container"> | |
12 | + <div class="row"> | |
13 | + <div class="col-sm-12"> | |
14 | + <h1>Ranking</h1> | |
15 | + </div> | |
16 | + </div> | |
17 | + </div> | |
18 | + </section> | |
19 | + <section class="section--articles section-gray section-space-up" ng-if="pageRanking.proposals"> | |
20 | + <div class="container"> | |
21 | + <div id="lista-de-propostas" class="row"> | |
22 | + <div class="col-sm-4 col-md-3"> | |
23 | + <div ng-if="pageRanking.themes"> | |
24 | + <category-list categories="pageRanking.themes" selected-category="pageRanking.selectedTheme" disable-unselect="true"></category-list> | |
25 | + </div> | |
26 | + <div ng-if="pageRanking.filtredPrograms && pageRanking.selectedProgram" class="topics-select--wrapper"> | |
27 | + <topics-select topics="pageRanking.filtredPrograms" selected-topic="pageRanking.selectedProgram"></topics-select> | |
28 | + </div> | |
29 | + <div ng-if="!pageRanking.themes && pageRanking.loadingThemes"> | |
30 | + <div class="alert alert-info" role="alert"> | |
31 | + Carregando temas. | |
32 | + </div> | |
33 | + </div> | |
34 | + <div ng-if="!pageRanking.themes && pageRanking.themesError"> | |
35 | + <div class="alert alert-danger" role="alert"> | |
36 | + Não foi possível carregar a lista de temas neste momento. | |
37 | + </div> | |
38 | + </div> | |
39 | + </div> | |
40 | + <div class="col-sm-8 col-md-9"> | |
41 | + <div class="row"> | |
42 | + <div class="col-sm-12"> | |
43 | + <header class="header"> | |
44 | + <h2 style="margin-top:0;">Total de Propostas: "<span>{{pageRanking.total_proposals}} propostas</span>"</h2> | |
45 | + </header> | |
46 | + </div> | |
47 | + </div> | |
48 | + | |
49 | + <div class="row"> | |
50 | + <div class="col-sm-12" ng-if="pageRanking.filtredProposals && pageRanking.total_proposals"> | |
51 | + <proposal-list proposals="pageRanking.filtredProposals" per-page="pageRanking.per_page" total="pageRanking.total_proposals"></proposal-list> | |
52 | + <app-paginator | |
53 | + page="pageRanking.page" | |
54 | + per-page="pageRanking.per_page" | |
55 | + total="pageRanking.total_proposals" | |
56 | + change-page="pageRanking.changePage(pageIndex)" | |
57 | + ></app-paginator> | |
58 | + </div> | |
59 | + <div class="col-sm-12" ng-if="pageRanking.loadingProposals"> | |
60 | + <div class="alert alert-info" role="alert"> | |
61 | + Carregando propostas. | |
62 | + </div> | |
63 | + </div> | |
64 | + <div class="col-sm-12" ng-if="pageRanking.proposalsError"> | |
65 | + <div class="alert alert-danger" role="alert"> | |
66 | + Não foi possível carregar a lista de propostas neste momento. | |
67 | + </div> | |
68 | + </div> | |
69 | + </div> | |
70 | + </div> | |
71 | + </div> | |
72 | + </div> | |
73 | + </section> | |
74 | +</div> | ... | ... |
src/assets/images/icons/tema-reducao-da-pobreza-small.png
src/assets/images/icons/tema-reducao-da-pobreza.png