doortts doortts 2017-09-07
view: Move some buttons to right side menu
@523abbbb5f2318fa77163cb697f90566dc48aec9
app/assets/stylesheets/less/_page.less
--- app/assets/stylesheets/less/_page.less
+++ app/assets/stylesheets/less/_page.less
@@ -2747,6 +2747,7 @@
 
     .posting-history {
         display: inline-block;
+        margin-left: 10px;
     }
 
     .content {
@@ -2763,6 +2764,30 @@
     }
     textarea.content {
         padding:6px;
+    }
+    .right-menu-icons {
+        button.icon {
+            line-height: 30px;
+            font-size: 22px;
+            color: lightgray;
+            .yobicon-lang {
+                font-size: 20px;
+            }
+            &.disabled {
+                color: #eee !important;
+            }
+            &:hover {
+                color: #51aacc;
+                opacity: 1;
+            }
+        }
+        .pt5px {
+            padding-top: 5px;
+        }
+    }
+
+    .count {
+        margin-left: -3px;
     }
 }
 
@@ -3905,6 +3930,9 @@
     margin-left:3px;
     font-size:@base-font-size;
     vertical-align:middle;
+    a:hover {
+        text-decoration: none;
+    }
 
     .ybtn  {
         padding:3px 12px !important;
app/assets/stylesheets/less/_responsive.less
--- app/assets/stylesheets/less/_responsive.less
+++ app/assets/stylesheets/less/_responsive.less
@@ -224,6 +224,10 @@
         display: block !important;
     }
 
+    .show-in-mobile-inline {
+        display: inline-block !important;
+    }
+
     .hide-in-mobile {
         display: none !important;
     }
app/models/Issue.java
--- app/models/Issue.java
+++ app/models/Issue.java
@@ -581,7 +581,13 @@
      * @return True if the user has voted, if not False
      */
     public boolean isVotedBy(User user) {
-        return this.voters.contains(user);
+        for(User voter: this.voters) {
+            play.Logger.debug(user + " : " + voter);
+            if(voter != null && user != null && voter.loginId.equals(user.loginId)) {
+                return true;
+            }
+        }
+        return false;
     }
 
     public String getDueDateString() {
app/views/board/view.scala.html
--- app/views/board/view.scala.html
+++ app/views/board/view.scala.html
@@ -63,19 +63,19 @@
                                 <strong class="name">@Messages("common.noAuthor")</strong>
                             }
                         </a>
