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))
|
||||
end
|
||||
|
||||
def all_select
|
||||
@pools = Pool.active.all
|
||||
end
|
||||
|
||||
private
|
||||
def append_pool_to_session(pool)
|
||||
recent_pool_ids = session[:recent_pool_ids].to_s.scan(/\d+/)
|
||||
|
||||
@@ -106,19 +106,19 @@ class PostPresenter < Presenter
|
||||
if template.params[:pool_id].present?
|
||||
pool = Pool.where(:id => template.params[:pool_id]).first
|
||||
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|
|
||||
html = pool_link_html(html, template, other_pool)
|
||||
html += pool_link_html(template, other_pool)
|
||||
end
|
||||
else
|
||||
first = true
|
||||
@post.pools.active.each do |pool|
|
||||
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
|
||||
else
|
||||
html = pool_link_html(html, template, pool)
|
||||
html += pool_link_html(template, pool)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -127,7 +127,7 @@ class PostPresenter < Presenter
|
||||
html.join("\n").html_safe
|
||||
end
|
||||
|
||||
def pool_link_html(html, template, pool, options = {})
|
||||
def pool_link_html(template, pool, options = {})
|
||||
pool_html = ["<li>"]
|
||||
match_found = false
|
||||
|
||||
@@ -160,11 +160,6 @@ class PostPresenter < Presenter
|
||||
end
|
||||
|
||||
pool_html << "</li>"
|
||||
|
||||
if match_found
|
||||
html += pool_html
|
||||
end
|
||||
|
||||
html
|
||||
pool_html
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
<div class="input">
|
||||
<label>Pool Name</label>
|
||||
<%= text_field_tag "pool_name", "", :size => 20 %>
|
||||
<span class="hint">Type the first two characters of a pool name</span>
|
||||
<span id="pool-name-container"><%= text_field_tag "pool_name", "", :size => 20 %></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 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
|
||||
resource :order, :only => [:edit, :update], :controller => "PoolOrders"
|
||||
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 :posts do
|
||||
resources :votes, :controller => "post_votes", :only => [:create, :destroy]
|
||||
|
||||
Reference in New Issue
Block a user