doortts doortts 2017-09-15
my-issues: Change sorting order - updated first
@61ffbe6f02181dff6a5ba6795aa8e1e8188fa1f0
app/controllers/IssueApp.java
--- app/controllers/IssueApp.java
+++ app/controllers/IssueApp.java
@@ -76,6 +76,12 @@
         }
         searchCondition.pageNum = pageNum - 1;
 
+        // default for my issues
+        String orderBy = request().getQueryString("orderBy");
+        if (StringUtils.isBlank(orderBy)) {
+            searchCondition.orderBy = "updatedDate";
+        }
+
         // determine pjax or json when requested with XHR
         if (HttpUtil.isRequestedWithXHR(request())) {
             format = HttpUtil.isPJAXRequest(request()) ? "pjax" : "json";
@@ -819,6 +825,9 @@
             IssueEvent.addFromNotificationEvent(
                     NotificationEvent.afterStateChanged(issue.previousState(), issue),
                     issue, UserApp.currentUser().loginId);
+        } else {
+            issue.updatedDate = JodaDateUtil.now();
+            issue.update();
         }
 
         return redirect(RouteUtil.getUrl(savedComment));
app/models/AbstractPosting.java
--- app/models/AbstractPosting.java
+++ app/models/AbstractPosting.java
@@ -146,6 +146,8 @@
             super.update();
         } catch (PersistenceException ole) {
             play.Logger.warn("PersistenceException: " + ole.getMessage());
+        } catch (Exception e) {
+            play.Logger.warn(e.getMessage());
         }
         updateMention();
     }
app/utils/TemplateHelper.scala
--- app/utils/TemplateHelper.scala
+++ app/utils/TemplateHelper.scala
@@ -18,6 +18,7 @@
 import models._
 import java.net.URLEncoder
 import java.util
+import java.util.Date
 
 import scala.annotation.tailrec
 import playRepository.FileDiff
@@ -95,11 +96,15 @@
   }
 
   def agoOrDateString(date: java.util.Date) = {
+    var year = JodaDateUtil.getDateString(date, "yyyy")
+    var thisYear = JodaDateUtil.getDateString(new Date(), "yyyy")
     val ago = JodaDateUtil.ago(date)
     if (ago.getStandardDays < 8) {
-        agoString(ago)
+      agoString(ago)
+    } else if (thisYear.equals(year)) {
+      JodaDateUtil.getDateString(date, "MM-dd")
     } else {
-        JodaDateUtil.getDateString(date, "yyyy-MM-dd")
+      JodaDateUtil.getDateString(date, "yyyy-MM-dd")
     }
   }
 
app/views/issue/my_partial_list.scala.html
--- app/views/issue/my_partial_list.scala.html
+++ app/views/issue/my_partial_list.scala.html
@@ -51,6 +51,11 @@
                 <span class="infos-item" data-toggle="tooltip" data-placement="bottom" title="@JodaDateUtil.getDateString(issue.createdDate)">
                     @agoOrDateString(issue.createdDate)
                 </span>
+                @if(!issue.createdDate.equals(issue.updatedDate)) {
+                    <span class="infos-item" data-toggle="tooltip" data-placement="bottom" title="@JodaDateUtil.getDateString(issue.updatedDate)">
+                    update: @agoOrDateString(issue.updatedDate)
+                    </span>
+                }
 
                 @partial_list_subtask(project, issue)
 
Add a comment
List