diff --git a/src/app/index.route.js b/src/app/index.route.js index 968a8b1..73756e3 100644 --- a/src/app/index.route.js +++ b/src/app/index.route.js @@ -99,8 +99,8 @@ 'header': { templateUrl: 'app/pages/header/header.html' }, 'main': { templateUrl: 'app/pages/programas/programa.html', - controller: 'ProgramaContentPageController', - controllerAs: 'pageProgramaContent' + controller: 'ProgramaPageController', + controllerAs: 'pagePrograma' }, 'footer': { templateUrl: 'app/pages/footer/footer.html' } } diff --git a/src/app/pages/programas/programa-content.controller.js b/src/app/pages/programas/programa-content.controller.js deleted file mode 100644 index abfa2b3..0000000 --- a/src/app/pages/programas/programa-content.controller.js +++ /dev/null @@ -1,135 +0,0 @@ -(function() { - 'use strict'; - - angular - .module('dialoga') - .controller('ProgramaContentPageController', ProgramaContentPageController); - - /** @ngInject */ - function ProgramaContentPageController(DialogaService, PATH, $state, $location, $scope, $rootScope, $element, $timeout, $log) { - $log.debug('ProgramaContentPageController'); - - var vm = this; - - vm.DialogaService = DialogaService; - vm.PATH = PATH; - vm.$state = $state; - vm.$location = $location; - vm.$scope = $scope; - vm.$rootScope = $rootScope; - vm.$element = $element; - vm.$timeout = $timeout; - vm.$log = $log; - - vm.init(); - vm.loadData(); - vm.attachListeners(); - } - - ProgramaContentPageController.prototype.init = function() { - var vm = this; - - vm.article = null; - vm.category = null; - vm.search = vm.$location.search(); - - vm.error = false; - }; - - ProgramaContentPageController.prototype.loadData = function() { - var vm = this; - - vm.loading = true; - - // Get program by slug - var slug = vm.$state.params.slug; - - if(!slug){ - vm.$log.error('slug not defined.'); - vm.$log.info('Rollback to home page.'); - vm.$state.go('inicio', {}, {location: true}); - } - - vm.DialogaService.getProgramBySlug(slug, function(article) { - vm.article = article; - vm.category = vm.article.categories[0]; - - // update the breadcrumb - vm.$rootScope.contentTitle = vm.article.title; - - // set the banner image with full image path - if (!vm.banner) { - vm.banner = { - src: vm.PATH.image + vm.article.image.url, - alt: 'Imagem de destaque do conteúdo' - }; - } - - vm.DialogaService.getProposalsByTopicId(vm.article.id, {}, function(data){ - vm.proposals = data.articles; - vm.proposalsTopRated = vm.proposals.slice(0, 3); - }, function (error) { - vm.$log.error(error); - }); - - if(vm.search.proposal_id){ - var proposalUrlId = vm.search.proposal_id; - vm.DialogaService.getProposalById(proposalUrlId, { - 'limit': '1' - }, _handleSuccessGetProposal, _handleErrorGetProposal); - - }else{ - // get random proposal - vm.DialogaService.getProposalsByTopicId(vm.article.id, { - 'order': 'random()', - 'limit': '1' - }, _handleSuccessGetProposal, _handleErrorGetProposal); - } - - function _handleSuccessGetProposal(data){ - if(data && data.articles){ - vm.randomProposal = data.articles[0]; - } - - // scroll to focused proposal - if(vm.search.proposal_id){ - vm.$timeout(function(){ - var target = angular.element('.focused-proposal'); - angular.element('body').animate({scrollTop: target.offset().top}, 'fast'); - }, 300); - } - } - - function _handleErrorGetProposal(error){ - vm.$log.error(error); - } - - vm.loading = false; - }, function(error) { - vm.$log.error(error); - vm.error = error; - vm.loading = false; - - // vm.$log.info('Rollback to home page.'); - // vm.$state.go('inicio', {}, {location: true}); - }); - }; - - ProgramaContentPageController.prototype.attachListeners = function() { - var vm = this; - - vm.$scope.$on('proposal-carousel:toProposals', function() { - if(!vm._proposal_list){ - vm._proposal_list = vm.$element.find('.proposal-ranking-section'); - } - - vm._proposal_list.slideToggle(); - }); - }; - - ProgramaContentPageController.prototype.makeProposal = function() { - var vm = this; - - vm.$log.warn('Not implemented yet: "makeProposal"'); - }; -})(); diff --git a/src/app/pages/programas/programa.controller.js b/src/app/pages/programas/programa.controller.js new file mode 100644 index 0000000..3d84cfc --- /dev/null +++ b/src/app/pages/programas/programa.controller.js @@ -0,0 +1,135 @@ +(function() { + 'use strict'; + + angular + .module('dialoga') + .controller('ProgramaPageController', ProgramaPageController); + + /** @ngInject */ + function ProgramaPageController(DialogaService, PATH, $state, $location, $scope, $rootScope, $element, $timeout, $log) { + $log.debug('ProgramaPageController'); + + var vm = this; + + vm.DialogaService = DialogaService; + vm.PATH = PATH; + vm.$state = $state; + vm.$location = $location; + vm.$scope = $scope; + vm.$rootScope = $rootScope; + vm.$element = $element; + vm.$timeout = $timeout; + vm.$log = $log; + + vm.init(); + vm.loadData(); + vm.attachListeners(); + } + + ProgramaPageController.prototype.init = function() { + var vm = this; + + vm.article = null; + vm.category = null; + vm.search = vm.$location.search(); + + vm.error = false; + }; + + ProgramaPageController.prototype.loadData = function() { + var vm = this; + + vm.loading = true; + + // Get program by slug + var slug = vm.$state.params.slug; + + if(!slug){ + vm.$log.error('slug not defined.'); + vm.$log.info('Rollback to home page.'); + vm.$state.go('inicio', {}, {location: true}); + } + + vm.DialogaService.getProgramBySlug(slug, function(article) { + vm.article = article; + vm.category = vm.article.categories[0]; + + // update the breadcrumb + vm.$rootScope.contentTitle = vm.article.title; + + // set the banner image with full image path + if (!vm.banner) { + vm.banner = { + src: vm.PATH.image + vm.article.image.url, + alt: 'Imagem de destaque do conteúdo' + }; + } + + vm.DialogaService.getProposalsByTopicId(vm.article.id, {}, function(data){ + vm.proposals = data.articles; + vm.proposalsTopRated = vm.proposals.slice(0, 3); + }, function (error) { + vm.$log.error(error); + }); + + if(vm.search.proposal_id){ + var proposalUrlId = vm.search.proposal_id; + vm.DialogaService.getProposalById(proposalUrlId, { + 'limit': '1' + }, _handleSuccessGetProposal, _handleErrorGetProposal); + + }else{ + // get random proposal + vm.DialogaService.getProposalsByTopicId(vm.article.id, { + 'order': 'random()', + 'limit': '1' + }, _handleSuccessGetProposal, _handleErrorGetProposal); + } + + function _handleSuccessGetProposal(data){ + if(data && data.articles){ + vm.randomProposal = data.articles[0]; + } + + // scroll to focused proposal + if(vm.search.proposal_id){ + vm.$timeout(function(){ + var target = angular.element('.focused-proposal'); + angular.element('body').animate({scrollTop: target.offset().top}, 'fast'); + }, 300); + } + } + + function _handleErrorGetProposal(error){ + vm.$log.error(error); + } + + vm.loading = false; + }, function(error) { + vm.$log.error(error); + vm.error = error; + vm.loading = false; + + // vm.$log.info('Rollback to home page.'); + // vm.$state.go('inicio', {}, {location: true}); + }); + }; + + ProgramaPageController.prototype.attachListeners = function() { + var vm = this; + + vm.$scope.$on('proposal-carousel:toProposals', function() { + if(!vm._proposal_list){ + vm._proposal_list = vm.$element.find('.proposal-ranking-section'); + } + + vm._proposal_list.slideToggle(); + }); + }; + + ProgramaPageController.prototype.makeProposal = function() { + var vm = this; + + vm.$log.warn('Not implemented yet: "makeProposal"'); + }; +})(); diff --git a/src/app/pages/programas/programa.html b/src/app/pages/programas/programa.html index a0b9117..9276e0a 100644 --- a/src/app/pages/programas/programa.html +++ b/src/app/pages/programas/programa.html @@ -11,31 +11,30 @@
- - + +
-
+
-
-

{{::pageProgramaContent.article.title}}

+

{{::pagePrograma.article.title}}

-
+
-
- +
+
-

{{::stripHtml(pageProgramaContent.article.abstract)}}

+

{{::stripHtml(pagePrograma.article.abstract)}}

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.

@@ -48,7 +47,7 @@
- +
@@ -58,20 +57,20 @@
-
+

Propostas mais votadas

- +
-
+

Propostas nesse programa

- +
-
+

Programas sem propostas

Este programa ainda não possui nenhuma proposta.

- +

@@ -82,20 +81,20 @@
-
-- libgit2 0.21.2