favgroups: add create new option to add to favgroup dialog.
Add option to create a new favgroup when the user opens the Add to Favgroup dialog and they don't have any favgroups yet.
This commit is contained in:
@@ -21,15 +21,7 @@ class FavoriteGroupsController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@favorite_group = FavoriteGroup.create(favgroup_params)
|
@favorite_group = FavoriteGroup.create(favgroup_params)
|
||||||
respond_with(@favorite_group) do |format|
|
respond_with(@favorite_group)
|
||||||
format.html do
|
|
||||||
if @favorite_group.errors.any?
|
|
||||||
render :action => "new"
|
|
||||||
else
|
|
||||||
redirect_to favorite_groups_path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
|||||||
@@ -1,12 +1,22 @@
|
|||||||
<p>Select a favorite group to add this post to:</p>
|
<% if CurrentUser.favorite_groups.empty? %>
|
||||||
|
<p>Add this post to a new a favorite group (<%= link_to_wiki "help:favorite_groups" %>):</p>
|
||||||
|
|
||||||
<% CurrentUser.favorite_groups.each_with_index do |favgroup, i| %>
|
<%= edit_form_for(FavoriteGroup.new, html: { class: "one-line-form" }) do |f| %>
|
||||||
<div>
|
<%= f.input :name, as: :string, required: true, input_html: { style: "width: 20em" } %>
|
||||||
<%= i + 1 %>.
|
<%= f.input :post_ids, as: :hidden, input_html: { value: post.id } %>
|
||||||
<%= link_to favgroup.name,
|
<%= f.submit "Create" %>
|
||||||
add_post_favorite_group_path(favgroup, :post_id => post.id, :format => :js),
|
<% end %>
|
||||||
:id => "add-to-favgroup-#{i + 1}", :class => "add-to-favgroup",
|
<% else %>
|
||||||
:method => :put, :remote => true,
|
<p>Select a favorite group to add this post to (<%= link_to_wiki "help:favorite_groups" %>):</p>
|
||||||
:"data-shortcut" => (i + 1) % 10, :"data-shortcut-when" => ":visible" %>
|
|
||||||
</div>
|
<% CurrentUser.favorite_groups.each_with_index do |favgroup, i| %>
|
||||||
|
<div>
|
||||||
|
<%= i + 1 %>.
|
||||||
|
<%= link_to favgroup.name,
|
||||||
|
add_post_favorite_group_path(favgroup, post_id: post.id, format: :js),
|
||||||
|
id: "add-to-favgroup-#{i + 1}", class: "add-to-favgroup", method: :put,
|
||||||
|
remote: true, "data-shortcut": (i + 1) % 10, "data-shortcut-when": ":visible"
|
||||||
|
%>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
1
app/views/favorite_groups/create.js.erb
Normal file
1
app/views/favorite_groups/create.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
location.reload();
|
||||||
Reference in New Issue
Block a user