[Notice] Announcing the End of Demo Server [Read me]

sorting posts
@688f4e67233e6f0f67fbbaf0982bef0ecaeca59e
--- app/controllers/BoardApp.java
+++ app/controllers/BoardApp.java
... | ... | @@ -61,6 +61,9 @@ |
61 | 61 |
Form<SearchCondition> postParamForm = new Form<SearchCondition>(SearchCondition.class); |
62 | 62 |
SearchCondition searchCondition = postParamForm.bindFromRequest().get(); |
63 | 63 |
searchCondition.pageNum = pageNum - 1; |
64 |
+ if(searchCondition.orderBy.equals("id")) { |
|
65 |
+ searchCondition.orderBy = "createdDate"; |
|
66 |
+ } |
|
64 | 67 |
|
65 | 68 |
ExpressionList<Posting> el = searchCondition.asExpressionList(project); |
66 | 69 |
Page<Posting> posts = el.findPagingList(ITEMS_PER_PAGE).getPage(searchCondition.pageNum); |
--- app/views/board/postList.scala.html
+++ app/views/board/postList.scala.html
... | ... | @@ -4,6 +4,8 @@ |
4 | 4 |
@import utils.AccessControl._ |
5 | 5 |
@import scala.collection.immutable.Map |
6 | 6 |
|
7 |
+@urlToList = {@routes.BoardApp.posts(project.owner, project.name, page.getPageIndex + 1)} |
|
8 |
+ |
|
7 | 9 |
@** header(label:String, key:String) = { |
8 | 10 |
<th> |
9 | 11 |
<a key="@key" href="@routes.BoardApp.posts(project.owner, project.name)">@label</a> |
... | ... | @@ -28,7 +30,7 @@ |
28 | 30 |
<form method="get" id="option_form"> |
29 | 31 |
<input type="hidden" name="orderBy" value="@param.orderBy"> |
30 | 32 |
<input type="hidden" name="orderDir" value="@param.orderDir"> |
31 |
- <input name="filter" class="text" type="text" placeholder="@Messages("project.searchPlaceholder")" value="@param.filter"><!-- |
|
33 |
+ <input name="filter" class="text" type="text" placeholder="@Messages("project.searchPlaceholder")" value="@param.filter"><!-- |
|
32 | 34 |
--><button type="submit" class="btn search-btn underConstruction">@Messages("post.menu.search")</button> |
33 | 35 |
</form> |
34 | 36 |
</div> |
... | ... | @@ -77,13 +79,25 @@ |
77 | 79 |
|
78 | 80 |
<div class="filter-wrap board"> |
79 | 81 |
<div class="filters" id="order"> |
80 |
- <a href="#" key="date" class="filter underConstruction @if(param.orderBy == "date"){ active }"> |
|
81 |
- <i class="ico btn-gray-arrow @if(param.orderBy == "date" && param.orderDir == "desc"){down}"></i>날짜순 |
|
82 |
- </a> |
|
82 |
+ @if(param.orderBy.equals("createdDate")) { |
|
83 |
+ @if(param.orderDir.equals("asc")) { |
|
84 |
+ <a href="#" data-orderBy="createdDate" data-orderDir="desc" class="filter active"><i class="ico btn-gray-arrow"></i>날짜순</a> |
|
85 |
+ } else { |
|
86 |
+ <a href="#" data-orderBy="createdDate" data-orderDir="asc" class="filter active"><i class="ico btn-gray-arrow down"></i>날짜순</a> |
|
87 |
+ } |
|
88 |
+ } else { |
|
89 |
+ <a href="#" data-orderBy="createdDate" data-orderDir="asc" class="filter"><i class="ico btn-gray-arrow"></i>날짜순</a> |
|
90 |
+ } |
|
83 | 91 |
|
84 |
- <a href="#" key="commentCount" class="filter underConstruction @if(param.orderBy == "commentCount"){ active }"> |
|
85 |
- <i class="ico btn-gray-arrow @if(param.orderBy == "commentCount" && param.orderDir == "desc"){down}"></i>댓글순 |
|
86 |
- </a> |
|
92 |
+ @if(param.orderBy.equals("numOfComments")) { |
|
93 |
+ @if(param.orderDir.equals("asc")) { |
|
94 |
+ <a href="#" data-orderBy="numOfComments" data-orderDir="desc" class="filter active"><i class="ico btn-gray-arrow"></i>댓글순</a> |
|
95 |
+ } else { |
|
96 |
+ <a href="#" data-orderBy="numOfComments" data-orderDir="asc" class="filter active"><i class="ico btn-gray-arrow down"></i>댓글순</a> |
|
97 |
+ } |
|
98 |
+ } else { |
|
99 |
+ <a href="#" data-orderBy="numOfComments" data-orderDir="asc" class="filter"><i class="ico btn-gray-arrow"></i>댓글순</a> |
|
100 |
+ } |
|
87 | 101 |
</div> |
88 | 102 |
</div> |
89 | 103 |
|
--- public/javascripts/service/hive.board.List.js
+++ public/javascripts/service/hive.board.List.js
... | ... | @@ -3,15 +3,15 @@ |
3 | 3 |
* |
4 | 4 |
* Copyright NHN Corporation. |
5 | 5 |
* Released under the MIT license |
6 |
- * |
|
6 |
+ * |
|
7 | 7 |
* http://hive.dev.naver.com/license |
8 | 8 |
*/ |
9 | 9 |
|
10 | 10 |
(function(ns){ |
11 |
- |
|
11 |
+ |
|
12 | 12 |
var oNS = $hive.createNamespace(ns); |
13 | 13 |
oNS.container[oNS.name] = function(htOptions){ |
14 |
- |
|
14 |
+ |
|
15 | 15 |
var htElement = {}; |
16 | 16 |
var htOrderMap = {"asc": "desc", "desc": "asc"}; |
17 | 17 |
|
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 |
function _init(htOptions){ |
23 | 23 |
_initElement(htOptions || {}); |
24 | 24 |
_attachEvent(); |
25 |
- |
|
25 |
+ |
|
26 | 26 |
_initPagination(htOptions); |
27 | 27 |
} |
28 | 28 |
|
... | ... | @@ -31,12 +31,12 @@ |
31 | 31 |
*/ |
32 | 32 |
function _initElement(htOptions){ |
33 | 33 |
htElement.welForm = $(htOptions.sOptionForm || "#option_form"); |
34 |
- htElement.welInputKey = htElement.welForm.find("input[name=key]"); |
|
35 |
- htElement.welInputOrder = htElement.welForm.find("input[name=order]"); |
|
34 |
+ htElement.welInputOrderBy = htElement.welForm.find("input[name=orderBy]"); |
|
35 |
+ htElement.welInputOrderDir = htElement.welForm.find("input[name=orderDir]"); |
|
36 | 36 |
htElement.welInputPageNum = htElement.welForm.find("input[name=pageNum]"); |
37 |
- |
|
37 |
+ |
|
38 | 38 |
htElement.welFilter = $(htOptions.sQueryFilter || "#order a"); |
39 |
- htElement.welPages = $(htOptions.sQueryPages || "#pagination a"); |
|
39 |
+ htElement.welPages = $(htOptions.sQueryPages || "#pagination a"); |
|
40 | 40 |
htElement.welPagination = $(htOptions.elPagination || '#pagination'); |
41 | 41 |
} |
42 | 42 |
|
... | ... | @@ -52,15 +52,12 @@ |
52 | 52 |
* onClick filter |
53 | 53 |
*/ |
54 | 54 |
function _onClickFilter(){ |
55 |
- var sKey = $(this).attr("key"); |
|
55 |
+ var orderBy = $(this).attr("data-orderBy"); |
|
56 |
+ var orderDir = $(this).attr("data-orderDir"); |
|
56 | 57 |
|
57 |
- // Key |
|
58 |
- if (sKey !== htElement.welInputKey.val()) { |
|
59 |
- htElement.welInputKey.val(sKey) |
|
60 |
- } else { // Order |
|
61 |
- var sCurrentVal = htElement.welInputOrder.val(); |
|
62 |
- htElement.welInputOrder.val(htOrderMap[sCurrentVal]); |
|
63 |
- } |
|
58 |
+ htElement.welInputOrderBy.val(orderBy); |
|
59 |
+ htElement.welInputOrderDir.val(orderDir); |
|
60 |
+ |
|
64 | 61 |
htElement.welForm.submit(); |
65 | 62 |
return false; |
66 | 63 |
} |
... | ... | @@ -73,15 +70,15 @@ |
73 | 70 |
htElement.welForm.submit(); |
74 | 71 |
return false; |
75 | 72 |
} |
76 |
- |
|
77 |
- |
|
73 |
+ |
|
74 |
+ |
|
78 | 75 |
function _initPagination(htOptions){ |
79 | 76 |
hive.Pagination.update(htElement.welPagination, htOptions.nTotalPages); |
80 | 77 |
} |
81 |
- |
|
78 |
+ |
|
82 | 79 |
_init(htOptions); |
83 | 80 |
}; |
84 |
- |
|
81 |
+ |
|
85 | 82 |
})("hive.board.List"); |
86 | 83 |
|
87 | 84 |
/* |
... | ... | @@ -95,7 +92,7 @@ |
95 | 92 |
"setUpEventListener" : function() { |
96 | 93 |
var $headers = $("#order a"); |
97 | 94 |
$headers.click(that.onHeader); |
98 |
- |
|
95 |
+ |
|
99 | 96 |
var $pagination = $("#pagination a"); |
100 | 97 |
$pagination.click(that.onPager); |
101 | 98 |
}, |
... | ... | @@ -124,7 +121,7 @@ |
124 | 121 |
return false; |
125 | 122 |
} |
126 | 123 |
}; |
127 |
- |
|
124 |
+ |
|
128 | 125 |
return that; |
129 | 126 |
}; |
130 | 127 |
*/(No newline at end of file) |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?