Commit 0e8518bf6927664cb924c1c0d50164ea75851441
1 parent
e4c7476f
Exists in
master
and in
11 other branches
filter proposal by category
Showing
3 changed files
with
18 additions
and
9 deletions
Show diff stats
index.html
| @@ -31,7 +31,7 @@ | @@ -31,7 +31,7 @@ | ||
| 31 | <img src="{{../host}}{{image.thumb_url}}"/> | 31 | <img src="{{../host}}{{image.thumb_url}}"/> |
| 32 | {{#link name id}}{{/link}} | 32 | {{#link name id}}{{/link}} |
| 33 | <ul id='proposal-item-{{id}}' class='proposal-category-item hide'> | 33 | <ul id='proposal-item-{{id}}' class='proposal-category-item hide'> |
| 34 | - {{#list_proposal ../article.children}} | 34 | + {{#list_proposal ../article.children category=slug}} |
| 35 | {{#link title id}}{{/link}} | 35 | {{#link title id}}{{/link}} |
| 36 | {{/list_proposal}} | 36 | {{/list_proposal}} |
| 37 | </ul> | 37 | </ul> |
| @@ -44,6 +44,7 @@ | @@ -44,6 +44,7 @@ | ||
| 44 | {{#link title id}}{{/link}} | 44 | {{#link title id}}{{/link}} |
| 45 | {{/list_proposal}} | 45 | {{/list_proposal}} |
| 46 | </ul> | 46 | </ul> |
| 47 | + | ||
| 47 | {{#each article.children}} | 48 | {{#each article.children}} |
| 48 | <div class='proposal-detail hide' id="proposal-item-{{id}}"> | 49 | <div class='proposal-detail hide' id="proposal-item-{{id}}"> |
| 49 | <div class='title'>{{title}}</div> | 50 | <div class='title'>{{title}}</div> |
js/handlebars-helpers.js
| @@ -10,18 +10,24 @@ Handlebars.registerHelper('link', function(text, url) { | @@ -10,18 +10,24 @@ Handlebars.registerHelper('link', function(text, url) { | ||
| 10 | Handlebars.registerHelper('list_proposal', function(proposals, options) { | 10 | Handlebars.registerHelper('list_proposal', function(proposals, options) { |
| 11 | 11 | ||
| 12 | var ret = ""; | 12 | var ret = ""; |
| 13 | - | ||
| 14 | for(var i=0, j=proposals.length; i<j; i++) { | 13 | for(var i=0, j=proposals.length; i<j; i++) { |
| 15 | - ret = ret + "<li class='proposal-item'>"; | ||
| 16 | - ret = ret + "<ul class='category'>"; | 14 | + element = "<li class='proposal-item'>"; |
| 15 | + element = element + "<ul class='category'>"; | ||
| 17 | 16 | ||
| 18 | for(var x=0, y=proposals[i].categories.length; x<y; x++) { | 17 | for(var x=0, y=proposals[i].categories.length; x<y; x++) { |
| 19 | - ret = ret + '<li>' + proposals[i].categories[x].name + '</li>'; | 18 | + if((options.hash['category'] != null) && (options.hash['category'] != proposals[i].categories[x].slug)){ |
| 19 | + element = ''; | ||
| 20 | + continue; | ||
| 21 | + } | ||
| 22 | + element = element + '<li>' + proposals[i].categories[x].name + '</li>'; | ||
| 23 | + } | ||
| 24 | + if(element == ''){ | ||
| 25 | + continue; | ||
| 20 | } | 26 | } |
| 21 | - ret = ret + '</ul>'; | ||
| 22 | - ret = ret + options.fn(proposals[i]); | ||
| 23 | - ret = ret + '<p>' + proposals[i].body + '</p>'; | ||
| 24 | - ret = ret + '</li>'; | 27 | + element = element + '</ul>'; |
| 28 | + element = element + options.fn(proposals[i]); | ||
| 29 | + element = element + '<p>' + proposals[i].body + '</p>'; | ||
| 30 | + ret = ret + element + '</li>'; | ||
| 25 | } | 31 | } |
| 26 | 32 | ||
| 27 | return ret; | 33 | return ret; |
js/main.js
| @@ -33,6 +33,8 @@ $.getJSON(noosferoAPI) | @@ -33,6 +33,8 @@ $.getJSON(noosferoAPI) | ||
| 33 | $('#proposal-categories').show(); | 33 | $('#proposal-categories').show(); |
| 34 | $('#nav-proposal-categories a').addClass('active'); | 34 | $('#nav-proposal-categories a').addClass('active'); |
| 35 | $('#nav-proposal-group a').removeClass('active'); | 35 | $('#nav-proposal-group a').removeClass('active'); |
| 36 | + $('.proposal-category-item').hide(); | ||
| 37 | + $('.proposal-detail').hide(); | ||
| 36 | }else if(item == 'proposal-group'){ | 38 | }else if(item == 'proposal-group'){ |
| 37 | //Display the Topics or Discussions tab | 39 | //Display the Topics or Discussions tab |
| 38 | $('#proposal-categories').hide(); | 40 | $('#proposal-categories').hide(); |