Commit 16ed9593f881eab58ed92f531bc24710c3ae8560

Authored by Leonardo Merlin
1 parent 079255a3

Add proposals page

src/app/components/article-service/article.service.js
@@ -96,8 +96,8 @@ @@ -96,8 +96,8 @@
96 var url = service.apiArticles + API.articleId.home; 96 var url = service.apiArticles + API.articleId.home;
97 97
98 var paramsExtended = angular.extend({ 98 var paramsExtended = angular.extend({
99 - 'fields[]': ['id', 'title', 'slug', 'abstract', 'categories', 'setting', 'children_count', 'hits'],  
100 - 'content_type':'ProposalsDiscussionPlugin::Proposals' 99 + // 'fields[]': ['id', 'title', 'slug', 'abstract', 'categories', 'setting', 'children', 'children_count'],
  100 + 'content_type':'ProposalsDiscussionPlugin::Proposal'
101 }, params); 101 }, params);
102 102
103 UtilService.get(url, {params: paramsExtended}).then(function(data){ 103 UtilService.get(url, {params: paramsExtended}).then(function(data){
src/app/components/proposal-grid/proposal-grid.directive.js 0 → 100644
@@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
  1 +(function() {
  2 + 'use strict';
  3 +
  4 + angular
  5 + .module('dialoga')
  6 + .directive('proposalGrid', proposalGrid);
  7 +
  8 + /** @ngInject */
  9 + function proposalGrid() {
  10 +
  11 + /** @ngInject */
  12 + function ProposalGridController($scope, $rootScope, $element, $location, $filter, $log) {
  13 + $log.debug('ProposalGridController');
  14 +
  15 + // alias
  16 + var vm = this;
  17 +
  18 + // dependencies
  19 + vm.$scope = $scope;
  20 + vm.$rootScope = $rootScope;
  21 + vm.$element = $element;
  22 + vm.$location = $location;
  23 + vm.$filter = $filter;
  24 + vm.$log = $log;
  25 + vm.defaultLimit = 6;
  26 +
  27 + // initialization
  28 + vm.init();
  29 + vm.attachListeners();
  30 + }
  31 +
  32 + ProposalGridController.prototype.init = function() {
  33 + // var vm = this;
  34 + // vm.programs = null; // scope var
  35 + };
  36 +
  37 + ProposalGridController.prototype.attachListeners = function() {
  38 + // var vm = this;
  39 + };
  40 +
  41 + var directive = {
  42 + restrict: 'E',
  43 + templateUrl: 'app/components/proposal-grid/proposal-grid.html',
  44 + scope: {
  45 + proposals: '='
  46 + },
  47 + controller: ProposalGridController,
  48 + controllerAs: 'vm',
  49 + bindToController: true
  50 + };
  51 +
  52 + return directive;
  53 + }
  54 +})();
src/app/components/proposal-grid/proposal-grid.html 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +<div class="proposal-grid row">
  2 + <div ng-repeat="proposal in vm.proposals as results">
  3 + <proposal-box proposal="proposal" category="proposal.categories[0]" class="col-xs-12 col-sm-6"></proposal-box>
  4 + <div ng-if="$odd" class="clearfix"></div>
  5 + </div>
  6 + <div class="animate-repeat" ng-if="results.length == 0">
  7 + Nenhum programa encontrado.
  8 + </div>
  9 +</div>
src/app/pages/programas/programas.controller.js
@@ -9,7 +9,6 @@ @@ -9,7 +9,6 @@
9 function ProgramasPageController(DialogaService, $log) { 9 function ProgramasPageController(DialogaService, $log) {
10 var vm = this; 10 var vm = this;
11 11
12 - // alias  
13 vm.DialogaService = DialogaService; 12 vm.DialogaService = DialogaService;
14 vm.$log = $log; 13 vm.$log = $log;
15 14
@@ -44,18 +43,22 @@ @@ -44,18 +43,22 @@
44 vm.DialogaService.getPrograms(function(programs){ 43 vm.DialogaService.getPrograms(function(programs){
45 vm.programs = programs; 44 vm.programs = programs;
46 vm.filtredPrograms = vm.programs; 45 vm.filtredPrograms = vm.programs;
  46 + vm.loadingPrograms = false;
47 }, function (error) { 47 }, function (error) {
48 vm.error = error; 48 vm.error = error;
49 vm.$log.error(error); 49 vm.$log.error(error);
  50 + vm.loadingPrograms = false;
50 }); 51 });
51 52
52 // load themes 53 // load themes
53 vm.loadingThemes = true; 54 vm.loadingThemes = true;
54 vm.DialogaService.getThemes(function(themes){ 55 vm.DialogaService.getThemes(function(themes){
55 vm.themes = themes; 56 vm.themes = themes;
  57 + vm.loadingThemes = false;
56 }, function (error) { 58 }, function (error) {
57 vm.error = error; 59 vm.error = error;
58 vm.$log.error(error); 60 vm.$log.error(error);
  61 + vm.loadingThemes = false;
59 }); 62 });
60 }; 63 };
61 })(); 64 })();
src/app/pages/programas/programas.html
@@ -10,7 +10,9 @@ @@ -10,7 +10,9 @@
10 <section class="section--info"> 10 <section class="section--info">
11 <div class="container"> 11 <div class="container">
12 <div class="row"> 12 <div class="row">
13 - <h1>Programas de governo</h1> 13 + <div class="col-sm-12">
  14 + <h1>Programas de governo</h1>
  15 + </div>
