Commit e2cf91e3980972a6a933737e65de9432f74b3ec5

Authored by Leonardo Merlin
2 parents e46b4a32 511ec322

Merge branch 'merlin' into staging

gulp/images.js
... ... @@ -18,7 +18,8 @@ gulp.task('sprites', function () {
18 18 return sprity.src({
19 19 src: src,
20 20 style: 'sprite.css',
21   - cssPath: '../assets/images/icons/'
  21 + cssPath: '../assets/images/icons/',
  22 + cachebuster: true
22 23 })
23 24 .pipe(gulpif('*.png', gulp.dest(destImg), gulp.dest(destCss)));
24 25 });
... ...
src/app/components/dialoga-service/dialoga.service.js
... ... @@ -25,6 +25,8 @@
25 25 extendedService.getQuestions = getQuestions;
26 26 extendedService.searchPrograms = searchPrograms;
27 27 extendedService.searchProposals = searchProposals;
  28 + extendedService.filterProposalsByCategorySlug = filterProposalsByCategorySlug;
  29 + extendedService.filterProposalsByProgramId = filterProposalsByProgramId;
28 30  
29 31 var CACHE = {};
30 32  
... ... @@ -230,6 +232,52 @@
230 232 ArticleService.searchProposals(params, cbSuccess, cbError);
231 233 }
232 234  
  235 + function filterProposalsByCategorySlug (input, categorySlug) {
  236 +
  237 + if(!angular.isArray(input)){
  238 + $log.error('Input is not a Array.');
  239 + return [];
  240 + }
  241 +
  242 + // Use native array filter
  243 + return input.filter(function(value/*, index, arr*/) {
  244 +
  245 + if (!value.parent) {
  246 + $log.warn('Proposal without a parent.');
  247 + return false;
  248 + }
  249 +
  250 + if (!value.parent.categories || value.parent.categories.length === 0) {
  251 + $log.warn('Proposal parent has no categories.');
  252 + return false;
  253 + }
  254 +
  255 + // match?!
  256 + return value.parent.categories[0].slug === categorySlug;
  257 + });
  258 + }
  259 +
  260 + function filterProposalsByProgramId (input, program_id) {
  261 + var vm = this;
  262 +
  263 + if(!angular.isArray(input)){
  264 + $log.error('Input is not a Array.');
  265 + return [];
  266 + }
  267 +
  268 + // Use native array filter
  269 + return input.filter(function(value) {
  270 + if (!value.parent || !value.parent.id) {
  271 + $log.warn('Proposal has no parent.');
  272 +
  273 + return false;
  274 + }
  275 +
  276 + // match?!
  277 + return value.parent.id === program_id;
  278 + });
  279 + }
  280 +