-                </div>
-                @if(StringUtils.isNotEmpty(post.history)){
-                    @if(UserApp.currentUser().isAnonymous){
-                        <div class="posting-history">
-                            <a href="@routes.UserApp.loginForm()?redirectUrl=@routes.BoardApp.post(project.owner, project.name, post.getNumber)" data-toggle="modal">@Messages("change.history")</a>
-                        </div>
-                    } else {
-                        <div class="posting-history">
-                            <a href="#-yona-posting-history" data-toggle="modal">@Messages("change.history")</a>
-                            @common.partial_history(post)
-                        </div>
+                    @if(StringUtils.isNotEmpty(post.history)){
+                        @if(UserApp.currentUser().isAnonymous){
+                            <div class="posting-history">
+                                <a href="@routes.UserApp.loginForm()?redirectUrl=@routes.BoardApp.post(project.owner, project.name, post.getNumber)" data-toggle="modal">@Messages("change.history")</a>
+                            </div>
+                        } else {
+                            <div class="posting-history">
+                                <a href="#-yona-posting-history" data-toggle="modal">@Messages("change.history")</a>
+                                @common.partial_history(post)
+                            </div>
+                        }
                     }
-                }
+                </div>
                 @if(StringUtils.isEmpty(post.body)){
                     <div class="content empty-content"></div>
                 } else {
@@ -98,20 +98,21 @@
                         </div>
                     </div>
 
-                    @if(StringUtils.isNotBlank(IssueApi.TRANSLATION_API)){
-                        <button type="button" id="translate" class="icon btn-transparent-with-fontsize-lineheight ml10"  data-toggle="tooltip" title="@Messages("button.translation")"><i class="yobicon-lang"></i></button>
+                    @if(StringUtils.isNotBlank(IssueApi.TRANSLATION_API)) {
+                        <button type="button" id="translate" class="icon btn-transparent-with-fontsize-lineheight ml10" data-toggle="tooltip" title="@Messages("button.translation")"><i class="yobicon-lang"></i></button>
                     }
+                    <span class="hide show-in-mobile-inline">
+                        @if(isAllowed(UserApp.currentUser(), post.asResource(), Operation.UPDATE)) {
+                            <button type="button" class="icon btn-transparent-with-fontsize-lineheight ml10 pt5px" data-toggle="tooltip" title="@Messages("button.edit")" onclick="window.location = '@routes.BoardApp.editPostForm(project.owner, project.name, post.getNumber)'"><i class="yobicon-edit-2"></i></button>
+                        } else {
+                            <a href="@routes.BoardApp.editPostForm(project.owner, project.name, post.getNumber)"><button type="button" class="icon btn-transparent-with-fontsize-lineheight ml10 pt5px" data-toggle="tooltip" title="@Messages("button.show.original")"><i class="yobicon-edit-2"></i></button></a>
+                        }
 
-                    @if(isAllowed(UserApp.currentUser(), post.asResource(), Operation.UPDATE)) {
-                        <button type="button" class="icon btn-transparent-with-fontsize-lineheight ml10 pt5px" data-toggle="tooltip" title="@Messages("button.edit")" onclick="window.location='@routes.BoardApp.editPostForm(project.owner, project.name, post.getNumber)'"><i class="yobicon-edit-2"></i></button>
-                    } else {
-                        <a href="@routes.BoardApp.editPostForm(project.owner, project.name, post.getNumber)"><button type="button" class="icon btn-transparent-with-fontsize-lineheight ml10 pt5px" data-toggle="tooltip" title="@Messages("button.show.original")"><i class="yobicon-edit-2"></i></button></a>
-                    }
-
-                    @if(isAllowed(UserApp.currentUser(), post.asResource(), Operation.DELETE)) {
-                        <a href="#deleteConfirm" data-toggle="modal">
-                            <button type="button" class="icon btn-transparent-with-fontsize-lineheight ml6" data-toggle='tooltip' title="@Messages("button.delete")"><i class="yobicon-trash"></i></button></a>
-                    }
+                        @if(isAllowed(UserApp.currentUser(), post.asResource(), Operation.DELETE)) {
+                            <a href="#deleteConfirm" data-toggle="modal">
+                                <button type="button" class="icon btn-transparent-with-fontsize-lineheight ml6" data-toggle='tooltip' title="@Messages("button.delete")"><i class="yobicon-trash"></i></button></a>
+                        }
+                    </span>
                 </div>
                 <div class="watcher-list"></div>
                 @** Comment **@
@@ -144,6 +145,18 @@
                             }
                         }
                         @**<!-- // -->**@
+                    <div class="right-menu-icons">
+                        @if(isAllowed(UserApp.currentUser(), post.asResource(), Operation.UPDATE)) {
+                            <button type="button" class="icon btn-transparent-with-fontsize-lineheight ml10 pt5px" data-toggle="tooltip" title="@Messages("button.edit")" onclick="window.location='@routes.BoardApp.editPostForm(project.owner, project.name, post.getNumber)'"><i class="yobicon-edit-2"></i></button>
+                        } else {
+                            <a href="@routes.BoardApp.editPostForm(project.owner, project.name, post.getNumber)"><button type="button" class="icon btn-transparent-with-fontsize-lineheight ml10 pt5px" data-toggle="tooltip" title="@Messages("button.show.original")"><i class="yobicon-edit-2"></i></button></a>
+                        }
+
+                        @if(isAllowed(UserApp.currentUser(), post.asResource(), Operation.DELETE)) {
+                            <a href="#deleteConfirm" data-toggle="modal">
+                                <button type="button" class="icon btn-transparent-with-fontsize-lineheight ml6" data-toggle='tooltip' title="@Messages("button.delete")"><i class="yobicon-trash"></i></button></a>
+                        }
+                    </div>
                 </div>
             </div>
         </div>
app/views/issue/partial_voters.scala.html
--- app/views/issue/partial_voters.scala.html
+++ app/views/issue/partial_voters.scala.html
@@ -14,24 +14,24 @@
             <li>@Html(getUserAvatar(UserApp.currentUser, "smaller"))</li>
         }
 