14 </div> 16 </div>
15 </div> 17 </div>
16 </section> 18 </section>
src/app/pages/propostas/proposta.html
@@ -1,11 +0,0 @@ @@ -1,11 +0,0 @@
1 -<div class="container">  
2 - <div class="row">  
3 - <div class="col-sm-12">  
4 - <div ncy-breadcrumb></div>  
5 - </div>  
6 - </div>  
7 -</div>  
8 -  
9 -<div class="container page--propostas">  
10 - <h1>TODO: Home > Proposta</h1>  
11 -</div>  
src/app/pages/propostas/propostas.controller.js
@@ -7,38 +7,58 @@ @@ -7,38 +7,58 @@
7 7
8 /** @ngInject */ 8 /** @ngInject */
9 function PropostasPageController(DialogaService, $log) { 9 function PropostasPageController(DialogaService, $log) {
10 - $log.debug('PropostasPageController');  
11 -  
12 var vm = this; 10 var vm = this;
13 11
14 vm.DialogaService = DialogaService; 12 vm.DialogaService = DialogaService;
15 vm.$log = $log; 13 vm.$log = $log;
16 14
17 vm.init(); 15 vm.init();
  16 + $log.debug('PropostasPageController');
18 } 17 }
19 18
20 PropostasPageController.prototype.init = function () { 19 PropostasPageController.prototype.init = function () {
21 var vm = this; 20 var vm = this;
22 21
23 vm.article = null; 22 vm.article = null;
24 - vm.categories = null;  
25 - vm.currentCategory = null;  
26 - vm.loading = true;  
27 - vm.error = false; 23 + vm.themes = null;
  24 + vm.selectedTheme = null;
  25 + vm.proposals = null;
  26 + vm.filtredProposals = null;
  27 + vm.query = null;
  28 +
  29 + vm.loading = null;
  30 + vm.error = null;
28 31
29 - // vm.loadData(); 32 + vm.loadData();
30 }; 33 };
31 34
32 35
33 PropostasPageController.prototype.loadData = function () { 36 PropostasPageController.prototype.loadData = function () {
34 var vm = this; 37 var vm = this;
35 38
36 - vm.DialogaService.getCategories(function(categories){  
37 - vm.categories = categories; 39 + vm.loading = true;
  40 +
  41 + // load Proposals
  42 + vm.loadingProposals = true;
  43 + vm.DialogaService.getProposalsByTopicId(103644, {}, function(data){
  44 + vm.proposals = data.articles;
  45 + vm.filtredProposals = vm.proposals;
  46 + vm.loadingProposals = false;
38 }, function (error) { 47 }, function (error) {
39 vm.error = error; 48 vm.error = error;
40 vm.$log.error(error); 49 vm.$log.error(error);
  50 + vm.loadingProposals = false;
41 }); 51 });
42 52
  53 + // load themes
  54 + vm.loadingThemes = true;
  55 + vm.DialogaService.getThemes(function(themes){
  56 + vm.themes = themes;
  57 + vm.loadingThemes = false;
  58 + }, function (error) {
  59 + vm.error = error;
  60 + vm.$log.error(error);
  61 + vm.loadingThemes = false;
  62 + });
43 }; 63 };
44 })(); 64 })();
src/app/pages/propostas/propostas.html
@@ -6,6 +6,93 @@ @@ -6,6 +6,93 @@
6 </div> 6 </div>
7 </div> 7 </div>
8 8
9 -<div class="container page--propostas">  
10 - <h1>TODO: Home > Propostas</h1> 9 +<div class="page--propostas">
  10 + <section class="section--info">
  11 + <div class="container">
  12 + <div class="row">
  13 + <div class="col-sm-12">
  14 + <h1>Propostas</h1>
  15 + </div>
  16 + </div>
  17 + </div>
  18 + </section>
  19 + <section class="section--articles section-gray section-space-up" ng-if="pagePropostas.proposals">
  20 + <div class="container">
  21 + <div id="lista-de-propostas" class="row">
  22 + <div class="col-sm-4 col-md-3">
  23 + <div class="row visible-xs">
  24 + <div class="col-xs-12">
  25 + <div class="input-group input-group-lg input-group-search">
  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="pagePropostas.query" placeholder="Buscar propostas" aria-label="Buscar propostas" >
  28 + <span class="input-group-btn">
  29 + <button type="button" class="btn btn-default" ng-click="pagePropostas.search()">
  30 + <span class="icon-circle icon-small color-theme-common-bg">
  31 + <span class="glyphicon glyphicon-search"></span>
  32 + </span>
  33 + <span class="sr-only">Buscar</span>
  34 + </button>
  35 + </span>
  36 + </div>
  37 + <br/>
  38 + </div>
  39 + </div>
  40 + <div ng-if="pagePropostas.themes">
  41 + <category-list categories="pagePropostas.themes" selected-category="pagePropostas.selectedTheme"></category-list>
  42 + </div>
  43 + <div ng-if="!pagePropostas.themes && pagePropostas.loadingThemes">
  44 + <div class="alert alert-info" role="alert">
  45 + Carregando temas.
  46 + </div>
  47 + </div>
  48 + <div ng-if="!pagePropostas.themes && pagePropostas.themesError">
  49 + <div class="alert alert-danger" role="alert">
  50 + Não foi possível carregar a lista de temas neste momento.
  51 + </div>
  52 + </div>
  53 + </div>
  54 + <div class="col-sm-8 col-md-9">
  55 + <div class="row hidden-xs">
  56 + <div class="col-xs-12">
  57 + <div class="input-group input-group-lg input-group-search">
  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="pagePropostas.query" placeholder="Buscar propostas" aria-label="Buscar propostas" >
  60 + <span class="input-group-btn">
  61 + <button type="button" class="btn btn-default" ng-click="pagePropostas.search()">
  62 + <span class="icon-circle icon-small color-theme-common-bg">
  63 + <span class="glyphicon glyphicon-search"></span>
  64 + </span>
  65 + <span class="sr-only">Buscar</span>
  66 + </button>
  67 + </span>
  68 + </div>
  69 + </div>
  70 + </div>
  71 + <div class="row">
  72 + <div class="col-sm-12">
  73 + <header class="header">
  74 + <h2>Total de Propostas as propostas: "<span>{{::pagePropostas.proposals.length}} propostas</span>"</h2>
  75 + </header>
  76 + </div>
  77 + </div>
  78 +
  79 + <div class="row">
  80 + <div class="col-sm-12" ng-if="pagePropostas.proposals">
  81 + <proposal-grid proposals="pagePropostas.filtredProposals"></proposal-grid>
  82 + </div>
  83 + <div ng-if="!pagePropostas.proposals && pagePropostas.loadingProposals">
  84 + <div class="alert alert-info" role="alert">
  85 + Carregando propostas.
  86 + </div>
  87 + </div>
  88 + <div ng-if="!pagePropostas.proposals && pagePropostas.proposalsError">
  89 + <div class="alert alert-danger" role="alert">
  90 + Não foi possível carregar a lista de propostas neste momento.
  91 + </div>
  92 + </div>
  93 + </div>
  94 + </div>
  95 + </div>
  96 + </div>
  97 + </section>
11 </div> 98 </div>