233 281 function _pipeHandleYoutube (data) {
234 282 var abstract = data.article.abstract;
235 283  
... ...
src/app/layout.scss
... ... @@ -283,67 +283,44 @@ a.link-black {
283 283 color: black;
284 284 }
285 285  
286   -article.program-content {
287   - margin-top: 40px;
288   -}
289   -
290   -article.program-content div.ng-binding div.container div.row {
291   - margin-bottom: 40px;
292   -}
293   -
294   -article.program-content h3 {
295   - margin-bottom: 15px;
296   -}
297   -
298 286 .inline-block {
299 287 display: inline-block;
300 288 }
301 289  
  290 +// Sobreescreve a classe do bootstrap
  291 +.close {
  292 + color: white;
  293 + opacity: 1;
  294 + font-weight: normal;
  295 +}
  296 +
302 297 blockquote {
303   - border-left: medium none;
304   - font-size: 140%;
  298 + border-left: none;
  299 + font-size: 24px;
  300 + line-height: 28px;
305 301 padding: 50px 0 0 50px;
306 302 position: relative;
307 303  
  304 + @each $category, $color in $categories {
  305 + .#{$category} & {
  306 + color: $color;
  307 + }
  308 + }
  309 +
308 310 &:before {
309 311 content: "⌜";
310 312 font-size: 200px;
311   - left: -2px;
  313 + line-height: 200px;
312 314 position: absolute;
313   - top: -50px;
  315 + top: -10px;
  316 + left: -10px;
314 317 font-weight: bolder;
315   - left: -17px;
316   - top: -68px;
317 318 @each $category, $color in $categories {
318 319 .#{$category} & {
319 320 color: $color;
320 321 }
321 322 }
322 323 }
323   -
324   -}
325   -
326   -// .cultura blockquote::before {
327   -// color: #cd999b;
328   -// }
329   -
330   -// Sobreescreve a classe do bootstrap
331   -.close {
332   - color: white;
333   - opacity: 1;
334   - font-weight: normal;
335   -}
336   -
337   -// .img-responsive {
338   -// width: 100%;
339   -// }
340   -
341   -strong {
342   - @each $category, $color in $categories {
343   - .#{$category} & {
344   - color: $color;
345   - }
346   - }
347 324 }
348 325  
349 326 .top-border-theme {
... ...
src/app/pages/auth/signin.html
... ... @@ -21,14 +21,14 @@
21 21 <div class="row">
22 22 <div class="col-sm-4"></div>
23 23 <div class="col-sm-8 text-center-sm">
24   - <!-- <div ng-if="pageSignin.redirect > 0">
25   - </div> -->
26 24 <div ng-if="pageSignin.countdown > 0">
27 25 <p>
28 26 Você será redirecionado em menos de <b>{{pageSignin.countdown}} segundos</b>...
29 27 </p>
30 28 </div>
31   - <button type="button" ng-click="pageSignin.onClickLogout()" class="btn btn-primary">Sair</button>
  29 + <div ng-if="!pageSignin.hasRedirect">
  30 + <a ui-sref="inicio" class="btn btn-primary">Ir para a Página Inicial</a>
  31 + </div>
32 32 </div>
33 33 </div>
34 34 </div>
... ...
src/app/pages/inicio/inicio.controller.js
... ... @@ -161,7 +161,18 @@
161 161 };
162 162  
163 163 InicioPageController.prototype.submitSearch = function() {
164   - vm.$log.warn('No implemented yet.');
  164 + var vm = this;
  165 +
  166 + vm.loadingFilter = true;
  167 +
  168 + // scroll to result grid
  169 + var $searchResult = angular.element('#search-result');
  170 + if($searchResult && $searchResult.length > 0){
  171 + angular.element('body').animate({scrollTop: $searchResult.offset().top}, 'fast');
  172 + vm.filtredPrograms = vm.getFiltredPrograms();
  173 + }else{
  174 + vm.$log.warn('#search-result element not found.');
  175 + }
165 176 };
166 177  
167 178 InicioPageController.prototype.filter = function() {
... ... @@ -222,6 +233,7 @@
222 233 var selectedTheme = vm.selectedTheme;
223 234  
224 235 var filter = vm.$filter('filter');
  236 + vm.loadingFilter = true;
225 237  
226 238 if (selectedTheme) {
227 239 output = vm._filterByCategory(output, selectedTheme);
... ... @@ -235,6 +247,7 @@
235 247 output = _balanceByCategory(output);
236 248 }
237 249  
  250 + vm.loadingFilter = false;
238 251 return output;
239 252 };
240 253  
... ... @@ -263,7 +276,7 @@
263 276 }
264 277  
265 278 return out;
266   - }
  279 + };
