Commit 3d623c6f84709c00edfa48ec563939de9b1ec134

Authored by Leonardo Merlin
2 parents 96331083 91b68ef5

Merge branch 'merlin' into staging

src/app/components/article-service/article.service.js
... ... @@ -19,6 +19,7 @@
19 19 getTopics: getTopics,
20 20 getTopicById: getTopicById,
21 21 getProposals: getProposals,
  22 + getProposalById: getProposalById,
22 23 getProposalsByTopicId: getProposalsByTopicId,
23 24 getEvents: getEvents,
24 25 subscribeToEvent: subscribeToEvent,
... ... @@ -108,26 +109,18 @@
108 109 // });
109 110  
110 111 //
111   - searchTopics(params, cbSuccess, cbError);
  112 + searchProposals({
  113 + query: ''
  114 + }, cbSuccess, cbError);
112 115 }
113 116  
114   - /**
115   - * Ex.: /api/v1/articles/[article_id]/children?[params]content_type=ProposalsDiscussionPlugin::Proposal
116   - * Ex.: /api/v1/articles/103644/children?limit=20&fields=id,name,slug,abstract,created_by&content_type=ProposalsDiscussionPlugin::Proposal
117   - *
118   - * @param {Integer} topicId topic where has those proposals
119   - * @param {Object} params params for pagination ant others
120   - * @param {Function} cbSuccess callback for success
121   - * @param {Function} cbError callback for error
122   - * @return {Array} [description]
123   - */
124   - function getProposalsByTopicId (topicId, params, cbSuccess, cbError) {
125   - var url = service.apiArticles + topicId + '/children';
  117 + function getProposalById (proposalId, params, cbSuccess, cbError) {
  118 + var url = service.apiArticles + proposalId;
126 119  
127 120 var paramsExtended = angular.extend({
128 121 // 'fields[]': ['id', 'title', 'abstract', 'children', 'children_count', 'ranking_position', 'hits', 'votes_for', 'votes_against'],
129   - // 'limit':'20',
130 122 // 'per_page':'1',
  123 + 'limit':'1',
131 124 'content_type':'ProposalsDiscussionPlugin::Proposal'
132 125 }, params);
133 126  
... ... @@ -137,6 +130,21 @@
137 130 }).catch(function(error){
138 131 cbError(error);
139 132 });
  133 +
  134 + }
  135 +
  136 + /**
  137 + * Ex.: /api/v1/articles/[article_id]/children?[params]content_type=ProposalsDiscussionPlugin::Proposal
  138 + * Ex.: /api/v1/articles/103644/children?limit=20&fields=id,name,slug,abstract,created_by&content_type=ProposalsDiscussionPlugin::Proposal
  139 + *
  140 + * @param {Integer} topicId topic where has those proposals
  141 + * @param {Object} params params for pagination ant others
  142 + * @param {Function} cbSuccess callback for success
  143 + * @param {Function} cbError callback for error
  144 + * @return {Array} [description]
  145 + */
  146 + function getProposalsByTopicId (topicId, params, cbSuccess, cbError) {
  147 + getProposalById(topicId + '/children', params, cbSuccess, cbError);
140 148 }
141 149  
142 150 function getEvents (community_id, params, cbSuccess, cbError) {
... ... @@ -156,19 +164,36 @@
156 164 });
157 165 }
158 166  
159   - function subscribeToEvent (event_id, params, cbSuccess, cbError) {
160   - var url = service.apiArticles + event_id + '/follow';
  167 + function getSubscribers (event_id, params, cbSuccess, cbError) {
  168 + var url = service.apiArticles + event_id + '/followers?_=' + new Date().getTime();
161 169 var paramsExtended = angular.extend({
162   - private_token: API.token
  170 + // 'fields[]': ['id', 'slug', 'title', 'abstract', 'body', 'categories', 'created_at', 'start_date', 'end_date', 'hits'],
  171 + 'content_type':'Event'
163 172 }, params);
164 173  
165   - UtilService.post(url, {params: paramsExtended}).then(function(data){
  174 + UtilService.get(url, {params: paramsExtended}).then(function(data){
166 175 cbSuccess(data.articles);
167 176 }).catch(function(error){
168 177 cbError(error);
169 178 });
170 179 }
171 180  
  181 + function subscribeToEvent (event_id, params, cbSuccess, cbError) {
  182 +
  183 + if(!$rootScope.currentUser){
  184 + cbError({message: 'Usuário não logado.'});
  185 + }
  186 +
  187 + var url = service.apiArticles + event_id + '/follow';
  188 + var encodedParams = 'private_token=' + $rootScope.currentUser.private_token;
  189 +
  190 + UtilService.post(url, encodedParams).then(function(response){
  191 + cbSuccess(response);
  192 + }).catch(function(error){
  193 + cbError(error);
  194 + });
  195 + }
  196 +
172 197 function searchTopics (params, cbSuccess, cbError) {
173 198 // Ex.: /api/v1/search/article?type=ProposalsDiscussionPlugin::Topic&query=cisternas
174 199 var url = '/api/v1/search/article';
... ... @@ -188,11 +213,13 @@
188 213 // Ex.: /api/v1/search/article?type=ProposalsDiscussionPlugin::Proposal&query=cisternas
189 214 var url = '/api/v1/search/article';
190 215 var paramsExtended = angular.extend({
191   - 'fields[]': ['id', 'title', 'slug', 'abstract', 'categories', 'setting', 'children_count', 'hits'],
  216 + // 'fields[]': ['id', 'title', 'slug', 'abstract', 'categories', 'setting', 'children_count', 'hits'],
192 217 'type': 'ProposalsDiscussionPlugin::Proposal'
193 218 }, params);
194 219  
195 220 UtilService.get(url, {params: paramsExtended}).then(function(data){
  221 + _pipeInjectSlugIntoParentProgram(data);
  222 + _pipeSortByRankinPosition(data);
196 223 cbSuccess(data);
197 224 }).catch(function(error){
198 225 cbError(error);
... ... @@ -200,6 +227,9 @@
200 227 }
201 228  
202 229 function _pipeInjectSlugIntoParentProgram(data){
  230 + if(!data.articles && data.article){
  231 + data.articles = [data.article];
  232 + }
203 233 var proposals = data.articles;
204 234 for (var i = proposals.length - 1; i >= 0; i--) {
205 235 var proposal = proposals[i];
... ... @@ -208,5 +238,14 @@
208 238 }
209 239 }
210 240 }
  241 +
  242 + function _pipeSortByRankinPosition(data){
  243 + if(!data.articles && data.article){
  244 + data.articles = [data.article];
  245 + }
  246 + data.articles = data.articles.sort(function(pA, pB){
  247 + return pA.ranking_position - pB.ranking_position;
  248 + });
  249 + }
211 250 }
212 251 })();
... ...
src/app/components/auth-user/auth-user.directive.js
... ... @@ -42,7 +42,6 @@
42 42 AuthUserController.prototype.onClickLogout = function (){
43 43 var vm = this;
44 44  
45   - // TODO: emit event?
46 45 vm.AuthService.logout();
47 46 };
48 47  
... ...
src/app/components/auth/auth.service.js
... ... @@ -130,6 +130,7 @@
130 130 $log.debug('AuthService.login [SUCCESS] response', response);
131 131  
132 132 var currentUser = Session.create(response.data);
  133 + $rootScope.currentUser = currentUser;
133 134  
134 135 $rootScope.$broadcast(AUTH_EVENTS.loginSuccess, currentUser);
135 136 return currentUser;
... ... @@ -142,7 +143,7 @@
142 143 function logout () {
143 144  
144 145 Session.destroy();
145   -
  146 + $rootScope.currentUser = null;
146 147 $rootScope.$broadcast(AUTH_EVENTS.logoutSuccess);
147 148 }
148 149  
... ...
src/app/components/category-list/category-list.directive.js
... ... @@ -65,7 +65,7 @@
65 65 templateUrl: 'app/components/category-list/category-list.html',
66 66 scope: {
67 67 categories: '=',
68   - selectedCategory: '@'
  68 + selectedCategory: '='
69 69 },
70 70 controller: CategoryListController,
71 71 controllerAs: 'vm',
... ...
src/app/components/category-list/category-list.html
... ... @@ -15,7 +15,8 @@
15 15 <span class="category-list--icon-circle" aria-hidden="true" ng-class="category.slug"></span>
16 16 <span class="category-list--icon icon" aria-hidden="true" ng-class="'icon-tema-' + category.slug"></span>
17 17 <span class="category-list--label">{{::category.name}}</span>
18   - <span class="category-list--icon--right glyphicon glyphicon-chevron-right hidden-xs"></span>
  18 + <span class="category-list--icon--right glyphicon glyphicon-chevron-right hidden-xs" ng-hide="vm.selectedCategory.slug === category.slug"></span>
  19 + <span class="category-list--icon--right glyphicon glyphicon-remove hidden-xs" ng-show="vm.selectedCategory.slug === category.slug"></span>
19 20 </button>
20 21 </div>
21 22 </nav>
... ...
src/app/components/event-list/event-list.directive.js
... ... @@ -8,11 +8,12 @@
8 8 /** @ngInject */
9 9 function eventList() {
10 10 /** @ngInject */
11   - function EventListController($scope, $rootScope, $state, $log) {
  11 + function EventListController(ArticleService, $scope, $rootScope, $state, $log) {
12 12 $log.debug('EventListController');
13 13  
14 14 var vm = this;
15 15  
  16 + vm.ArticleService = ArticleService;
16 17 vm.$scope = $scope;
17 18 vm.$rootScope = $rootScope;
18 19 vm.$state = $state;
... ... @@ -39,10 +40,26 @@
39 40 vm.isCollapsed = !vm.isCollapsed;
40 41 };
41 42  
42   - EventListController.prototype.subscribe = function (data) {
  43 + EventListController.prototype.subscribe = function (event_id) {
43 44 var vm = this;
44 45  
45   - vm.$log.debug('data', data);
  46 + vm.$log.debug('event_id', event_id);
  47 +
  48 + if(!vm.$rootScope.currentUser){
  49 + vm.$log.warn('User is not logged in. Redirect to Auth page.');
  50 + vm.$state.go('entrar',{
  51 + redirect_uri: 'state=inicio&task=subscribe&event_id=' + event_id
  52 + },{
  53 + location: true
  54 + });
  55 + }else{
  56 + vm.ArticleService.subscribeToEvent(event_id, {}, function(response){
  57 + vm.$log.debug('response', response);
  58 + }, function(error){
  59 + vm.$log.debug('error', error);
  60 + })
  61 + }
  62 +
46 63 };
47 64  
48 65 var directive = {
... ...
src/app/components/event-list/event-list.html
... ... @@ -59,12 +59,14 @@
59 59 <span class="theme">{{::event.categories[0].name}}</span>
60 60 </td>
61 61 <td align="right">
62   - <b>(?)</b>
63   - <br/>
64   - <span>Inscritos</span>
  62 + <div ng-if="event.followers_count > 0">
  63 + <b>{{::event.followers_count}}</b>
  64 + <br/>
  65 + <span>Inscritos</span>
  66 + </div>
65 67 </td>
66 68 <td align="left">
67   - <button type="button" class="btn color-theme-common-bg" ng-click="vm.subscribe('EVENT_ID')">
  69 + <button type="button" class="btn color-theme-common-bg" ng-click="vm.subscribe(event.id)">
68 70 Inscreva-se
69 71 <span class="sr-only">no bate-papo com (ministro) no dia {event.start_date | date : "dd/MM/yyyy"}} as {{event.start_date | date : "HH:mm"}} horas</span>
70 72 </button>
... ...
src/app/components/navbar/navbar.html
... ... @@ -22,7 +22,7 @@
22 22 <li ui-sref-active="active"><a ui-sref="duvidas">Dúvidas</a></li>
23 23 <li role="separator" class="divider hidden-xs hidden-sm"><span>|</span></li>
24 24 <li class="dropdown">
25   - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Compartilhar <span class="icon icon-social-share-small"></span></a>
  25 + <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Compartilhar <span aria-hidden="true" class="icon icon-social-share-small"></span></a>
26 26 <social-share class="dropdown-menu dropdown-menu-right"></social-share>
27 27 <!-- <ul class="dropdown-menu dropdown-menu-right dropdown-menu-social">
28 28 <li>
... ...
src/app/components/proposal-box/proposal-box.directive.js
... ... @@ -24,14 +24,16 @@
24 24 var vm = this;
25 25  
26 26 if (!vm.vote) { vm.vote = false; }
  27 + if (!vm.focus) { vm.focus = false; }
27 28  
28 29 };
29 30  
30   - ProposalBoxController.prototype.showContent2 = function (topic) {
  31 + ProposalBoxController.prototype.showContent = function (slug) {
31 32 var vm = this;
32 33  
33 34 vm.$state.go('programa-conteudo', {
34   - slug: topic.slug
  35 + slug: slug,
  36 + proposal_id: vm.proposal.id
35 37 }, {
36 38 location: true
37 39 });
... ... @@ -44,7 +46,11 @@
44 46 proposal: '=',
45 47 topic: '=',
46 48 category: '=',
47   - vote: '='
  49 + vote: '=',
  50 + focus: '@'
  51 + // @ -> Text binding / one-way binding
  52 + // = -> Direct model binding / two-way binding
  53 + // & -> Behaviour binding / Method binding
48 54 },
49 55 controller: ProposalBoxController,
50 56 controllerAs: 'vm',
... ...
src/app/components/proposal-box/proposal-box.html
1   -<div class="proposal-box" ng-class="[{'focus': vm.isFocused}, vm.category.slug]">
  1 +<div class="proposal-box" ng-class="[{'focus': vm.focus}, vm.category.slug]">
2 2 <div class="proposal-box--top">
3 3 <div class="proposal-box--theme color-theme-bg-darker">{{::vm.category.name}}</div>
4 4 <div class="proposal-box--program color-theme-bg">{{::vm.topic.title}}</div>
5 5 </div>
6 6 <div class="proposal-box--middle">
7 7 <div class="proposal-box--content">
8   - <div class="proposal-box--content-inner" ng-bind-html="vm.proposal.abstract"></div>
  8 + <div class="proposal-box--content-inner">{{::vm.proposal.abstract}}</div>
9 9 </div>
10   - <div ng-show="!vm.vote" class="proposal-box--join">
11   - <button class="btn btn-link" ng-click="vm.showContent2(vm.topic)">Participe</button>
  10 + <div ng-hide="vm.vote" class="proposal-box--join">
  11 + <button class="btn btn-link color-theme-common-fg" ng-click="vm.showContent(vm.topic.slug)">
  12 + Participe
  13 + <span class="glyphicon glyphicon-menu-right color-theme-common-fg" aria-hidde="true"></span>
  14 + </button>
12 15 </div>
13 16 <div ng-show="vm.vote"class="proposal-box--actions text-center">
14 17 <div class="row">
... ... @@ -43,7 +46,7 @@
43 46 <div class="proposal-box--share">
44 47 <span>COMPARTILHE ESSA <b>PROPOSTA</b></span>
45 48 <div class="dropdown">
46   - <button id="dropdown-share-btn" class="btn btn-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="icon icon-social-share-small" aria-hidden="true"></span></button>
  49 + <button id="dropdown-share-btn" class="btn btn-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-label="Mostrar ou esconder a lista redes sociais para compartilhamento"><span class="icon icon-social-share-small" aria-hidden="true"></span></button>
47 50 <social-share class="dropdown-menu dropdown-menu-right"></social-share>
48 51 </div>
49 52 </div>
... ...
src/app/components/proposal-box/proposal-box.scss
... ... @@ -2,6 +2,7 @@
2 2 background-color: #f1f1f1;
3 3 border-radius: 5px;
4 4 // overflow: hidden;
  5 + margin-bottom: 20px;
5 6  
6 7 &.focus {
7 8 border: 7px solid #000;
... ... @@ -20,6 +21,14 @@
20 21  
21 22 &--middle {
22 23 padding: 30px;
  24 + min-height: 180px;
  25 +
  26 + // position: relative;
  27 + // .proposal-box--join {
  28 + // position: absolute;
  29 + // bottom: 10px;
  30 + // left: 30px;
  31 + // }
23 32 }
24 33  
25 34 &--bottom {
... ... @@ -56,17 +65,27 @@
56 65 margin-top: 10px;
57 66 }
58 67  
  68 + .proposal-box--join {
  69 + .btn {
  70 + font-weight: bold;
  71 + }
  72 + }
  73 +
  74 + .action {
  75 + .glyphicon {
  76 + color: #fff;
  77 + }
  78 + }
  79 +
59 80 .dropdown {
60 81 display: inline-block;
61 82 }
  83 +
62 84 .dropdown-menu {
63 85 padding: 0;
64 86 margin: 0;
65 87 }
66 88  
67   - .glyphicon {
68   - color: #fff;
69   - }
70 89 .icon-circle {
71 90 cursor: pointer;
72 91  
... ...
src/app/components/proposal-grid/proposal-grid.directive.js
... ... @@ -22,7 +22,6 @@
22 22 vm.$location = $location;
23 23 vm.$filter = $filter;
24 24 vm.$log = $log;
25   - vm.defaultLimit = 6;
26 25  
27 26 // initialization
28 27 vm.init();
... ... @@ -30,8 +29,7 @@
30 29 }
31 30  
32 31 ProposalGridController.prototype.init = function() {
33   - // var vm = this;
34   - // vm.programs = null; // scope var
  32 + var vm = this;
35 33 };
36 34  
37 35 ProposalGridController.prototype.attachListeners = function() {
... ...
src/app/components/proposal-list/proposal-list.directive.js
... ... @@ -2,26 +2,27 @@
2 2 'use strict';
3 3  
4 4 angular
5   - .module('dialoga')
6   - .directive('proposalList', proposalList);
  5 + .module('dialoga')
  6 + .directive('proposalList', proposalList);
7 7  
8 8 /** @ngInject */
9 9 function proposalList() {
10 10  
11 11 /** @ngInject */
12   - function ProposalListController(ArticleService, $scope, $element, $timeout, $log) {
  12 + function ProposalListController(ArticleService, $state, $scope, $element, $timeout, $log) {
13 13 $log.debug('ProposalListController');
14 14  
15 15 var vm = this;
16 16 vm.ArticleService = ArticleService;
  17 + vm.$state = $state;
17 18 vm.$scope = $scope;
18 19 vm.$element = $element;
19 20 vm.$timeout = $timeout;
20 21 vm.$log = $log;
21 22  
22 23 vm.init();
23   -
24 24 vm.loadData();
  25 + vm.attachListeners();
25 26 }
26 27  
27 28 ProposalListController.prototype.init = function () {
... ... @@ -36,9 +37,27 @@
36 37 vm.per_page = 5;
37 38 }
38 39  
  40 + vm.initPorposalList();
  41 + };
  42 +
  43 + ProposalListController.prototype.initPorposalList = function () {
  44 + var vm = this;
  45 +
  46 + vm.currentPageIndex = 0;
  47 +
39 48 vm.proposalsPerPage = vm.getProposalsPerPage(0);
40 49  
41 50 vm.proposalsLength = vm.proposals.length;
  51 +
  52 +
  53 + if ((vm.proposalsLength % vm.per_page) === 0) {
  54 + vm.pages = vm.proposalsLength / vm.per_page;
  55 + } else{
  56 + vm.pages = (vm.proposalsLength / vm.per_page) + 1;
  57 + }
  58 +
  59 + // vm.arraypages = new Array(Math.ceil(vm.pages));
  60 + vm.arraypages = new Array(Math.floor(vm.pages));
42 61 };
43 62  
44 63 ProposalListController.prototype.loadData = function () {
... ... @@ -51,6 +70,14 @@
51 70 }, 1000);
52 71 };
53 72  
  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 +
54 81 ProposalListController.prototype.getProposalsPerPage = function (pageIndex) {
55 82 var vm = this;
56 83  
... ... @@ -62,7 +89,28 @@
62 89  
63 90 ProposalListController.prototype.showPage = function (pageIndex) {
64 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 +
65 101 vm.proposalsPerPage = vm.getProposalsPerPage(pageIndex);
  102 + vm.currentPageIndex = pageIndex;
  103 + };
  104 +
  105 + ProposalListController.prototype.showContent = function (proposal) {
  106 + var vm = this;
  107 +
  108 + vm.$state.go('programa-conteudo', {
  109 + slug: proposal.parent.slug,
  110 + proposal_id: proposal.id
  111 + }, {
  112 + location: true
  113 + });
66 114 };
67 115  
68 116 function attachPopover(){
... ...
src/app/components/proposal-list/proposal-list.html
1 1 <div class="proposal-list">
2   - <div class="table-responsive" ng-if="vm.loading">
3   - <div class="table-responsive">Carregando...</div>
4   - </div>
5   - <div class="table-responsive" ng-if="!vm.loading && vm.proposalsPerPage">
6   - <table class="table table-striped">
7   - <thead>
8   - <tr>
9   - <th>
10   - Colocação
11   - <a tabindex="0" class="btn btn-link btn-question" role="button" data-toggle="popover" data-trigger="focus">?</a>
12   - </th>
13   - <th>{{vm.proposals.length}} PROPOSTAS</th>
14   - </tr>
15   - </thead>
16   - <tbody>
17   - <tr ng-repeat="proposal in vm.proposalsPerPage">
18   - <td class="color-theme-fg">
19   - <span class="position">{{::($index+1)}}º</span>
20   - </td>
21   - <td>
22   - <div class="row">
23   - <div class="col-xs-12">
24   - <div class="abstract" ng-bind-html="proposal.abstract"></div>
25   - </div>
26   - </div>
27   - <div class="row row-actions">
28   - <div class="col-md-9">
29   - <button type="button" class="btn btn-link btn-rate color-theme-common-fg">
30   - Avalie esta proposta
31   - <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
32   - </button>
33   - </div>
34   - <div class="col-md-3">
35   - <proposal-stats views="{{::proposal.hits}}" up="{{::proposal.votes_for}}" down="{{::proposal.votes_against}}"></proposal-stats>
36   - </div>
37   - </div>
38   - </td>
39   - </tr>
40   - </tbody>
41   - </table>
42   - <nav>
43   - <ul class="pagination">
44   - <li>
45   - <a href="#" aria-label="Previous">
46   - <span aria-hidden="true">&laquo;</span>
47   - </a>
48   - </li>
49   - <li><a href="#" ng-click="vm.showPage(1)">1</a></li>
50   - <li><a href="#" ng-click="vm.showPage(2)">2</a></li>
51   - <li><a href="#" ng-click="vm.showPage(3)">3</a></li>
52   - <li><a href="#" ng-click="vm.showPage(4)">4</a></li>
53   - <li><a href="#" ng-click="vm.showPage(5)">5</a></li>
54   - <li>
55   - <a href="#" aria-label="Next">
56   - <span aria-hidden="true">&raquo;</span>
57   - </a>
58   - </li>
59   - </ul>
60   - </nav>
61   - </div>
  2 + <div class="table-responsive" ng-if="vm.loading">
  3 + <div class="table-responsive">Carregando...</div>
  4 + </div>
  5 + <div class="table-responsive" ng-if="!vm.loading && vm.proposalsPerPage">
  6 + <table class="table table-striped">
  7 + <thead>
  8 + <tr>
  9 + <th>
  10 + Colocação
  11 + <a tabindex="0" class="btn btn-link btn-question" role="button" data-toggle="popover" data-trigger="focus">?</a>
  12 + </th>
  13 + <th>{{vm.proposals.length}} PROPOSTAS</th>
  14 + </tr>
  15 + </thead>
  16 + <tbody>
  17 + <tr ng-repeat="proposal in vm.proposalsPerPage">
  18 + <td class="color-theme-fg">
  19 + <span class="position">{{::proposal.ranking_position}}º</span>
  20 + </td>
  21 + <td>
  22 + <div class="row">
  23 + <div class="col-xs-12">
  24 + <div class="abstract" ng-bind-html="proposal.abstract"></div>
  25 + </div>
  26 + </div>
  27 + <div class="row row-actions">
  28 + <div class="col-md-8">
  29 + <button type="button" class="btn btn-link btn-rate color-theme-common-fg" ng-click="vm.showContent(proposal)">
  30 + Avalie esta proposta
  31 + <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
  32 + </button>
  33 + </div>
  34 + <div class="col-md-4">
  35 + <proposal-stats class="text-right" views="{{::proposal.hits}}" up="{{::proposal.votes_for}}" down="{{::proposal.votes_against}}"></proposal-stats>
  36 + </div>
  37 + </div>
  38 + </td>
  39 + </tr>
  40 + </tbody>
  41 + </table>
  42 + <nav>
  43 + <ul class="pagination">
  44 + <li ng-class="{ 'disabled' : vm.currentPageIndex == 0}">
  45 + <a class="btn-pagination" href="#" aria-label="Previous" ng-click="vm.showPage(vm.currentPageIndex-1)">
  46 + <span aria-hidden="true" class="glyphicon glyphicon-chevron-left pagination-icon"></span>
  47 + </a>
  48 + </li>
  49 + <li ng-repeat="paginas in vm.arraypages track by $index" ng-class="{ 'active' : ($index) == vm.currentPageIndex }" >
  50 + <a class="btn-pagination" href="#" ng-click="vm.showPage($index)">{{::($index)+1}}</a>
  51 + </li>
  52 + <li ng-class="{ 'disabled' : vm.currentPageIndex == (vm.arraypages.length -1)}">
  53 + <a class="btn-pagination" href="#" aria-label="Next" ng-click="vm.showPage(vm.currentPageIndex+1)">
  54 + <span aria-hidden="true" class="glyphicon glyphicon-chevron-right pagination-icon"></span>
  55 + </a>
  56 + </li>
  57 + </ul>
  58 + </nav>
  59 + </div>
62 60 </div>
... ...
src/app/components/proposal-list/proposal-list.scss
... ... @@ -79,4 +79,42 @@
79 79 background-color: #eaeaea;
80 80 }
81 81 }
  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 +
82 120 }
... ...
src/app/components/social-share/social-share.html
1 1 <ul class="social-share list-inline">
2 2 <li>
3   - <a socialshare
  3 + <a href="#" role="button"
  4 + socialshare
4 5 socialshare-provider="facebook"
5 6 socialshare-url="http://dialoga.gov.br"
6 7 socialshare-text="Conheça o Dialoga Brasil. Dialoga Brasil | O País fica melhor quando VOCÊ PARTICIPA."
7 8 title="Compartilhar no Facebook">
8   - <span class="icon-circle icon-small icon-circle-social-facebook"><span class="icon icon-social-facebook"></span></span>
  9 + <span aria-hidden="true" class="icon-circle icon-small icon-circle-social-facebook"><span class="icon icon-social-facebook"></span></span>
9 10 <span class="sr-only">Compartilhar no Facebook</span>
10 11 </a>
11 12 </li>
12 13 <li>
13   - <a socialshare
  14 + <a href="#" role="button"
  15 + socialshare
14 16 socialshare-provider="twitter"
15 17 socialshare-url="http://dialoga.gov.br"
16 18 socialshare-text="Conheça o Dialoga Brasil. Dialoga Brasil | O País fica melhor quando VOCÊ PARTICIPA."
17 19 socialshare-hastags="dialogabrasil"
18 20 title="Compartilhar no Twitter">
19   - <span class="icon-circle icon-small icon-circle-social-twitter"><span class="icon icon-social-twitter"></span></span>
  21 + <span aria-hidden="true" class="icon-circle icon-small icon-circle-social-twitter"><span class="icon icon-social-twitter"></span></span>
20 22 <span class="sr-only">Compartilhar no Twitter</span>
21 23 </a>
22 24 </li>
23 25 <li>
24   - <a socialshare
25   - socialshare-provider="gplus"
  26 + <a href="#" role="button"
  27 + socialshare
  28 + socialshare-provider="google+"
26 29 socialshare-url="http://dialoga.gov.br"
27 30 socialshare-text="Conheça o Dialoga Brasil. Dialoga Brasil | O País fica melhor quando VOCÊ PARTICIPA."
28 31 title="Compartilhar no Google Plus">
29   - <span class="icon-circle icon-small icon-circle-social-googleplus"><span class="icon icon-social-googleplus"></span></span>
  32 + <span aria-hidden="true" class="icon-circle icon-small icon-circle-social-googleplus"><span class="icon icon-social-googleplus"></span></span>
30 33 <span class="sr-only">Compartilhar no Google Plus</span>
31 34 </a>
32 35 </li>
33 36 <li>
34   - <a href="mailto:contato@dialoga.gov.br?subject=Conheça o Dialoga Brasil" title="Enviar por email">
35   - <span class="icon-circle icon-small icon-circle-social-whatsapp"><span class="icon icon-social-whatsapp"></span></span>
  37 + <a href="whatsapp://send?text=Aqui suas ideias viram propostas e você ajuda a melhorar as ações do governo http://dialoga.gov.br/" title="Compartilhar no WhatsApp">
  38 + <span aria-hidden="true" class="icon-circle icon-small icon-circle-social-whatsapp"><span class="icon icon-social-whatsapp"></span></span>
36 39 <span class="sr-only">Enviar por email</span>
37 40 </a>
38 41 </li>
... ...
src/app/index.route.js
... ... @@ -23,7 +23,7 @@
23 23 }
24 24 })
25 25 .state('entrar', {
26   - url: '/entrar',
  26 + url: '/entrar?redirect_uri',
27 27 ncyBreadcrumb: {label: 'Entrar'},
28 28 views: {
29 29 'header': { templateUrl: 'app/pages/header/header.html' },
... ... @@ -75,7 +75,7 @@
75 75 }
76 76 })
77 77 .state('programas', {
78   - url: '/programas',
  78 + url: '/programas?tema',
79 79 ncyBreadcrumb: {label: 'Programas'},
80 80 views: {
81 81 'header': { templateUrl: 'app/pages/header/header.html' },
... ... @@ -88,7 +88,7 @@
88 88 }
89 89 })
90 90 .state('programa-conteudo', {
91   - url: '/programa/:slug',
  91 + url: '/programa/:slug?proposal_id',
92 92 ncyBreadcrumb: {
93 93 label: '{{$parent.$root.contentTitle}}',
94 94 parent: 'programas'
... ... @@ -104,7 +104,7 @@
104 104 }
105 105 })
106 106 .state('propostas', {
107   - url: '/propostas',
  107 + url: '/propostas?tema',
108 108 ncyBreadcrumb: {label: 'Propostas'},
109 109 views: {
110 110 'header': { templateUrl: 'app/pages/header/header.html' },
... ... @@ -117,14 +117,14 @@
117 117 }
118 118 })
119 119 .state('ranking', {
120   - url: '/ranking',
  120 + url: '/ranking?tema',
121 121 ncyBreadcrumb: {label: 'Propostas'},
122 122 views: {
123 123 'header': { templateUrl: 'app/pages/header/header.html' },
124 124 'main': {
125 125 templateUrl: 'app/pages/propostas/ranking.html',
126 126 controller: 'PropostasPageController',
127   - controllerAs: 'pageRanking'
  127 + controllerAs: 'pagePropostas'
128 128 },
129 129 'footer': { templateUrl: 'app/pages/footer/footer.html' }
130 130 }
... ... @@ -203,6 +203,15 @@
203 203 'footer': { templateUrl: 'app/pages/footer/footer.html' }
204 204 }
205 205 })
  206 + .state('mapa', {
  207 + url: '/mapa',
  208 + ncyBreadcrumb: {label: 'Mapa'},
  209 + views: {
  210 + 'header': { templateUrl: 'app/pages/header/header.html' },
  211 + 'main': { templateUrl: 'app/pages/mapa/mapa.html' },
  212 + 'footer': { templateUrl: 'app/pages/footer/footer.html' }
  213 + }
  214 + })
