end
end
+ # star / unstar the current project
+ def star
+ links = Link.where(tail_uuid: current_user.uuid,
+ head_uuid: @object.uuid,
+ link_class: 'star')
+
+ if params['status'] == 'create'
+ # create 'star' link if one does not already exist
+ if !links.andand.any?
+ dst = Link.new(owner_uuid: current_user.uuid,
+ tail_uuid: current_user.uuid,
+ head_uuid: @object.uuid,
+ link_class: 'star',
+ name: @object.uuid)
+ dst.save!
+ end
+ else # delete any existing 'star' links
+ if links.andand.any?
+ links.each do |link|
+ link.destroy
+ end
+ end
+ end
+
+ respond_to do |format|
+ format.js
+ end
+ end
+
protected
def derive_unique_filename filename, manifest_files
end
end
- def star
- links = Link.where(tail_uuid: current_user.uuid,
- head_uuid: @object.uuid,
- link_class: 'star')
-
- if params['status'] == 'create'
- # create 'star' link if one does not already exist
- if !links.andand.any?
- dst = Link.new(owner_uuid: current_user.uuid,
- tail_uuid: current_user.uuid,
- head_uuid: @object.uuid,
- link_class: 'star',
- name: @object.uuid)
- dst.save!
- end
- else # delete any existing 'star' links
- if links.andand.any?
- links.each do |link|
- link.destroy
- end
- end
- end
-
- show
- end
-
helper_method :is_starred
def is_starred
links = Link.where(tail_uuid: current_user.uuid,
--- /dev/null
+<% if is_starred %>
+ <%= link_to(star_path(status: 'delete', id:@object.uuid, action_method: 'get'), class: "btn btn-xs star-unstar", title: "Remove from list of favorites", remote: true) do %>
+ <i class="fa fa-fw fa-star"></i>
+ <% end %>
+<% else %>
+ <%= link_to(star_path(status: 'create', id:@object.uuid, action_method: 'get'), class: "btn btn-xs star-unstar", title: "Add to list of favorites", remote: true) do %>
+ <i class="fa fa-fw fa-star-o"></i>
+ <% end %>
+<% end %>
--- /dev/null
+$(".star-unstar").html("<%= escape_javascript(render partial: 'show_star') %>");
<% if @object.uuid == current_user.andand.uuid %>
Home
<% else %>
- <% starred = false %>
- <% starred = true if is_starred %>
- <% if starred %>
- <%= link_to(url_for({action: 'star', status: 'delete', id: @object.uuid, controller: 'projects'}), method: :post, class: "btn btn-xs", title: "Remove from list of favorites") do %>
- <i class="fa fa-fw fa-star"></i>
- <% end %>
- <% else %>
- <%= link_to(url_for({action: 'star', status: 'create', id: @object.uuid, controller: 'projects'}), method: :post, class: "btn btn-xs", title: "Add to list of favorites") do %>
- <i class="fa fa-fw fa-star-o"></i>
- <% end %>
- <% end %>
+ <%= render partial: "show_star" %>
<%= render_editable_attribute @object, 'name', nil, { 'data-emptytext' => "New project" } %>
<% end %>
</h2>
get "users/setup" => 'users#setup', :as => :setup_user
get "report_issue_popup" => 'actions#report_issue_popup', :as => :report_issue_popup
post "report_issue" => 'actions#report_issue', :as => :report_issue
+ get "star" => 'actions#star', :as => :star
resources :nodes
resources :humans
resources :traits
post 'share_with', on: :member
get 'tab_counts', on: :member
get 'public', on: :collection
- post 'star', on: :member
end
resources :search do