267 280  
268 281 function _balanceByCategory (input) {
269 282 var result = [];
... ...
src/app/pages/inicio/inicio.html
... ... @@ -130,12 +130,12 @@
130 130 </div>
131 131 </div>
132 132 </div>
133   - <div class="row">
  133 + <div id="search-result" class="row">
134 134 <div class="col-sm-12">
135 135 <header class="header">
136 136 <h2>Programas</h2>
137 137 <button type="button" class="btn btn-link" ng-click="pageInicio.showAllPrograms($event)">
138   - <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> Ver todos os programas
  138 + <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> Ver todos os {{::pageInicio.programs.length}} programas
139 139 </button>
140 140 </header>
141 141 </div>
... ...
src/app/pages/programas/programa.html
... ... @@ -18,8 +18,8 @@
18 18 </div>
19 19 </section>
20 20  
21   - <div role="main">
22   - <section ng-if="pagePrograma.article.body" ng-class="pagePrograma.category.slug">
  21 + <div role="main" ng-class="pagePrograma.category.slug">
  22 + <section ng-if="pagePrograma.article.body">
23 23 <div class="container">
24 24 <div class="row">
25 25 <article class="program-preview">
... ...
src/app/pages/programas/programas.controller.js
... ... @@ -212,7 +212,7 @@
212 212 }
213 213  
214 214 return out;
215   - }
  215 + };
216 216  
217 217 ProgramasPageController.prototype._balanceByCategory = function (input) {
218 218 var vm = this;
... ... @@ -276,5 +276,5 @@
276 276 }
277 277  
278 278 return result;
279   - }
  279 + };
