fixes #905, as well as fix for pool nav
This commit is contained in:
@@ -21,6 +21,10 @@ class PoolElementsController < ApplicationController
|
|||||||
respond_with(@pool, :location => post_path(@post))
|
respond_with(@pool, :location => post_path(@post))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def all_select
|
||||||
|
@pools = Pool.active.all
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def append_pool_to_session(pool)
|
def append_pool_to_session(pool)
|
||||||
recent_pool_ids = session[:recent_pool_ids].to_s.scan(/\d+/)
|
recent_pool_ids = session[:recent_pool_ids].to_s.scan(/\d+/)
|
||||||
|
|||||||
@@ -106,19 +106,19 @@ class PostPresenter < Presenter
|
|||||||
if template.params[:pool_id].present?
|
if template.params[:pool_id].present?
|
||||||
pool = Pool.where(:id => template.params[:pool_id]).first
|
pool = Pool.where(:id => template.params[:pool_id]).first
|
||||||
return if pool.nil?
|
return if pool.nil?
|
||||||
html = pool_link_html(html, template, pool, :include_rel => true)
|
html += pool_link_html(template, pool, :include_rel => true)
|
||||||
|
|
||||||
@post.pools.active.where("id <> ?", template.params[:pool_id]).each do |other_pool|
|
@post.pools.active.where("id <> ?", template.params[:pool_id]).each do |other_pool|
|
||||||
html = pool_link_html(html, template, other_pool)
|
html += pool_link_html(template, other_pool)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
first = true
|
first = true
|
||||||
@post.pools.active.each do |pool|
|
@post.pools.active.each do |pool|
|
||||||
if first && template.params[:tags].blank?
|
if first && template.params[:tags].blank?
|
||||||
html = pool_link_html(html, template, pool, :include_rel => true)
|
html += pool_link_html(template, pool, :include_rel => true)
|
||||||
first = false
|
first = false
|
||||||
else
|
else
|
||||||
html = pool_link_html(html, template, pool)
|
html += pool_link_html(template, pool)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -127,7 +127,7 @@ class PostPresenter < Presenter
|
|||||||
html.join("\n").html_safe
|
html.join("\n").html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def pool_link_html(html, template, pool, options = {})
|
def pool_link_html(template, pool, options = {})
|
||||||
pool_html = ["<li>"]
|
pool_html = ["<li>"]
|
||||||
match_found = false
|
match_found = false
|
||||||
|
|
||||||
@@ -160,11 +160,6 @@ class PostPresenter < Presenter
|
|||||||
end
|
end
|
||||||
|
|
||||||
pool_html << "</li>"
|
pool_html << "</li>"
|
||||||
|
pool_html
|
||||||
if match_found
|
|
||||||
html += pool_html
|
|
||||||
end
|
|
||||||
|
|
||||||
html
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<label>Pool Name</label>
|
<label>Pool Name</label>
|
||||||
<%= text_field_tag "pool_name", "", :size => 20 %>
|
<span id="pool-name-container"><%= text_field_tag "pool_name", "", :size => 20 %></span>
|
||||||
<span class="hint">Type the first two characters of a pool name</span>
|
<span id="pool-name-hint" class="hint">Search for a pool containing (<%= link_to "see full list", all_select_pool_element_path, :remote => true %>)</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input">
|
<div class="input">
|
||||||
|
|||||||
2
app/views/pool_elements/all_select.js.erb
Normal file
2
app/views/pool_elements/all_select.js.erb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
$("#pool-name-container").html(<%= raw select_tag("pool_id", options_for_select(@pools.map {|x| [x.name, x.id]})).to_json %>);
|
||||||
|
$("#pool-name-hint").hide();
|
||||||
@@ -128,7 +128,11 @@ Danbooru::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
resource :order, :only => [:edit, :update], :controller => "PoolOrders"
|
resource :order, :only => [:edit, :update], :controller => "PoolOrders"
|
||||||
end
|
end
|
||||||
resource :pool_element, :only => [:create, :destroy]
|
resource :pool_element, :only => [:create, :destroy] do
|
||||||
|
collection do
|
||||||
|
get :all_select
|
||||||
|
end
|
||||||
|
end
|
||||||
resources :pool_versions, :only => [:index]
|
resources :pool_versions, :only => [:index]
|
||||||
resources :posts do
|
resources :posts do
|
||||||
resources :votes, :controller => "post_votes", :only => [:create, :destroy]
|
resources :votes, :controller => "post_votes", :only => [:create, :destroy]
|
||||||
|
|||||||
Reference in New Issue
Block a user