doortts doortts 2018-01-03
project: Add starred project feature at project breadcromb
@d827f72d96cb57b2a5ec80250fb025117fcc5049
app/assets/stylesheets/less/_common.less
--- app/assets/stylesheets/less/_common.less
+++ app/assets/stylesheets/less/_common.less
@@ -277,3 +277,7 @@
 input.white:-moz-placeholder             { color:#fff; opacity:0.8; } /* Firefox 18- */
 input.white::-moz-placeholder            { color:#fff; opacity:0.8; } /* Firefox 19+ */
 input.white:-ms-input-placeholder        { color:#fff; opacity:0.8; }
+
+.va-text-top {
+    vertical-align: text-top !important;
+}
app/assets/stylesheets/less/_page.less
--- app/assets/stylesheets/less/_page.less
+++ app/assets/stylesheets/less/_page.less
@@ -419,6 +419,19 @@
                         font-size: 14px;
                         margin-left:5px;
                     }
+
+                    .user-project-list {
+                        .star {
+                            color: rgba(255, 255, 255, 0.22);
+                            &:hover {
+                                color: #e91e63;
+                                cursor: pointer;
+                            }
+                        }
+                        .starred {
+                            color: #e91e63 !important;
+                        }
+                    }
                 }
 
                 .project-origin {
app/models/FavoriteProject.java
--- app/models/FavoriteProject.java
+++ app/models/FavoriteProject.java
@@ -49,4 +49,11 @@
             favoriteProject.update();
         }
     }
+
+    public static FavoriteProject findByProjectId(Long userId, Long projectId){
+        return finder.where()
+                .eq("user.id", userId)
+                .eq("project.id", projectId)
+                .findUnique();
+    }
 }
app/views/project/header.scala.html
--- app/views/project/header.scala.html
+++ app/views/project/header.scala.html
@@ -45,6 +45,10 @@
     }
 }
 
+@isFavoriteProject = @{
+    FavoriteProject.findByProjectId(UserApp.currentUser().id, project.id) != null
+}
+
 <div class="project-header-outer" style="background-image:url(@urlToProjectBG(project))">
     <div class="project-header-inner">
         <div class="project-header-wrap">
@@ -56,6 +60,9 @@
                     <span class="project-author hide-in-mobile"><a href="@routes.UserApp.userInfo(project.owner)">@project.owner</a></span>
                     <span class="project-separator hide-in-mobile">/</span>
                     <span class="project-name"><a href="@routes.ProjectApp.project(project.owner, project.name)">@project.name</a></span>
+                    <span class="user-project-list" data-project-id="@project.id">
+                        <i class="@if(isFavoriteProject){starred} star material-icons va-text-top">star</i>
+                    </span>
                     @if(project.isPrivate){
                     <span class="project-private">
                         <i class="yobicon-lock"></i>
public/javascripts/common/yona.Usermenu.js
--- public/javascripts/common/yona.Usermenu.js
+++ public/javascripts/common/yona.Usermenu.js
@@ -107,7 +107,7 @@
             }
         });
 
-        $(".project-list > .star-project").on("click", function toggleProjectFavorite(e) {
+        $(".project-list > .star-project, .project-breadcrumb > .user-project-list").on("click", function toggleProjectFavorite(e) {
             e.stopPropagation();
             var that = $(this);
           $.post(UsermenuToggleFavoriteProjectUrl + that.data("projectId"))
Add a comment
List