280 280 })();
... ...
src/app/pages/programas/programas.scss
... ... @@ -117,9 +117,39 @@
117 117 line-height: 36px;
118 118 font-weight: bold;
119 119 }
  120 + }
  121 +
  122 + .program-content {
  123 +
  124 + margin-top: 40px;
120 125  
121 126 h3 {
  127 + font-size: 22px;
  128 + line-height: 26px;
  129 + font-weight: bold;
  130 +
122 131 margin-top: 0;
  132 + margin-bottom: 15px;
  133 + }
  134 +
  135 + h4 {
  136 + font-size: 18px;
  137 + line-height: 24px;
  138 + font-weight: bold;
  139 + }
  140 +
  141 + h5 {
  142 + font-size: 16px;
  143 + line-height: 22px;
  144 + }
  145 +
  146 + p {
  147 + font-size: 14px;
  148 + line-height: 18px;
  149 + }
  150 +
  151 + .container > .row {
  152 + margin-bottom: 40px;
123 153 }
124 154 }
125 155  
... ...
src/app/pages/propostas/propostas.controller.js
... ... @@ -22,7 +22,7 @@
22 22 $log.debug('PropostasPageController');
23 23 }
24 24  
25   - PropostasPageController.prototype.init = function () {
  25 + PropostasPageController.prototype.init = function() {
26 26 var vm = this;
27 27  
28 28 vm.themes = null;
... ... @@ -38,7 +38,7 @@
38 38 vm.error = null;
39 39 };
40 40  
41   - PropostasPageController.prototype.loadData = function () {
  41 + PropostasPageController.prototype.loadData = function() {
42 42 var vm = this;
43 43  
44 44 vm.loading = true;
... ... @@ -50,15 +50,15 @@
50 50  
51 51 // 1. Load themes
52 52 vm.loadingThemes = true;
53   - vm.DialogaService.getThemes(function(themes){
  53 + vm.DialogaService.getThemes(function(themes) {
54 54 vm.themes = themes;
55 55 vm.loadingThemes = false;
56 56 vm.loading = false;
57 57  
58   - vm.loadProposals(function (){
  58 + vm.loadProposals(function() {
59 59 vm.attachListeners();
60 60 });
61   - }, function (error) {
  61 + }, function(error) {
62 62 vm.error = error;
63 63 vm.$log.error(error);
64 64 vm.loadingThemes = false;
... ... @@ -66,21 +66,21 @@
66 66 });
67 67 };
68 68  
69   - PropostasPageController.prototype.loadProposals = function (cb) {
  69 + PropostasPageController.prototype.loadProposals = function(cb) {
70 70 var vm = this;
71 71  
72 72 // load Proposals
73 73 vm.loadingProposals = true;
74   - vm.DialogaService.getProposals({}, function(data){
  74 + vm.DialogaService.getProposals({}, function(data) {
75 75 vm.proposals = data.articles;
76 76 vm.filtredProposals = vm.proposals;
77 77 vm.loadingProposals = false;
78 78 vm.loading = false;
79 79  
80   - if(cb){
  80 + if (cb) {
81 81 cb();
82 82 }
83   - }, function (error) {
  83 + }, function(error) {
84 84 vm.error = error;
85 85 vm.$log.error(error);
86 86 vm.loadingProposals = false;
... ... @@ -91,21 +91,21 @@
91 91 PropostasPageController.prototype.attachListeners = function() {
92 92 var vm = this;
93 93  
94   - vm.$scope.$on('change-selectedCategory', function (event, selectedCategory) {
  94 + vm.$scope.$on('change-selectedCategory', function(event, selectedCategory) {
95 95 vm.selectedTheme = selectedCategory;
96 96 });
97 97  
98   - vm.$scope.$watch('pagePropostas.selectedTheme', function(newValue, oldValue) {
  98 + vm.$scope.$watch('pagePropostas.selectedTheme', function(newValue/*, oldValue*/) {
99 99 vm.search.tema = newValue ? newValue.slug : null;
100 100 vm.$location.search('tema', vm.search.tema);
101 101 vm.filtredProposals = vm.getFiltredProposals();
102 102 });
103 103  
104   - vm.$scope.$on('change-selectedTopic', function (event, selectedTopic) {
  104 + vm.$scope.$on('change-selectedTopic', function(event, selectedTopic) {
105 105 vm.selectedProgram = selectedTopic;
106 106 });
107 107  
108   - vm.$scope.$watch('pagePropostas.selectedProgram', function(newValue, oldValue) {
  108 + vm.$scope.$watch('pagePropostas.selectedProgram', function(newValue/*, oldValue*/) {
109 109 vm.search.programa = newValue ? newValue.slug : null;
110 110 vm.$location.search('programa', vm.search.programa);
111 111 vm.filtredProposals = vm.getFiltredProposals();
... ... @@ -128,7 +128,7 @@
128 128 PropostasPageController.prototype.getFiltredProposals = function() {
129 129 var vm = this;
130 130  
131   - if(!vm.proposals){
  131 + if (!vm.proposals) {
132 132 vm.$log.info('No proposals loaded yet. Abort.');
133 133 return null;
134 134 }
... ... @@ -142,64 +142,18 @@
142 142 var filter = vm.$filter('filter');
143 143  
144 144 if (selectedTheme) {
145   - output = vm._filterByCategory(output, selectedTheme);
  145 + output = vm.DialogaService.filterProposalsByCategorySlug(output, selectedTheme.slug);
146 146 }
147 147  
148 148 if (selectedProgram) {
149   - output = vm._filterByProgram(output, selectedProgram);
  149 + output = vm.DialogaService.filterProposalsByProgramId(output, selectedProgram.id);
150 150 }
151 151  
152 152 if (query) {
153 153 output = filter(output, query, false);
154 154 }
155 155  
156   - // if(!query && !selectedTheme && vm._showAllFlag){
157   - // output = _balanceByCategory(output);
158   - // }
159   -
160 156 return output;
161 157 };
162 158  
163   - PropostasPageController.prototype._filterByCategory = function (input, category) {
164   - var vm = this;
165   -
166   - input = input || [];
167   -
168   - if (!category) {
169   - // no filter
170   - return input;
171   - }
172   -
173   - var out = [];
174   - for (var i = 0; i < input.length; i++) {
175   - var proposal = input[i];
176   - if (proposal.parent.categories[0].slug === category.slug) {
177   - out.push(proposal);
178   - }
179   - }
180   -
181   - return out;
182   - }
183   -
184   - PropostasPageController.prototype._filterByProgram = function (input, program) {
185   - var vm = this;
186   -
187   - input = input || [];
188   -
189   - if (!program) {
190   - // no filter
191   - return input;
192   - }
193   -
194   - var out = [];
195   - for (var i = 0; i < input.length; i++) {
196   - var proposal = input[i];
197   - if (proposal.parent.id === program.id) {
198   - out.push(proposal);
199   - }
200   - }
201   -
202   - return out;
203   - }
204   -
205 159 })();
... ...