-        @defining(VoteApp.getVotersExceptCurrentUser(issue.voters)) { issueVoters =>
-            @for(voter <- VoteApp.getVotersForAvatar(issueVoters, numOfAvatars)) {
-                <li>@Html(getUserAvatar(voter, "smaller"))</li>
+        @for(voter <- VoteApp.getVotersForAvatar(issue.voters, numOfAvatars)) {
+            @if(voter != UserApp.currentUser) {
+            <li>@Html(getUserAvatar(voter, "smaller"))</li>
             }
-            @if(issueVoters.size > numOfAvatars) {
-                <li data-toggle="tooltip" data-html="true"
-                    title="
-                    @for(voter <- VoteApp.getVotersForName(issueVoters, numOfAvatars, numOfNames)) {
-                        @voter.name <br>
-                    }
-                    @if(issueVoters.size > numOfAvatars + numOfNames) {
-                            &hellip;
-                    }">
-                    <a href="#voters" data-toggle="modal">
-                        @Messages("issue.voters.more", issueVoters.size - numOfAvatars)
-                    </a>
-                </li>
-            }
+        }
+        @if(issue.voters.size > numOfAvatars) {
+            <li data-toggle="tooltip" data-html="true"
+                title="
+                @for(voter <- VoteApp.getVotersForName(issue.voters, numOfAvatars, numOfNames)) {
+                    @voter.name <br>
+                }
+                @if(issue.voters.size > numOfAvatars + numOfNames) {
+                        &hellip;
+                }">
+                <a href="#voters" data-toggle="modal">
+                    @Messages("issue.voters.more", issue.voters.size - numOfAvatars)
+                </a>
+            </li>
         }
     </ul>
 </div>
app/views/issue/view.scala.html
--- app/views/issue/view.scala.html
+++ app/views/issue/view.scala.html
@@ -28,8 +28,12 @@
   }
 }
 
