Commit 40a0b4985dcd11c281c45a816eafbf8ed2bd244c
1 parent
ab4d4908
Exists in
master
and in
8 other branches
Rename from 'programaContent' to 'progama'
Showing
4 changed files
with
156 additions
and
157 deletions
Show diff stats
src/app/index.route.js
... | ... | @@ -99,8 +99,8 @@ |
99 | 99 | 'header': { templateUrl: 'app/pages/header/header.html' }, |
100 | 100 | 'main': { |
101 | 101 | templateUrl: 'app/pages/programas/programa.html', |
102 | - controller: 'ProgramaContentPageController', | |
103 | - controllerAs: 'pageProgramaContent' | |
102 | + controller: 'ProgramaPageController', | |
103 | + controllerAs: 'pagePrograma' | |
104 | 104 | }, |
105 | 105 | 'footer': { templateUrl: 'app/pages/footer/footer.html' } |
106 | 106 | } | ... | ... |
src/app/pages/programas/programa-content.controller.js
... | ... | @@ -1,135 +0,0 @@ |
1 | -(function() { | |
2 | - 'use strict'; | |
3 | - | |
4 | - angular | |
5 | - .module('dialoga') | |
6 | - .controller('ProgramaContentPageController', ProgramaContentPageController); | |
7 | - | |
8 | - /** @ngInject */ | |
9 | - function ProgramaContentPageController(DialogaService, PATH, $state, $location, $scope, $rootScope, $element, $timeout, $log) { | |
10 | - $log.debug('ProgramaContentPageController'); | |
11 | - | |
12 | - var vm = this; | |
13 | - | |
14 | - vm.DialogaService = DialogaService; | |
15 | - vm.PATH = PATH; | |
16 | - vm.$state = $state; | |
17 | - vm.$location = $location; | |
18 | - vm.$scope = $scope; | |
19 | - vm.$rootScope = $rootScope; | |
20 | - vm.$element = $element; | |
21 | - vm.$timeout = $timeout; | |
22 | - vm.$log = $log; | |
23 | - | |
24 | - vm.init(); | |
25 | - vm.loadData(); | |
26 | - vm.attachListeners(); | |
27 | - } | |
28 | - | |
29 | - ProgramaContentPageController.prototype.init = function() { | |
30 | - var vm = this; | |
31 | - | |
32 | - vm.article = null; | |
33 | - vm.category = null; | |
34 | - vm.search = vm.$location.search(); | |
35 | - | |
36 | - vm.error = false; | |
37 | - }; | |
38 | - | |
39 | - ProgramaContentPageController.prototype.loadData = function() { | |
40 | - var vm = this; | |
41 | - | |
42 | - vm.loading = true; | |
43 | - | |
44 | - // Get program by slug | |
45 | - var slug = vm.$state.params.slug; | |
46 | - | |
47 | - if(!slug){ | |
48 | - vm.$log.error('slug not defined.'); | |
49 | - vm.$log.info('Rollback to home page.'); | |
50 | - vm.$state.go('inicio', {}, {location: true}); | |
51 | - } | |
52 | - | |
53 | - vm.DialogaService.getProgramBySlug(slug, function(article) { | |
54 | - vm.article = article; | |
55 | - vm.category = vm.article.categories[0]; | |
56 | - | |
57 | - // update the breadcrumb | |
58 | - vm.$rootScope.contentTitle = vm.article.title; | |
59 | - | |
60 | - // set the banner image with full image path | |
61 | - if (!vm.banner) { | |
62 | - vm.banner = { | |
63 | - src: vm.PATH.image + vm.article.image.url, | |
64 | - alt: 'Imagem de destaque do conteúdo' | |
65 | - }; | |
66 | - } | |
67 | - | |
68 | - vm.DialogaService.getProposalsByTopicId(vm.article.id, {}, function(data){ | |
69 | - vm.proposals = data.articles; | |
70 | - vm.proposalsTopRated = vm.proposals.slice(0, 3); | |
71 | - }, function (error) { | |
72 | - vm.$log.error(error); | |
73 | - }); | |
74 | - | |
75 | - if(vm.search.proposal_id){ | |
76 | - var proposalUrlId = vm.search.proposal_id; | |
77 | - vm.DialogaService.getProposalById(proposalUrlId, { | |
78 | - 'limit': '1' | |
79 | - }, _handleSuccessGetProposal, _handleErrorGetProposal); | |
80 | - | |
81 | - }else{ | |
82 | - // get random proposal | |
83 | - vm.DialogaService.getProposalsByTopicId(vm.article.id, { | |
84 | - 'order': 'random()', | |
85 | - 'limit': '1' | |
86 | - }, _handleSuccessGetProposal, _handleErrorGetProposal); | |
87 | - } | |
88 | - | |
89 | - function _handleSuccessGetProposal(data){ | |
90 | - if(data && data.articles){ | |
91 | - vm.randomProposal = data.articles[0]; | |
92 | - } | |
93 | - | |
94 | - // scroll to focused proposal | |
95 | - if(vm.search.proposal_id){ | |
96 | - vm.$timeout(function(){ | |
97 | - var target = angular.element('.focused-proposal'); | |
98 | - angular.element('body').animate({scrollTop: target.offset().top}, 'fast'); | |
99 | - }, 300); | |
100 | - } | |
101 | - } | |
102 | - | |
103 | - function _handleErrorGetProposal(error){ | |
104 | - vm.$log.error(error); | |
105 | - } | |
106 | - | |
107 | - vm.loading = false; | |
108 | - }, function(error) { | |
109 | - vm.$log.error(error); | |
110 | - vm.error = error; | |
111 | - vm.loading = false; | |
112 | - | |
113 | - // vm.$log.info('Rollback to home page.'); | |
114 | - // vm.$state.go('inicio', {}, {location: true}); | |
115 | - }); | |
116 | - }; | |
117 | - | |
118 | - ProgramaContentPageController.prototype.attachListeners = function() { | |
119 | - var vm = this; | |
120 | - | |
121 | - vm.$scope.$on('proposal-carousel:toProposals', function() { | |
122 | - if(!vm._proposal_list){ | |
123 | - vm._proposal_list = vm.$element.find('.proposal-ranking-section'); | |
124 | - } | |
125 | - | |
126 | - vm._proposal_list.slideToggle(); | |
127 | - }); | |
128 | - }; | |
129 | - | |
130 | - ProgramaContentPageController.prototype.makeProposal = function() { | |
131 | - var vm = this; | |
132 | - | |
133 | - vm.$log.warn('Not implemented yet: "makeProposal"'); | |
134 | - }; | |
135 | -})(); |
... | ... | @@ -0,0 +1,135 @@ |
1 | +(function() { | |
2 | + 'use strict'; | |
3 | + | |
4 | + angular | |
5 | + .module('dialoga') | |
6 | + .controller('ProgramaPageController', ProgramaPageController); | |
7 | + | |
8 | + /** @ngInject */ | |
9 | + function ProgramaPageController(DialogaService, PATH, $state, $location, $scope, $rootScope, $element, $timeout, $log) { | |
10 | + $log.debug('ProgramaPageController'); | |
11 | + | |
12 | + var vm = this; | |
13 | + | |
14 | + vm.DialogaService = DialogaService; | |
15 | + vm.PATH = PATH; | |
16 | + vm.$state = $state; | |
17 | + vm.$location = $location; | |
18 | + vm.$scope = $scope; | |
19 | + vm.$rootScope = $rootScope; | |
20 | + vm.$element = $element; | |
21 | + vm.$timeout = $timeout; | |
22 | + vm.$log = $log; | |
23 | + | |
24 | + vm.init(); | |
25 | + vm.loadData(); | |
26 | + vm.attachListeners(); | |
27 | + } | |
28 | + | |
29 | + ProgramaPageController.prototype.init = function() { | |
30 | + var vm = this; | |
31 | + | |
32 | + vm.article = null; | |
33 | + vm.category = null; | |
34 | + vm.search = vm.$location.search(); | |
35 | + | |
36 | + vm.error = false; | |
37 | + }; | |
38 | + | |
39 | + ProgramaPageController.prototype.loadData = function() { | |
40 | + var vm = this; | |
41 | + | |
42 | + vm.loading = true; | |
43 | + | |
44 | + // Get program by slug | |
45 | + var slug = vm.$state.params.slug; | |
46 | + | |
47 | + if(!slug){ | |
48 | + vm.$log.error('slug not defined.'); | |
49 | + vm.$log.info('Rollback to home page.'); | |
50 | + vm.$state.go('inicio', {}, {location: true}); | |
51 | + } | |
52 | + | |
53 | + vm.DialogaService.getProgramBySlug(slug, function(article) { | |
54 | + vm.article = article; | |
55 | + vm.category = vm.article.categories[0]; | |
56 | + | |
57 | + // update the breadcrumb | |
58 | + vm.$rootScope.contentTitle = vm.article.title; | |
59 | + | |
60 | + // set the banner image with full image path | |
61 | + if (!vm.banner) { | |
62 | + vm.banner = { | |
63 | + src: vm.PATH.image + vm.article.image.url, | |
64 | + alt: 'Imagem de destaque do conteúdo' | |
65 | + }; | |
66 | + } | |
67 | + | |
68 | + vm.DialogaService.getProposalsByTopicId(vm.article.id, {}, function(data){ | |
69 | + vm.proposals = data.articles; | |
70 | + vm.proposalsTopRated = vm.proposals.slice(0, 3); | |
71 | + }, function (error) { | |
72 | + vm.$log.error(error); | |
73 | + }); | |
74 | + | |
75 | + if(vm.search.proposal_id){ | |
76 | + var proposalUrlId = vm.search.proposal_id; | |
77 | + vm.DialogaService.getProposalById(proposalUrlId, { | |
78 | + 'limit': '1' | |
79 | + }, _handleSuccessGetProposal, _handleErrorGetProposal); | |
80 | + | |
81 | + }else{ | |
82 | + // get random proposal | |
83 | + vm.DialogaService.getProposalsByTopicId(vm.article.id, { | |
84 | + 'order': 'random()', | |
85 | + 'limit': '1' | |
86 | + }, _handleSuccessGetProposal, _handleErrorGetProposal); | |
87 | + } | |
88 | + | |
89 | + function _handleSuccessGetProposal(data){ | |
90 | + if(data && data.articles){ | |
91 | + vm.randomProposal = data.articles[0]; | |
92 | + } | |
93 | + | |
94 | + // scroll to focused proposal | |
95 | + if(vm.search.proposal_id){ | |
96 | + vm.$timeout(function(){ | |
97 | + var target = angular.element('.focused-proposal'); | |
98 | + angular.element('body').animate({scrollTop: target.offset().top}, 'fast'); | |
99 | + }, 300); | |
100 | + } | |
101 | + } | |
102 | + | |
103 | + function _handleErrorGetProposal(error){ | |
104 | + vm.$log.error(error); | |
105 | + } | |
106 | + | |
107 | + vm.loading = false; | |
108 | + }, function(error) { | |
109 | + vm.$log.error(error); | |
110 | + vm.error = error; | |
111 | + vm.loading = false; | |
112 | + | |
113 | + // vm.$log.info('Rollback to home page.'); | |
114 | + // vm.$state.go('inicio', {}, {location: true}); | |
115 | + }); | |
116 | + }; | |
117 | + | |
118 | + ProgramaPageController.prototype.attachListeners = function() { | |
119 | + var vm = this; | |
120 | + | |
121 | + vm.$scope.$on('proposal-carousel:toProposals', function() { | |
122 | + if(!vm._proposal_list){ | |
123 | + vm._proposal_list = vm.$element.find('.proposal-ranking-section'); | |
124 | + } | |
125 | + | |
126 | + vm._proposal_list.slideToggle(); | |
127 | + }); | |
128 | + }; | |
129 | + | |
130 | + ProgramaPageController.prototype.makeProposal = function() { | |
131 | + var vm = this; | |
132 | + | |
133 | + vm.$log.warn('Not implemented yet: "makeProposal"'); | |
134 | + }; | |
135 | +})(); | ... | ... |
src/app/pages/programas/programa.html
... | ... | @@ -11,31 +11,30 @@ |
11 | 11 | <div class="container"> |
12 | 12 | <div class="row"> |
13 | 13 | <div class="col-sm-12"> |
14 | - <div ng-if="!pageProgramaContent.article && pageProgramaContent.loading" class="alert alert-info" role="alert">Carregando detalhes sobre o progama...</div> | |
15 | - <div ng-if="!pageProgramaContent.article && pageProgramaContent.error" class="alert alert-warning" role="alert">Erro ao carregar o programa.</div> | |
14 | + <div ng-if="!pagePrograma.article && pagePrograma.loading" class="alert alert-info" role="alert">Carregando detalhes sobre o progama...</div> | |
15 | + <div ng-if="!pagePrograma.article && pagePrograma.error" class="alert alert-warning" role="alert">Erro ao carregar o programa.</div> | |
16 | 16 | </div> |
17 | 17 | </div> |
18 | 18 | </div> |
19 | 19 | </section> |
20 | 20 | |
21 | - <div ng-if="pageProgramaContent.article.body" ng-class="pageProgramaContent.category.slug"> | |
21 | + <div ng-if="pagePrograma.article.body" ng-class="pagePrograma.category.slug"> | |
22 | 22 | <section> |
23 | 23 | <div class="container"> |
24 | 24 | <div class="row"> |
25 | 25 | <article class="program-preview"> |
26 | - | |
27 | 26 | <div class="col-md-12"> |
28 | - <h1 class="program-preview--title color-theme-fg">{{::pageProgramaContent.article.title}}</h1> | |
27 | + <h1 class="program-preview--title color-theme-fg">{{::pagePrograma.article.title}}</h1> | |
29 | 28 | </div> |
30 | 29 | <div class="col-md-8"> |
31 | 30 | <div class="program-preview--box contraste-box"> |
32 | - <div class="program-preview--banner" ng-style="{'background-image':'url( {{::pageProgramaContent.banner.src}} )'}"></div> | |
31 | + <div class="program-preview--banner" ng-style="{'background-image':'url( {{::pagePrograma.banner.src}} )'}"></div> | |
33 | 32 | <div class="program-preview--box--content-wrapper"> |
34 | - <div class="program-preview--icon icon-wrapper-rounded color-theme-bg" ng-class="pageProgramaContent.category.slug"> | |
35 | - <span class="icon" ng-class="'icon-tema-' + pageProgramaContent.category.slug"></span> | |
33 | + <div class="program-preview--icon icon-wrapper-rounded color-theme-bg" ng-class="pagePrograma.category.slug"> | |
34 | + <span class="icon" ng-class="'icon-tema-' + pagePrograma.category.slug"></span> | |
36 | 35 | </div> |
37 | 36 | <div class="program-preview--abstract color-theme-fg"> |
38 | - <h2>{{::stripHtml(pageProgramaContent.article.abstract)}}</h2> | |
37 | + <h2>{{::stripHtml(pagePrograma.article.abstract)}}</h2> | |
39 | 38 | </div> |
40 | 39 | <div class="program-preview--abstract-details"> |
41 | 40 | <p>Lorem ipsum dolor sit amet, ea veniam mucius ocurreret vix, ius ex nisl vidisse partiendo. Blandit nominavi cum ei, paulo quaestio his ei, eum minim salutandi in. Civibus albucius in quo, et eam posse facilisis. Debet suavitate sea ut, his ei feugiat fastidii eleifend. Quo ex quando maiestatis voluptatum, mel te perpetua maiestatis, sit ceteros legendos deserunt ea. Enim dolores moderatius eu pro, ad quo ignota aliquid meliore.</p> |
... | ... | @@ -48,7 +47,7 @@ |
48 | 47 | <div class="row"> |
49 | 48 | <div class="col-sm-6"> |
50 | 49 | <div class="button--themed"> |
51 | - <button type="button" class="btn btn-block" ng-click="pageProgramaContent.makeProposal()">Faça uma proposta</button> | |
50 | + <button type="button" class="btn btn-block" ng-click="pagePrograma.makeProposal()">Faça uma proposta</button> | |
52 | 51 | </div> |
53 | 52 | </div> |
54 | 53 | </div> |
... | ... | @@ -58,20 +57,20 @@ |
58 | 57 | </div> |
59 | 58 | <div class="col-md-4"> |
60 | 59 | <div class="row"> |
61 | - <div class="col-xs-12" ng-if="pageProgramaContent.proposalsTopRated && pageProgramaContent.proposalsTopRated.length > 0"> | |
60 | + <div class="col-xs-12" ng-if="pagePrograma.proposalsTopRated && pagePrograma.proposalsTopRated.length > 0"> | |
62 | 61 | <h3 class="color-theme-fg">Propostas mais votadas</h3> |
63 | - <proposal-carousel proposals="pageProgramaContent.proposalsTopRated" canVote="true"></proposal-carousel> | |
62 | + <proposal-carousel proposals="pagePrograma.proposalsTopRated" canVote="true"></proposal-carousel> | |
64 | 63 | </div> |
65 | - <div class="col-xs-12" ng-if="pageProgramaContent.randomProposal" ng-class="{'focused-proposal': !!pageProgramaContent.search.proposal_id}"> | |
64 | + <div class="col-xs-12" ng-if="pagePrograma.randomProposal" ng-class="{'focused-proposal': !!pagePrograma.search.proposal_id}"> | |
66 | 65 | <h3 class="color-theme-fg">Propostas nesse programa</h3> |
67 | - <proposal-box proposal="pageProgramaContent.randomProposal" topic="pageProgramaContent.article" category="pageProgramaContent.category" vote="true" focus="{{pageProgramaContent.search.proposal_id}}" ></proposal-box> | |
66 | + <proposal-box proposal="pagePrograma.randomProposal" topic="pagePrograma.article" category="pagePrograma.category" vote="true" focus="{{pagePrograma.search.proposal_id}}" ></proposal-box> | |
68 | 67 | </div> |
69 | - <div class="col-xs-12" ng-if="!pageProgramaContent.randomProposal && !(pageProgramaContent.proposalsTopRated && pageProgramaContent.proposalsTopRated.length > 0)"> | |
68 | + <div class="col-xs-12" ng-if="!pagePrograma.randomProposal && !(pagePrograma.proposalsTopRated && pagePrograma.proposalsTopRated.length > 0)"> | |
70 | 69 | <h3>Programas sem propostas</h3> |
71 | 70 | <p> |
72 | 71 | Este programa ainda não possui nenhuma proposta. |
73 | 72 | <div class="button--themed"> |
74 | - <button type="button" class="btn btn-block" ng-click="pageProgramaContent.makeProposal()">Faça uma proposta</button> | |
73 | + <button type="button" class="btn btn-block" ng-click="pagePrograma.makeProposal()">Faça uma proposta</button> | |
75 | 74 | </div> |
76 | 75 | </p> |
77 | 76 | </div> |
... | ... | @@ -82,20 +81,20 @@ |
82 | 81 | </div> |
83 | 82 | </section> |
84 | 83 | |
85 | - <section class="proposal-ranking-section" style="display:none;" ng-if="pageProgramaContent.proposals && pageProgramaContent.proposals.length > 0"> | |
84 | + <section class="proposal-ranking-section" style="display:none;" ng-if="pagePrograma.proposals && pagePrograma.proposals.length > 0"> | |
86 | 85 | <div class="container"> |
87 | 86 | <div class="proposal-ranking-section-header"> |
88 | 87 | <h3 class="color-theme-fg">Resultados de propostas mais votadas</h3> |
89 | 88 | </div> |
90 | 89 | <div class="proposal-ranking-section-table"> |
91 | - <proposal-list proposals="pageProgramaContent.proposals"></proposal-list> | |
90 | + <proposal-list proposals="pagePrograma.proposals"></proposal-list> | |
92 | 91 | </div> |
93 | 92 | </div> |
94 | 93 | </section> |
95 | 94 | |
96 | 95 | <section class="section-content"> |
97 | - <article class="program-content" ng-if="pageProgramaContent.article"> | |
98 | - <div ng-bind-html="pageProgramaContent.article.body"></div> | |
96 | + <article class="program-content" ng-if="pagePrograma.article"> | |
97 | + <div ng-bind-html="pagePrograma.article.body"></div> | |
99 | 98 | </article> |
100 | 99 | </section> |
101 | 100 | </div> | ... | ... |