206 215 ;
207 216  
208 217 $urlRouterProvider.otherwise('/erro');
... ...
src/app/pages/article/article.html
... ... @@ -26,9 +26,15 @@
26 26 <article>
27 27 <header class="container">
28 28 <div class="row">
29   - <h1>{{::pageArticle.article.title}}</h1>
  29 + <div class="col-sm-12">
  30 + <h1>{{::pageArticle.article.title}}</h1>
  31 + </div>
30 32 </div>
31 33 </header>
32   - <div ng-bind-html="pageArticle.article.body"></div>
  34 + <article>
  35 + <div class="container">
  36 + <div ng-bind-html="pageArticle.article.body"></div>
  37 + </div>
  38 + </article>
33 39 </article>
34 40 </div>
... ...
src/app/pages/auth/auth.controller.js
... ... @@ -6,13 +6,13 @@
6 6 .controller('AuthPageController', AuthPageController);
7 7  
8 8 /** @ngInject */
9   - function AuthPageController($scope, $rootScope, AUTH_EVENTS, AuthService, DialogaService, Session, $log) {
10   - $log.debug('AuthPageController');
11   -
  9 + function AuthPageController($scope, $rootScope, $location, $state, AUTH_EVENTS, AuthService, DialogaService, Session, $log) {
12 10 var vm = this;
13 11  
14   - vm.$rootScope = $rootScope;
15 12 vm.$scope = $scope;
  13 + vm.$rootScope = $rootScope;
  14 + vm.$location = $location;
  15 + vm.$state = $state;
16 16 vm.AUTH_EVENTS = AUTH_EVENTS;
17 17 vm.AuthService = AuthService;
18 18 vm.DialogaService = DialogaService;
... ... @@ -21,6 +21,8 @@
21 21  
22 22 vm.init();
23 23 vm.loadData();
  24 +
  25 + vm.$log.debug('AuthPageController');
24 26 }
25 27  
26 28 AuthPageController.prototype.init = function() {
... ... @@ -32,6 +34,12 @@
32 34 vm.terms = null;
33 35 vm.loadingTerms = null;
34 36  
  37 + vm.search = vm.$location.search();
  38 + var redirect = vm.search.redirect_uri || '';
  39 + if(redirect && redirect.length > 0){
  40 + vm.params = JSON.parse('{"' + decodeURI(redirect).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}');
  41 + }
  42 +
35 43 // attach events
36 44 vm.currentUser = vm.Session.getCurrentUser();
37 45  
... ... @@ -78,6 +86,8 @@
78 86 // 'Cadastro efetuado com sucesso.'
79 87 // 'Verifique seu email para confirmar o cadastro.'
80 88  
  89 + // TODO: show messagens and redirect timeout
  90 + vm.redirectBack();
81 91 }, function(response){
82 92 vm.$log.debug('register error.response', response);
83 93  
... ... @@ -92,9 +102,28 @@
92 102 vm.AuthService.login(credentials).then(function(user) {
93 103 // handle view
94 104 vm.$log.debug('user', user);
  105 + vm.redirectBack();
95 106 }, function() {
96 107 // handle view
97 108 });
98 109 };
99 110  
  111 + AuthPageController.prototype.redirectBack = function(){
  112 + var vm = this;
  113 +
  114 + if(!vm.params){
  115 + vm.$log.warn('No redirect params defined.');
  116 + return;
  117 + }
  118 + var state = vm.params.state;
  119 + switch(state){
  120 + case 'inicio':
  121 + vm.$state.go(state, {
  122 + event_id: vm.params.event_id,
  123 + task: vm.params.task
  124 + });
  125 + break;
  126 + }
  127 + }
  128 +
100 129 })();
... ...
src/app/pages/inicio/inicio.controller.js
... ... @@ -33,6 +33,18 @@
33 33 vm.query = null;
34 34 vm.search = vm.$location.search();
35 35  
  36 + if (vm.search.tema) {
  37 + vm._filtredByThemeSlug = vm.search.tema;
  38 + }
  39 +
  40 + if (vm.search.filtro) {
  41 + vm._filtredByQuery = vm.search.filtro;
  42 + }
  43 +
  44 + if (vm.search.tema || vm.search.filtro) {
  45 + vm.loadingFilter = true;
  46 + }
  47 +