+@isVotedByCurrentUser = @{
+    issue.isVotedBy(UserApp.currentUser)
+}
+
 @urlToVote = @{
-    if(issue.isVotedBy(UserApp.currentUser)){
+    if(isVotedByCurrentUser){
         routes.VoteApp.unvote(project.owner, project.name, issue.getNumber).toString
     } else {
         routes.VoteApp.vote(project.owner, project.name, issue.getNumber).toString
@@ -37,7 +41,7 @@
 }
 
 @getVoteButtonTitle = {
-    @if(issue.isVotedBy(UserApp.currentUser)){
+    @if(isVotedByCurrentUser){
         @Messages("issue.unvote.description")
     } else {
         @Messages("issue.vote.description")
@@ -135,19 +139,20 @@
                                 <strong class="name">@Messages("issue.noAuthor")</strong>
                             }
                         </a>
-                </div>
-                @if(StringUtils.isNotEmpty(issue.history)){
-                    @if(UserApp.currentUser().isAnonymous){
-                        <div class="posting-history">
-                            <a href="@routes.UserApp.loginForm()?redirectUrl=@routes.IssueApp.issue(project.owner, project.name, issue.getNumber)" data-toggle="modal">@Messages("change.history")</a>
-                        </div>
-                    } else {
-                        <div class="posting-history">
-                            <a href="#-yona-posting-history" data-toggle="modal">@Messages("change.history")</a>
-                            @common.partial_history(issue)
-                        </div>
+                    @if(StringUtils.isNotEmpty(issue.history)){
+                        @if(UserApp.currentUser().isAnonymous){
+                            <div class="posting-history">
+                                <a href="@routes.UserApp.loginForm()?redirectUrl=@routes.IssueApp.issue(project.owner, project.name, issue.getNumber)" data-toggle="modal">@Messages("change.history")</a>
+                            </div>
+                        } else {
+                            <div class="posting-history">
+                                <a href="#-yona-posting-history" data-toggle="modal">@Messages("change.history")</a>
+                                @common.partial_history(issue)
+                            </div>
+                        }
                     }
-                }
+                </div>
+
                 @if(StringUtils.isEmpty(issue.body)){
                     <div class="content empty-content"></div>
                 } else {
@@ -167,35 +172,37 @@
                                 }
                                 </button>
                             }
-                            <div id="vote" class="vote-wrap">
-                                @if(isResourceCreatable(UserApp.currentUser, issue.asResource(), ResourceType.ISSUE_COMMENT)) {
-                                    <a href="@urlToVote" class="ybtn @if(issue.isVotedBy(UserApp.currentUser)){ybtn-watching}" title="@getVoteButtonTitle"
-                                       data-request-method="post" data-toggle="tooltip">
-                                        <span class="heart"><i class="yobicon-hearts"></i></span>
-                                        @if(issue.voters.size > 0) {
-                                            <strong class="count">@issue.voters.size</strong>
-                                        }
-                                    </a>
-                                } else {
-                                    <span class="ybtn ybtn-disabled" style="color:#777;" data-toggle="tooltip" title="@Messages("user.login.alert")" data-login="required">
-                                        <span class="heart"><i class="yobicon-hearts"></i></span>
-                                        @if(issue.voters.size > 0) {
-                                            <strong class="count">@issue.voters.size</strong>
-                                        }
-                                    </span>
-                                }
 
-                                @if(issue.voters.size > 0){
-                                    @partial_voters(issue, 3)
-                                }
-                            </div>
                         </div>
                     </div>
 
+                    <div id="vote" class="vote-wrap">
+                        @if(issue.voters.size > 0) {
+                            @partial_voters(issue, 3)
+                        }
+                        @if(isResourceCreatable(UserApp.currentUser, issue.asResource(), ResourceType.ISSUE_COMMENT)) {
+                            <a href="@urlToVote" class="@if(issue.isVotedBy(UserApp.currentUser)) {ybtn-watching}" title="@getVoteButtonTitle"
+                            data-request-method="post" data-toggle="tooltip">
+                                <span class="heart"><i class="yobicon-hearts"></i></span>
+                                @if(issue.voters.size > 0) {
+                                    <strong class="count">@issue.voters.size</strong>
+                                }
+                            </a>
+                        } else {
+                            <span class="ybtn-disabled" style="color: #777;" data-toggle="tooltip" title="@Messages("user.login.alert")" data-login="required">
+                                <span class="heart"><i class="yobicon-hearts"></i></span>
+                                @if(issue.voters.size > 0) {
+                                    <strong class="count">@issue.voters.size</strong>
+                                }
+                            </span>
+                        }
+
+                    </div>
                     @if(StringUtils.isNotBlank(IssueApi.TRANSLATION_API)){
                         <button type="button" id="translate" class="icon btn-transparent-with-fontsize-lineheight ml10"  data-toggle="tooltip" title="@Messages("button.translation")"><i class="yobicon-lang"></i></button>
                     }
 
+                    <span class="act-row hide show-in-mobile-inline">
                     @if(isAllowed(UserApp.currentUser(), issue.asResource(), Operation.UPDATE)) {
                         <button type="button" class="icon btn-transparent-with-fontsize-lineheight ml10 pt5px" data-toggle="tooltip" title="@Messages("button.edit")" onclick="window.location='@routes.IssueApp.editIssueForm(project.owner, project.name, issue.getNumber)'"><i class="yobicon-edit-2"></i></button>
                     } else {
@@ -209,6 +216,7 @@
                     } else {
                         <button type="button" class="icon disabled btn-transparent-with-fontsize-lineheight ml6" data-toggle='popover' data-trigger="hover" data-placement="top" data-content="@Messages("issue.can.not.be.deleted")"><i class="yobicon-trash"></i></button>
                     }
+                    </span>
                 </div>
                 <div class="watcher-list"></div>
                 <div class="subtasks">
@@ -360,6 +368,21 @@
                                 @partial_show_selected_label(issue.labels.toList, routes.IssueApp.issues(project.owner, project.name, issue.state.state(), "html", 1).toString)
                             }
                         }
+                        <div class="act-row right-menu-icons">
+                            @if(isAllowed(UserApp.currentUser(), issue.asResource(), Operation.UPDATE)) {
+                                <button type="button" class="icon btn-transparent-with-fontsize-lineheight ml10 pt5px" data-toggle="tooltip" title="@Messages("button.edit")" onclick="window.location='@routes.IssueApp.editIssueForm(project.owner, project.name, issue.getNumber)'"><i class="yobicon-edit-2"></i></button>
+                            } else {
+                                <a href="@routes.IssueApp.editIssueForm(project.owner, project.name, issue.getNumber)"><button type="button" class="icon btn-transparent-with-fontsize-lineheight ml10 pt5px" data-toggle="tooltip" title="@Messages("button.show.original")"><i class="yobicon-edit-2"></i></button></a>
+                            }
+                            @if(issue.canBeDeleted) {
+                                @if(isAllowed(UserApp.currentUser(), issue.asResource(), Operation.DELETE)) {
+                                    <a href="#deleteConfirm" data-toggle="modal">
+                                        <button type="button" class="icon btn-transparent-with-fontsize-lineheight ml6" data-toggle='tooltip' title="@Messages("button.delete")"><i class="yobicon-trash"></i></button></a>
+                                }
+                            } else {
+                                <button type="button" class="icon disabled btn-transparent-with-fontsize-lineheight ml6" data-toggle='popover' data-trigger="hover" data-placement="top" data-content="@Messages("issue.can.not.be.deleted")"><i class="yobicon-trash"></i></button>
+                            }
+                        </div>
                         @**<!-- // -->**@
                     </form>
                 </div>
Add a comment
List