Add order page for favgroups

This commit is contained in:
Toks 2015-06-30 10:02:07 -04:00
parent bb879cc4fd
commit 799b9ebe19
6 changed files with 42 additions and 4 deletions

View File

@ -12,7 +12,7 @@
this.initialize_add_to_pool_link();
}
if ($("#c-pool-orders").length) {
if ($("#c-pool-orders,#c-favorite-group-orders").length) {
this.initialize_simple_edit();
}
}

View File

@ -53,7 +53,7 @@ div#c-pools {
}
}
div#c-pool-orders {
div#c-pool-orders, div#c-favorite-group-orders {
h1 {
font-size: $h2_size;
}

View File

@ -0,0 +1,9 @@
class FavoriteGroupOrdersController < ApplicationController
respond_to :html, :xml, :json, :js
before_filter :member_only
def edit
@favorite_group = FavoriteGroup.find(params[:favorite_group_id])
respond_with(@favorite_group)
end
end

View File

@ -0,0 +1,24 @@
<div id="c-favorite-group-orders">
<div id="a-edit">
<h1>Order Favorite Group: <%= @favorite_group.pretty_name %></h1>
<p>Drag and drop the list below to determine ordering.</p>
<ul id="sortable">
<% @favorite_group.posts(:limit => 1_000).each do |post| %>
<li class="ui-state-default" id="favorite_group[post_id_array]_<%= post.id %>">
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>
</li>
<% end %>
</ul>
<%= simple_form_for(@favorite_group, :format => :js, :html => {:id => "ordering-form"}) do |f| %>
<%= submit_tag "Save" %>
<% end %>
</div>
</div>
<%= render "favorite_groups/secondary_links" %>
<% content_for(:page_title) do %>
Order Favorite Group - <%= Danbooru.config.app_name %>
<% end %>

View File

@ -13,6 +13,9 @@
<% if @favorite_group.editable_by?(CurrentUser.user) %>
<li><%= link_to "Edit", edit_favorite_group_path(@favorite_group) %></li>
<li><%= link_to "Delete", favorite_group_path(@favorite_group), :method => :delete, :data => {:confirm => "Are you sure you want to delete this favorite group?"} %></li>
<% if @favorite_group.post_count <= 100 %>
<li><%= link_to "Order", edit_favorite_group_order_path(@favorite_group) %></li>
<% end %>
<% end %>
<% end %>
</menu>

View File

@ -109,7 +109,9 @@ Rails.application.routes.draw do
end
resource :dtext_preview, :only => [:create]
resources :favorites
resources :favorite_groups
resources :favorite_groups do
resource :order, :only => [:edit], :controller => "favorite_group_orders"
end
resources :forum_posts do
member do
post :undelete
@ -164,7 +166,7 @@ Rails.application.routes.draw do
collection do
get :gallery
end
resource :order, :only => [:edit, :update], :controller => "pool_orders"
resource :order, :only => [:edit], :controller => "pool_orders"
end
resource :pool_element, :only => [:create, :destroy] do
collection do