Commit 1f88da399b7e429d43fda0ecc6b2dc614cc09612
1 parent
6fb80e5e
Exists in
master
and in
8 other branches
Sort proposals by ranking position
Showing
2 changed files
with
11 additions
and
1 deletions
Show diff stats
src/app/components/article-service/article.service.js
| @@ -219,6 +219,7 @@ | @@ -219,6 +219,7 @@ | ||
| 219 | 219 | ||
| 220 | UtilService.get(url, {params: paramsExtended}).then(function(data){ | 220 | UtilService.get(url, {params: paramsExtended}).then(function(data){ |
| 221 | _pipeInjectSlugIntoParentProgram(data); | 221 | _pipeInjectSlugIntoParentProgram(data); |
| 222 | + _pipeSortByRankinPosition(data); | ||
| 222 | cbSuccess(data); | 223 | cbSuccess(data); |
| 223 | }).catch(function(error){ | 224 | }).catch(function(error){ |
| 224 | cbError(error); | 225 | cbError(error); |
| @@ -237,5 +238,14 @@ | @@ -237,5 +238,14 @@ | ||
| 237 | } | 238 | } |
| 238 | } | 239 | } |
| 239 | } | 240 | } |
| 241 | + | ||
| 242 | + function _pipeSortByRankinPosition(data){ | ||
| 243 | + if(!data.articles && data.article){ | ||
| 244 | + data.articles = [data.article]; | ||
| 245 | + } | ||
| 246 | + data.articles = data.articles.sort(function(pA, pB){ | ||
| 247 | + return pA.ranking_position - pB.ranking_position; | ||
| 248 | + }); | ||
| 249 | + } | ||
| 240 | } | 250 | } |
| 241 | })(); | 251 | })(); |
src/app/components/proposal-list/proposal-list.html
| @@ -32,7 +32,7 @@ | @@ -32,7 +32,7 @@ | ||
| 32 | </button> | 32 | </button> |
| 33 | </div> | 33 | </div> |
| 34 | <div class="col-md-4"> | 34 | <div class="col-md-4"> |
| 35 | - <proposal-stats views="{{::proposal.hits}}" up="{{::proposal.votes_for}}" down="{{::proposal.votes_against}}"></proposal-stats> | 35 | + <proposal-stats class="text-right" views="{{::proposal.hits}}" up="{{::proposal.votes_for}}" down="{{::proposal.votes_against}}"></proposal-stats> |
| 36 | </div> | 36 | </div> |
| 37 | </div> | 37 | </div> |
| 38 | </td> | 38 | </td> |