36 48 vm.error = null;
37 49  
38 50 vm.loadData();
... ... @@ -42,7 +54,6 @@
42 54 InicioPageController.prototype.loadData = function() {
43 55 var vm = this;
44 56  
45   -
46 57 // Load main content
47 58 vm.loading = true;
48 59 vm.DialogaService.getHome(function(data) {
... ... @@ -77,6 +88,8 @@
77 88 vm.DialogaService.getThemes(function(data) {
78 89 vm.themes = data;
79 90 vm.loadingThemes = false;
  91 +
  92 + vm.filter();
80 93 }, function(error) {
81 94 vm.$log.error('Error on getThemes.', error);
82 95 });
... ... @@ -87,13 +100,38 @@
87 100 vm.programs = vm.article.children;
88 101 vm.filtredPrograms = data.articles;
89 102 vm.loadingPrograms = false;
  103 +
  104 + vm.filter();
90 105 }, function(error) {
91 106 vm.$log.error('Error on getPrograms.', error);
92 107 });
93   -
94   - vm.filter();
95 108 }
  109 + };
  110 +
  111 + InicioPageController.prototype.attachListeners = function() {
  112 + var vm = this;
  113 +
  114 + vm.$scope.$on('change-selectedCategory', function(event, selectedCategory) {
  115 + vm.selectedTheme = selectedCategory;
  116 + });
  117 +
  118 + vm.$scope.$watch('pageInicio.selectedTheme', function(newValue/*, oldValue*/) {
  119 + vm.search.tema = newValue ? newValue.slug : null;
  120 + vm.$location.search('tema', vm.search.tema);
96 121  
  122 + if (!vm.loadingFilter) {
  123 + vm.filtredPrograms = vm.getFiltredPrograms();
  124 + }
  125 + });
  126 +
  127 + vm.$scope.$watch('pageInicio.query', function(newValue/*, oldValue*/) {
  128 + vm.search.filtro = newValue ? newValue : null;
  129 + vm.$location.search('filtro', vm.search.filtro);
  130 +
  131 + if (!vm.loadingFilter) {
  132 + vm.filtredPrograms = vm.getFiltredPrograms();
  133 + }
  134 + });
97 135 };
98 136  
99 137 InicioPageController.prototype.showVideo = function() {
... ... @@ -114,41 +152,32 @@
114 152 vm.article.videoIsLoaded = true;
115 153 };
116 154  
117   - InicioPageController.prototype.attachListeners = function() {
118   - var vm = this;
119   -
120   - vm.$scope.$on('change-selectedCategory', function (event, selectedCategory) {
121   - vm.selectedTheme = selectedCategory;
122   - });
123   -
124   - vm.$scope.$watch('pageInicio.selectedTheme', function(newValue/*, oldValue*/) {
125   - vm.search.tema = newValue ? newValue.slug : null;
126   - vm.$location.search('tema', vm.search.tema);
127   - vm.filtredPrograms = vm.getFiltredPrograms();
128   - });
129   -
130   - vm.$scope.$watch('pageInicio.query', function(newValue/*, oldValue*/) {
131   - vm.search.filtro = newValue ? newValue : null;
132   - vm.$location.search('filtro', vm.search.filtro);
133   - vm.filtredPrograms = vm.getFiltredPrograms();
134   - });
135   - };
136   -
137 155 InicioPageController.prototype.filter = function() {
138 156 var vm = this;
139 157  
140   - if (vm.search && vm.search.tema) {
141   - var slug = vm.search.tema;
142   - vm.$log.debug('filter by theme', slug);
  158 + if (vm.loadingThemes || vm.loadingPrograms) {
  159 + vm.$log.info('No programs or themes loaded yet. Abort.');
  160 + return;
  161 + }
143 162  
144   - vm.DialogaService.getThemeBySlug(slug, function(theme){
  163 + if (vm._filtredByThemeSlug) {
  164 + var slug = vm._filtredByThemeSlug;
  165 +
  166 + vm.DialogaService.getThemeBySlug(slug, function(theme) {
145 167 vm.selectedTheme = theme;
146   - vm.$log.debug('getThemeBySlug.slug', slug);
147   - vm.$log.debug('getThemeBySlug.selectedTheme', theme);
148   - }, function(error){
  168 + }, function(error) {
149 169 vm.$log.error('Error when try to "getThemeBySlug"', error);
150 170 });
151 171 }
  172 +
  173 + if (vm._filtredByQuery) {
  174 + vm.query = vm._filtredByQuery;
  175 + }
  176 +
  177 + if (vm._filtredByThemeSlug || vm._filtredByQuery) {
  178 + vm.filtredPrograms = vm.getFiltredPrograms();
  179 + vm.loadingFilter = false;
  180 + }
152 181 };
153 182  
154 183 InicioPageController.prototype.showAllPrograms = function($event) {
... ... @@ -170,7 +199,7 @@
170 199 InicioPageController.prototype.getFiltredPrograms = function() {
171 200 var vm = this;
172 201  
173   - if(!vm.programs){
  202 + if (!vm.programs) {
174 203 vm.$log.warn('No programs loaded yet. Abort.');
175 204 return null;
176 205 }
... ... @@ -179,9 +208,9 @@
179 208 var output = input;
180 209 var query = vm.query;
181 210 var selectedTheme = vm.selectedTheme;
182   -
  211 +
183 212 var filter = vm.$filter('filter');
184   -
  213 +
185 214 if (selectedTheme) {
186 215 output = _filterByCategory(output, selectedTheme);
187 216 }
... ... @@ -190,7 +219,7 @@
190 219 output = filter(output, query, false);
191 220 }
192 221  
193   - if(!query && !selectedTheme){
  222 + if (!query && !selectedTheme) {
194 223 output = _balanceByCategory(output);
195 224 }
196 225  
... ...
src/app/pages/inicio/inicio.html
1   -<div class="page--inicio">
2   - <section class="section-video" role="main">
  1 +<div class="page--inicio" role="main">
  2 + <section class="section-video">
3 3 <div class="container">
4 4 <div class="row">
5 5 <div class="col-sm-10 col-sm-offset-1">
... ... @@ -80,7 +80,7 @@
80 80 <br/>
81 81 </div>
82 82 </div>
83   - <div ng-if="pageInicio.themes">
  83 + <div ng-if="pageInicio.themes && !vm.loadingFilter">
84 84 <category-list categories="pageInicio.themes" selected-category="pageInicio.selectedTheme"></category-list>
85 85 </div>
86 86 <div ng-if="!pageInicio.themes && pageInicio.loadingThemes">
... ... @@ -123,7 +123,7 @@
123 123 </div>
124 124  
125 125 <div class="row">
126   - <div class="col-sm-12" ng-if="pageInicio.programs">
  126 + <div class="col-sm-12" ng-if="pageInicio.filtredPrograms && !vm.loadingFilter">
127 127 <article-grid articles="pageInicio.filtredPrograms"></article-grid>
128 128 </div>
129 129 <div ng-if="!pageInicio.programs && pageInicio.loadingPrograms">
... ...
src/app/pages/mapa/mapa.html 0 → 100644
... ... @@ -0,0 +1,136 @@
  1 +<div class="container">
  2 + <div class="row">
  3 + <div class="col-sm-11 col-sm-offset-1">
  4 + <h2>Mapa do Site</h2>
  5 + <p>Uma visão geral do conteúdo disponível no site.</p>
  6 + </div>
  7 + </div>
  8 +</div>
  9 +
  10 +<div class="page--mapa">
  11 + <div class="container">
  12 + <div class="row margin-mapa">
  13 + <div class="col-sm-11 col-sm-offset-1">
  14 + <h3 class="font-mapa">Sobre o Dialoga</h3>
  15 +
  16 + <div class="row margin-mapa">
  17 + <h3 class="font-mapa">Programas</h3>
  18 + <div class="col-sm-6">
  19 + <h4 class="font-mapa">Ttulo do tema</h4>
  20 + <ul>
  21 + <li>Titulo do programa</li>
  22 + <li>Titulo do programa</li>
  23 + <li>Titulo do programa</li>
  24 + <li>Titulo do programa</li>
  25 + </ul>
  26 + <h4 class="font-mapa">Ttulo do tema</h4>
  27 + <ul>
  28 + <li>Titulo do programa</li>
  29 + <li>Titulo do programa</li>
  30 + <li>Titulo do programa</li>
  31 + <li>Titulo do programa</li>
  32 + </ul>
  33 + <h4 class="font-mapa">Ttulo do tema</h4>
  34 + <ul>
  35 + <li>Titulo do programa</li>
  36 + <li>Titulo do programa</li>
  37 + <li>Titulo do programa</li>
  38 + <li>Titulo do programa</li>
  39 + </ul>
  40 + </div>
  41 + </div>
  42 + <div class="row margin-mapa">
  43 + <h3 class="font-mapa">Propostas</h3>
  44 + <div class="col-sm-6">
  45 + <h4 class="font-mapa"></h4>
  46 + <ul>
  47 + <li></li>
  48 + </ul>
  49 + <h4 class="font-mapa"></h4>
  50 + <ul>
  51 + <li></li>
  52 + </ul>
  53 + <h4 class="font-mapa"></h4>
  54 + <ul>
  55 + <li></li>
  56 + </ul>
  57 + </div>
  58 + </div>
  59 + <div class="row margin-mapa">
  60 + <h3 class="font-mapa">Ranking</h3>
  61 + <div class="col-sm-6">
  62 + <h4 class="font-mapa"></h4>
  63 + <ul>
  64 + <li></li>
  65 + </ul>
  66 + <h4 class="font-mapa"></h4>
  67 + <ul>
  68 + <li></li>
  69 + </ul>
  70 + <h4 class="font-mapa"></h4>
  71 + <ul>
  72 + <li></li>
  73 + </ul>
  74 + </div>
  75 + </div>
  76 + <div class="row margin-mapa">
  77 + <h3 class="font-mapa">Dúvidas e sugestões</h3>
  78 + <div class="col-sm-6">
  79 + <h4 class="font-mapa"></h4>
  80 + <ol>
  81 + <li>O que é o Dialoga Brasil?</li>
  82 + <li>O que são Programas?</li>
  83 + <li>O que são Propostas</li>
  84 + <li>Quem pode criar propostas e votar nelas?</li>
  85 + <li>O que acontece com as melhores propostas?</li>
  86 + </ol>
  87 + </div>
  88 + </div>
  89 + <div class="row margin-mapa">
  90 + <h3 class="font-mapa">Entrar</h3>
  91 + <div class="col-sm-6">
  92 + <h4 class="font-mapa"></h4>
  93 + <ul>
  94 + <li></li>
  95 + </ul>
  96 + <h4 class="font-mapa"></h4>
  97 + <ul>
  98 + <li></li>
  99 + </ul>
  100 + <h4 class="font-mapa"></h4>
  101 + <ul>
  102 + <li></li>
  103 + </ul>
  104 + </div>
  105 + </div>
  106 + <div class="row margin-mapa">
  107 +
  108 +
  109 + <h3 class="font-mapa">Dialoga nas redes</h3>
  110 + <div class="col-sm-6">
  111 + <h4 class="font-mapa"></h4>
  112 + <ul>
  113 + <li>Rede 1</li>
  114 + <li>Rede 2</li>
  115 + <li>Rede 3</li>
  116 + <li>Rede 4</li>
  117 + </ul>
  118 + </div>
  119 + </div>
  120 + <div class="row margin-mapa">
  121 +
  122 + <h3 class="font-mapa">Compartilhar</h3>
  123 + <div class="col-sm-6">
  124 + <h4 class="font-mapa"></h4>
  125 + <ul>
  126 + <li>Rede 1</li>
  127 + <li>Rede 2</li>
  128 + <li>Rede 3</li>
  129 + <li>Rede 4</li>
  130 + </ul>
  131 + </div>
  132 + </div>
  133 +
  134 + </div>
  135 + </div>
  136 + <button type="button" class="btn btn-link" ui-sref="inicio">retornar à página inicial</button>
... ...
src/app/pages/mapa/mapa.scss 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +.page--mapa {
  2 + background-color: #f9f9f9;
  3 +
  4 + .font-mapa {
  5 + color: $defaultblue;
  6 + font-weight: 600;
  7 + }
  8 +
  9 + .margin-mapa {
  10 + margin-left: 0px;
  11 + margin-right: 0px;
  12 + }
  13 +
  14 +}
... ...
src/app/pages/programas/programa-content.controller.js
... ... @@ -6,13 +6,14 @@
6 6 .controller('ProgramaContentPageController', ProgramaContentPageController);
7 7  
8 8 /** @ngInject */
9   - function ProgramaContentPageController(DialogaService, $state, $scope, $rootScope, $element, $log) {
  9 + function ProgramaContentPageController(DialogaService, $state, $location, $scope, $rootScope, $element, $log) {
10 10 $log.debug('ProgramaContentPageController');
11 11  
12 12 var vm = this;
13 13  
14 14 vm.DialogaService = DialogaService;
15 15 vm.$state = $state;
  16 + vm.$location = $location;
16 17 vm.$scope = $scope;
17 18 vm.$rootScope = $rootScope;
18 19 vm.$element = $element;
... ... @@ -28,6 +29,7 @@
28 29  
29 30 vm.article = null;
30 31 vm.category = null;
  32 + vm.search = vm.$location.search();
31 33  
32 34 vm.error = false;
33 35 };
... ... @@ -68,15 +70,33 @@
68 70 vm.$log.error(error);
69 71 });
70 72  
71   - // get random proposal
72   - vm.DialogaService.getProposalsByTopicId(vm.article.id, {
73   - 'order': 'random()',
74   - 'limit': '1'
75   - }, function(data){
76   - vm.randomProposal = data.articles[0];
77   - }, function (error) {
  73 + if(vm.search.proposal_id){
  74 + var proposalUrlId = vm.search.proposal_id;
  75 + vm.DialogaService.getProposalById(proposalUrlId, {
  76 + 'limit': '1'
  77 + }, _handleSuccessGetProposal, _handleErrorGetProposal);
  78 +
  79 + }else{
  80 + // get random proposal
  81 + vm.DialogaService.getProposalsByTopicId(vm.article.id, {
  82 + 'order': 'random()',
  83 + 'limit': '1'
  84 + }, _handleSuccessGetProposal, _handleErrorGetProposal);
  85 + }
  86 +
  87 + function _handleSuccessGetProposal(data){
  88 + if(data && data.articles){
  89 + vm.randomProposal = data.articles[0];
  90 + }
  91 +
  92 + if(data && data.article){
  93 + vm.randomProposal = data.article;
  94 + }
  95 + }
  96 +
  97 + function _handleErrorGetProposal(error){
78 98 vm.$log.error(error);
79   - });
  99 + }
80 100  
81 101 vm.loading = false;
82 102 }, function(error) {
... ...
src/app/pages/programas/programa.html
... ... @@ -64,7 +64,7 @@
64 64 </div>
65 65 <div class="col-xs-12" ng-if="pageProgramaContent.randomProposal">
66 66 <h3 class="color-theme-fg">Propostas nesse programa</h3>
67   - <proposal-box proposal="pageProgramaContent.randomProposal" topic="pageProgramaContent.article" category="pageProgramaContent.category" vote="false" ></proposal-box>
  67 + <proposal-box proposal="pageProgramaContent.randomProposal" topic="pageProgramaContent.article" category="pageProgramaContent.category" vote="true" focus="{{pageProgramaContent.search.proposal_id}}" ></proposal-box>
68 68 </div>
69 69 <div class="col-xs-12" ng-if="!pageProgramaContent.randomProposal && !(pageProgramaContent.proposalsTopRated && pageProgramaContent.proposalsTopRated.length > 0)">
70 70 <h3>Programas sem propostas</h3>
... ...
src/app/pages/programas/programas.scss
... ... @@ -57,6 +57,10 @@
57 57 vertical-align: middle;
58 58 }
59 59  
  60 + .program-preview--abstract h2 {
  61 + font-size: 40px;
  62 + }
  63 +
60 64 h2,
61 65 h3{
62 66 font-weight: bold;
... ...
src/app/pages/propostas/propostas.controller.js
... ... @@ -11,33 +11,36 @@
11 11 .controller('PropostasPageController', PropostasPageController);
12 12  
13 13 /** @ngInject */
14   - function PropostasPageController(DialogaService, $log) {
  14 + function PropostasPageController(DialogaService, $scope, $location, $filter, $log) {
15 15 var vm = this;
16 16  
17 17 vm.DialogaService = DialogaService;
  18 + vm.$scope = $scope;
  19 + vm.$location = $location;
  20 + vm.$filter = $filter;
18 21 vm.$log = $log;
19 22  
20 23 vm.init();
  24 + vm.loadData();
  25 + vm.attachListeners();
  26 +
21 27 $log.debug('PropostasPageController');
22 28 }
23 29  
24 30 PropostasPageController.prototype.init = function () {
25 31 var vm = this;
26 32  
27   - vm.article = null;
28 33 vm.themes = null;
29 34 vm.selectedTheme = null;
30 35 vm.proposals = null;
31 36 vm.filtredProposals = null;
32 37 vm.query = null;
  38 + vm.search = vm.$location.search();
33 39  
34 40 vm.loading = null;
35 41 vm.error = null;
36   -
37   - vm.loadData();
38 42 };
39 43  
40   -
41 44 PropostasPageController.prototype.loadData = function () {
42 45 var vm = this;
43 46  
... ... @@ -49,10 +52,12 @@
49 52 vm.proposals = data.articles;
50 53 vm.filtredProposals = vm.proposals;
51 54 vm.loadingProposals = false;
  55 + vm.loading = false;
52 56 }, function (error) {
53 57 vm.error = error;
54 58 vm.$log.error(error);
55 59 vm.loadingProposals = false;
  60 + vm.loading = false;
56 61 });
57 62  
58 63 // load themes
... ... @@ -60,10 +65,117 @@
60 65 vm.DialogaService.getThemes(function(themes){
61 66 vm.themes = themes;
62 67 vm.loadingThemes = false;
  68 + vm.loading = false;
63 69 }, function (error) {
64 70 vm.error = error;
65 71 vm.$log.error(error);
66 72 vm.loadingThemes = false;
  73 + vm.loading = false;
  74 + });
  75 + };
  76 +
  77 + PropostasPageController.prototype.attachListeners = function() {
  78 + var vm = this;
  79 +
  80 + vm.$scope.$on('change-selectedCategory', function (event, selectedCategory) {
  81 + vm.selectedTheme = selectedCategory;
  82 + });
  83 +
  84 + vm.$scope.$watch('pagePropostas.selectedTheme', function(newValue/*, oldValue*/) {
  85 + vm.search.tema = newValue ? newValue.slug : null;
  86 + vm.$location.search('tema', vm.search.tema);
  87 + vm.filtredProposals = vm.getFiltredProposals();
67 88 });
  89 +
  90 + vm.$scope.$watch('pagePropostas.query', function(newValue/*, oldValue*/) {
  91 + vm.search.filtro = newValue ? newValue : null;
  92 + vm.$location.search('filtro', vm.search.filtro);
  93 + vm.filtredProposals = vm.getFiltredProposals();
  94 + });
  95 + };
  96 +
  97 + PropostasPageController.prototype.filter = function() {
  98 + var vm = this;
  99 +
  100 + if (vm.search && vm.search.tema) {
  101 + var slug = vm.search.tema;
  102 + vm.$log.debug('filter by theme', slug);
  103 +
  104 + vm.DialogaService.getThemeBySlug(slug, function(theme){
  105 + vm.selectedTheme = theme;
  106 + vm.$log.debug('getThemeBySlug.slug', slug);
  107 + vm.$log.debug('getThemeBySlug.selectedTheme', theme);
  108 + }, function(error){
  109 + vm.$log.error('Error when try to "getThemeBySlug"', error);
  110 + });
  111 + }
68 112 };
  113 +
  114 + PropostasPageController.prototype.showAllPrograms = function($event) {
  115 + var vm = this;
  116 + $event.stopPropagation();
  117 +
  118 + vm.resetFilterValues();
  119 +
  120 + vm._showAllFlag = true;
  121 +
  122 + vm.filtredPrograms = vm.getFiltredPrograms();
  123 + };
  124 +
  125 + PropostasPageController.prototype.resetFilterValues = function() {
  126 + var vm = this;
  127 +
  128 + vm.query = null;
  129 + vm.selectedTheme = null;
  130 + };
  131 +
  132 + PropostasPageController.prototype.getFiltredProposals = function() {
  133 + var vm = this;
  134 +
  135 + if(!vm.proposals){
  136 + vm.$log.warn('No proposals loaded yet. Abort.');
  137 + return null;
  138 + }
  139 +
  140 + var input = vm.proposals;
  141 + var output = input;
  142 + var query = vm.query;
  143 + var selectedTheme = vm.selectedTheme;
  144 +
  145 + var filter = vm.$filter('filter');
  146 +
  147 + if (selectedTheme) {
  148 + output = _filterByCategory(output, selectedTheme);
  149 + }
  150 +
  151 + if (query) {
  152 + output = filter(output, query, false);
  153 + }
  154 +
  155 + // if(!query && !selectedTheme && vm._showAllFlag){
  156 + // output = _balanceByCategory(output);
  157 + // }
  158 +
  159 + return output;
  160 + };
  161 +
  162 + function _filterByCategory (input, category) {
  163 + input = input || [];
  164 +
  165 + if (!category) {
  166 + // no filter
  167 + return input;
  168 + }
  169 +
  170 + var out = [];
  171 + for (var i = 0; i < input.length; i++) {
  172 + var proposal = input[i];
  173 + if (proposal.parent.categories[0].slug === category.slug) {
  174 + out.push(proposal);
  175 + }
  176 + }
  177 +
  178 + return out;
  179 + }
  180 +
69 181 })();
... ...
src/app/pages/propostas/propostas.html
... ... @@ -7,7 +7,26 @@
7 7 </div>
8 8  
9 9 <div class="page--propostas">
10   - <section class="section--info">
  10 +
  11 + <section class="section-info" ng-if="pagePropostas.loading || pagePropostas.error">
  12 + <div class="container">
  13 + <div class="row">
  14 + <div class="col-md-12">
  15 + <div ng-if="pagePropostas.loading && !pagePropostas.error">
  16 + <div class="alert alert-info" role="alert">Carregando conteúdo...</div>
  17 + </div>
  18 +
  19 + <div ng-if="pagePropostas.error">
  20 + <div class="alert alert-danger" role="alert">
  21 + Erro ao carregar o conteúdo principal.
  22 + </div>
  23 + </div>
  24 + </div>
  25 + </div>
  26 + </div>
  27 + </section>
  28 +
  29 + <section class="section--header" ng-if="pagePropostas.proposals || pagePropostas.themes">
11 30 <div class="container">
12 31 <div class="row">
13 32 <div class="col-sm-12">
... ... @@ -16,7 +35,8 @@
16 35 </div>
17 36 </div>
18 37 </section>
19   - <section class="section--articles section-gray section-space-up" ng-if="pagePropostas.proposals">
  38 +
  39 + <section class="section--articles section-gray section-space-up" ng-if="pagePropostas.proposals || pagePropostas.themes">
20 40 <div class="container">
21 41 <div id="lista-de-propostas" class="row">
22 42 <div class="col-sm-4 col-md-3">
... ... @@ -52,7 +72,7 @@
52 72 </div>
53 73 </div>
54 74 <div class="col-sm-8 col-md-9">
55   - <div class="row hidden-xs">
  75 + <div class="row hidden-xs" ng-if="pagePropostas.proposals">
56 76 <div class="col-xs-12">
57 77 <div class="input-group input-group-lg input-group-search">
58 78 <label for="articleQueryFilter" class="control-label sr-only">Buscar propostas:</label>
... ... @@ -68,10 +88,11 @@
68 88 </div>
69 89 </div>
70 90 </div>
71   - <div class="row">
  91 +
  92 + <div class="row" ng-if="pagePropostas.proposals">
72 93 <div class="col-sm-12">
73 94 <header class="header">
74   - <h2>Total de Propostas as propostas: "<span>{{::pagePropostas.proposals.length}} propostas</span>"</h2>
  95 + <h2>Total de Propostas: "<b>{{pagePropostas.filtredProposals.length}} propostas</b>"</h2>
75 96 </header>
76 97 </div>
77 98 </div>
... ...
src/app/pages/propostas/propostas.scss 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +.page--propostas {
  2 + .proposal-box--middle {
  3 + background-color: #fff;
  4 + }
  5 +}
... ...
src/app/pages/propostas/ranking.html
... ... @@ -16,7 +16,7 @@
16 16 </div>
17 17 </div>
18 18 </section>
19   - <section class="section--articles section-gray section-space-up" ng-if="pageRanking.proposals">
  19 + <section class="section--articles section-gray section-space-up" ng-if="pagePropostas.proposals">
20 20 <div class="container">
21 21 <div id="lista-de-propostas" class="row">
22 22 <div class="col-sm-4 col-md-3">
... ... @@ -24,9 +24,9 @@
24 24 <div class="col-xs-12">
25 25 <div class="input-group input-group-lg input-group-search">
26 26 <label for="articleQueryFilter" class="control-label sr-only">Buscar propostas:</label>
27   - <input id="articleQueryFilter" type="search" class="form-control input-search" ng-model="pageRanking.query" placeholder="Buscar propostas" aria-label="Buscar propostas" >
  27 + <input id="articleQueryFilter" type="search" class="form-control input-search" ng-model="pagePropostas.query" placeholder="Buscar propostas" aria-label="Buscar propostas" >
28 28 <span class="input-group-btn">
29   - <button type="button" class="btn btn-default" ng-click="pageRanking.search()">
  29 + <button type="button" class="btn btn-default" ng-click="pagePropostas.search()">
30 30 <span class="icon-circle icon-small color-theme-common-bg">
31 31 <span class="glyphicon glyphicon-search"></span>
32 32 </span>
... ... @@ -37,15 +37,15 @@
37 37 <br/>
38 38 </div>
39 39 </div>
40   - <div ng-if="pageRanking.themes">
41   - <category-list categories="pageRanking.themes" selected-category="pageRanking.selectedTheme"></category-list>
  40 + <div ng-if="pagePropostas.themes">
  41 + <category-list categories="pagePropostas.themes" selected-category="pagePropostas.selectedTheme"></category-list>
42 42 </div>
43   - <div ng-if="!pageRanking.themes && pageRanking.loadingThemes">
  43 + <div ng-if="!pagePropostas.themes && pagePropostas.loadingThemes">
44 44 <div class="alert alert-info" role="alert">
45 45 Carregando temas.
46 46 </div>
47 47 </div>
48   - <div ng-if="!pageRanking.themes && pageRanking.themesError">
  48 + <div ng-if="!pagePropostas.themes && pagePropostas.themesError">
49 49 <div class="alert alert-danger" role="alert">
50 50 Não foi possível carregar a lista de temas neste momento.
51 51 </div>
... ... @@ -56,9 +56,9 @@
56 56 <div class="col-xs-12">
57 57 <div class="input-group input-group-lg input-group-search">
58 58 <label for="articleQueryFilter" class="control-label sr-only">Buscar propostas:</label>
59   - <input id="articleQueryFilter" type="search" class="form-control input-search" ng-model="pageRanking.query" placeholder="Buscar propostas" aria-label="Buscar propostas" >
  59 + <input id="articleQueryFilter" type="search" class="form-control input-search" ng-model="pagePropostas.query" placeholder="Buscar propostas" aria-label="Buscar propostas" >
60 60 <span class="input-group-btn">
61   - <button type="button" class="btn btn-default" ng-click="pageRanking.search()">
  61 + <button type="button" class="btn btn-default" ng-click="pagePropostas.search()">
62 62 <span class="icon-circle icon-small color-theme-common-bg">
63 63 <span class="glyphicon glyphicon-search"></span>
64 64 </span>
... ... @@ -71,21 +71,21 @@
71 71 <div class="row">
72 72 <div class="col-sm-12">
73 73 <header class="header">
74   - <h2>Total de Propostas as propostas: "<span>{{::pageRanking.proposals.length}} propostas</span>"</h2>
  74 + <h2>Total de Propostas: "<span>{{pagePropostas.filtredProposals.length}} propostas</span>"</h2>
75 75 </header>
76 76 </div>
77 77 </div>
78 78  
79 79 <div class="row">
80   - <div class="col-sm-12" ng-if="pageRanking.proposals">
81   - <proposal-list proposals="pageRanking.filtredProposals"></proposal-list>
  80 + <div class="col-sm-12" ng-if="pagePropostas.proposals">
  81 + <proposal-list proposals="pagePropostas.filtredProposals"></proposal-list>
82 82 </div>
83   - <div ng-if="!pageRanking.proposals && pageRanking.loadingProposals">
  83 + <div ng-if="!pagePropostas.proposals && pagePropostas.loadingProposals">
84 84 <div class="alert alert-info" role="alert">
85 85 Carregando propostas.
86 86 </div>
87 87 </div>
88   - <div ng-if="!pageRanking.proposals && pageRanking.proposalsError">
  88 + <div ng-if="!pagePropostas.proposals && pagePropostas.proposalsError">
89 89 <div class="alert alert-danger" role="alert">
90 90 Não foi possível carregar a lista de propostas neste momento.
91 91 </div>
... ...