[Notice] Announcing the End of Demo Server [Read me]
Keesun Baik 2013-04-25
sorting posts
@688f4e67233e6f0f67fbbaf0982bef0ecaeca59e
app/controllers/BoardApp.java
--- app/controllers/BoardApp.java
+++ app/controllers/BoardApp.java
@@ -61,6 +61,9 @@
         Form<SearchCondition> postParamForm = new Form<SearchCondition>(SearchCondition.class);
         SearchCondition searchCondition = postParamForm.bindFromRequest().get();
         searchCondition.pageNum = pageNum - 1;
+        if(searchCondition.orderBy.equals("id")) {
+            searchCondition.orderBy = "createdDate";
+        }
 
         ExpressionList<Posting> el = searchCondition.asExpressionList(project);
         Page<Posting> posts = el.findPagingList(ITEMS_PER_PAGE).getPage(searchCondition.pageNum);
app/views/board/postList.scala.html
--- app/views/board/postList.scala.html
+++ app/views/board/postList.scala.html
@@ -4,6 +4,8 @@
 @import utils.AccessControl._
 @import scala.collection.immutable.Map
 
+@urlToList = {@routes.BoardApp.posts(project.owner, project.name, page.getPageIndex + 1)}
+
 @** header(label:String, key:String) = {
   <th>
     <a key="@key" href="@routes.BoardApp.posts(project.owner, project.name)">@label</a>
@@ -28,7 +30,7 @@
         <form method="get" id="option_form">
           <input type="hidden" name="orderBy"  value="@param.orderBy">
           <input type="hidden" name="orderDir" value="@param.orderDir">
-          <input name="filter" class="text" type="text" placeholder="@Messages("project.searchPlaceholder")" value="@param.filter"><!-- 
+          <input name="filter" class="text" type="text" placeholder="@Messages("project.searchPlaceholder")" value="@param.filter"><!--
            --><button type="submit" class="btn search-btn underConstruction">@Messages("post.menu.search")</button>
         </form>
       </div>
@@ -77,13 +79,25 @@
 
   <div class="filter-wrap board">
       <div class="filters" id="order">
-          <a href="#" key="date" class="filter underConstruction @if(param.orderBy == "date"){ active }">
-			<i class="ico btn-gray-arrow @if(param.orderBy == "date" && param.orderDir == "desc"){down}"></i>날짜순
-          </a>
+          @if(param.orderBy.equals("createdDate")) {
+            @if(param.orderDir.equals("asc")) {
+                <a href="#" data-orderBy="createdDate" data-orderDir="desc" class="filter active"><i class="ico btn-gray-arrow"></i>날짜순</a>
+            } else {
+                <a href="#" data-orderBy="createdDate" data-orderDir="asc" class="filter active"><i class="ico btn-gray-arrow down"></i>날짜순</a>
+            }
+          } else {
+              <a href="#" data-orderBy="createdDate" data-orderDir="asc" class="filter"><i class="ico btn-gray-arrow"></i>날짜순</a>
+          }
 
-          <a href="#" key="commentCount" class="filter underConstruction @if(param.orderBy == "commentCount"){ active }">
-            <i class="ico btn-gray-arrow @if(param.orderBy == "commentCount" && param.orderDir == "desc"){down}"></i>댓글순
-          </a>
+          @if(param.orderBy.equals("numOfComments")) {
+              @if(param.orderDir.equals("asc")) {
+                  <a href="#" data-orderBy="numOfComments" data-orderDir="desc" class="filter active"><i class="ico btn-gray-arrow"></i>댓글순</a>
+              } else {
+                  <a href="#" data-orderBy="numOfComments" data-orderDir="asc" class="filter active"><i class="ico btn-gray-arrow down"></i>댓글순</a>
+              }
+          } else {
+              <a href="#" data-orderBy="numOfComments" data-orderDir="asc" class="filter"><i class="ico btn-gray-arrow"></i>댓글순</a>
+          }
       </div>
   </div>
 
public/javascripts/service/hive.board.List.js
--- public/javascripts/service/hive.board.List.js
+++ public/javascripts/service/hive.board.List.js
@@ -3,15 +3,15 @@
  *
  * Copyright NHN Corporation.
  * Released under the MIT license
- * 
+ *
  * http://hive.dev.naver.com/license
  */
 
 (function(ns){
-	
+
 	var oNS = $hive.createNamespace(ns);
 	oNS.container[oNS.name] = function(htOptions){
-		
+
 		var htElement = {};
     	var htOrderMap = {"asc": "desc", "desc": "asc"};
 
@@ -22,7 +22,7 @@
 		function _init(htOptions){
 			_initElement(htOptions || {});
 			_attachEvent();
-			
+
 			_initPagination(htOptions);
 		}
 
@@ -31,12 +31,12 @@
 		 */
 		function _initElement(htOptions){
 			htElement.welForm = $(htOptions.sOptionForm || "#option_form");
-			htElement.welInputKey = htElement.welForm.find("input[name=key]");
-			htElement.welInputOrder = htElement.welForm.find("input[name=order]");
+			htElement.welInputOrderBy = htElement.welForm.find("input[name=orderBy]");
+			htElement.welInputOrderDir = htElement.welForm.find("input[name=orderDir]");
 			htElement.welInputPageNum = htElement.welForm.find("input[name=pageNum]");
-			
+
 			htElement.welFilter = $(htOptions.sQueryFilter || "#order a");
-			htElement.welPages = $(htOptions.sQueryPages || "#pagination a"); 
+			htElement.welPages = $(htOptions.sQueryPages || "#pagination a");
 			htElement.welPagination = $(htOptions.elPagination || '#pagination');
 		}
 
@@ -52,15 +52,12 @@
          * onClick filter
          */
         function _onClickFilter(){
-            var sKey = $(this).attr("key");
+            var orderBy = $(this).attr("data-orderBy");
+            var orderDir = $(this).attr("data-orderDir");
 
-        	// Key
-            if (sKey !== htElement.welInputKey.val()) {
-            	htElement.welInputKey.val(sKey)
-            } else { // Order
-            	var sCurrentVal = htElement.welInputOrder.val();
-            	htElement.welInputOrder.val(htOrderMap[sCurrentVal]);
-            }
+            htElement.welInputOrderBy.val(orderBy);
+            htElement.welInputOrderDir.val(orderDir);
+
             htElement.welForm.submit();
             return false;
         }
@@ -73,15 +70,15 @@
         	htElement.welForm.submit();
             return false;
         }
-        
-        
+
+
         function _initPagination(htOptions){
         	hive.Pagination.update(htElement.welPagination, htOptions.nTotalPages);
         }
-        
+
         _init(htOptions);
 	};
-	
+
 })("hive.board.List");
 
 /*
@@ -95,7 +92,7 @@
         "setUpEventListener" : function() {
             var $headers = $("#order a");
             $headers.click(that.onHeader);
-            
+
             var $pagination = $("#pagination a");
             $pagination.click(that.onPager);
         },
@@ -124,7 +121,7 @@
             return false;
         }
     };
-    
+
     return that;
 };
 */
(No newline at end of file)
Add a comment
List