Commit 5d0de01968043c0630c3a1567827dfaa9e7a5a47
1 parent
1ea912ba
Exists in
master
and in
8 other branches
Fix 'participe' at proposal-box
Showing
12 changed files
with
165 additions
and
47 deletions
Show diff stats
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) { |
... | ... | @@ -205,11 +213,12 @@ |
205 | 213 | // Ex.: /api/v1/search/article?type=ProposalsDiscussionPlugin::Proposal&query=cisternas |
206 | 214 | var url = '/api/v1/search/article'; |
207 | 215 | var paramsExtended = angular.extend({ |
208 | - 'fields[]': ['id', 'title', 'slug', 'abstract', 'categories', 'setting', 'children_count', 'hits'], | |
216 | + // 'fields[]': ['id', 'title', 'slug', 'abstract', 'categories', 'setting', 'children_count', 'hits'], | |
209 | 217 | 'type': 'ProposalsDiscussionPlugin::Proposal' |
210 | 218 | }, params); |
211 | 219 | |
212 | 220 | UtilService.get(url, {params: paramsExtended}).then(function(data){ |
221 | + _pipeInjectSlugIntoParentProgram(data); | |
213 | 222 | cbSuccess(data); |
214 | 223 | }).catch(function(error){ |
215 | 224 | cbError(error); |
... | ... | @@ -217,6 +226,9 @@ |
217 | 226 | } |
218 | 227 | |
219 | 228 | function _pipeInjectSlugIntoParentProgram(data){ |
229 | + if(!data.articles && data.article){ | |
230 | + data.articles = [data.article]; | |
231 | + } | |
220 | 232 | var proposals = data.articles; |
221 | 233 | for (var i = proposals.length - 1; i >= 0; i--) { |
222 | 234 | var proposal = proposals[i]; | ... | ... |
src/app/components/proposal-box/proposal-box.directive.js
... | ... | @@ -27,11 +27,12 @@ |
27 | 27 | |
28 | 28 | }; |
29 | 29 | |
30 | - ProposalBoxController.prototype.showContent2 = function (topic) { | |
30 | + ProposalBoxController.prototype.showContent = function (slug) { | |
31 | 31 | var vm = this; |
32 | 32 | |
33 | 33 | vm.$state.go('programa-conteudo', { |
34 | - slug: topic.slug | |
34 | + slug: slug, | |
35 | + proposal_id: vm.proposal.id | |
35 | 36 | }, { |
36 | 37 | location: true |
37 | 38 | }); | ... | ... |
src/app/components/proposal-box/proposal-box.html
... | ... | @@ -5,10 +5,13 @@ |
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"> | ... | ... |
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/index.route.js
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" ></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
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,40 @@ |
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; | |
67 | 74 | }); |
68 | 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 | + vm.$log.debug('vm.selectedTheme', vm.selectedTheme); | |
83 | + }); | |
84 | + | |
85 | + vm.$scope.$watch('pagePropostas.selectedTheme', function(newValue/*, oldValue*/) { | |
86 | + vm.search.tema = newValue ? newValue.slug : null; | |
87 | + vm.$location.search('tema', vm.search.tema); | |
88 | + vm.filtredProposals = vm.getFiltredProposals(); | |
89 | + }); | |
90 | + | |
91 | + vm.$scope.$watch('pagePropostas.query', function(newValue/*, oldValue*/) { | |
92 | + vm.search.filtro = newValue ? newValue : null; | |
93 | + vm.$location.search('filtro', vm.search.filtro); | |
94 | + vm.filtredProposals = vm.getFiltredProposals(); | |
95 | + }); | |
96 | + }; | |
97 | + | |
98 | + PropostasPageController.prototype.getFiltredProposals = function() { | |
99 | + var vm = this; | |
100 | + | |
101 | + return vm.proposals; | |
102 | + }; | |
103 | + | |
69 | 104 | })(); | ... | ... |
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.proposals.length}} propostas</b>"</h2> | |
75 | 96 | </header> |
76 | 97 | </div> |
77 | 98 | </div> | ... | ... |