fix for pool selection
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
$.getJSON(
|
$.getJSON(
|
||||||
"/pools.json?search[name_matches]=" + req.term,
|
"/pools.json?search[name_matches]=" + req.term,
|
||||||
function(data) {
|
function(data) {
|
||||||
resp(data.map(function(x) {return x.name;}));
|
resp(data.map(function(x) {return x.name.replace(/_/g, " ");}));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class PoolsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@search = Pool.active.search(params[:search])
|
@search = Pool.active.search(params[:search])
|
||||||
@pools = @search.paginate(params[:page]).order("name")
|
@pools = @search.paginate(params[:page]).order("updated_at desc")
|
||||||
respond_with(@pools)
|
respond_with(@pools)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class Pool < ActiveRecord::Base
|
|||||||
return q if params.blank?
|
return q if params.blank?
|
||||||
|
|
||||||
if params[:name_matches].present?
|
if params[:name_matches].present?
|
||||||
|
params[:name_matches] = params[:name_matches].tr(" ", "_")
|
||||||
params[:name_matches] += "*" unless params[:name_matches] =~ /\*/
|
params[:name_matches] += "*" unless params[:name_matches] =~ /\*/
|
||||||
q = q.where("name ilike ? escape E'\\\\'", params[:name_matches].to_escaped_for_sql_like)
|
q = q.where("name ilike ? escape E'\\\\'", params[:name_matches].to_escaped_for_sql_like)
|
||||||
end
|
end
|
||||||
@@ -66,7 +67,7 @@ class Pool < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.options
|
def self.options
|
||||||
select_all_sql("SELECT id, name FROM pools WHERE is_active = true AND is_deleted = false ORDER BY name LIMIT 100").map {|x| [x["name"], x["id"]]}
|
select_all_sql("SELECT id, name FROM pools WHERE is_active = true AND is_deleted = false ORDER BY name LIMIT 100").map {|x| [x["name"].tr("_", " "), x["id"]]}
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_anonymous
|
def self.create_anonymous
|
||||||
|
|||||||
@@ -402,10 +402,10 @@ class Tag < ActiveRecord::Base
|
|||||||
|
|
||||||
case params[:sort].present?
|
case params[:sort].present?
|
||||||
when "count"
|
when "count"
|
||||||
q = q.order("post_count")
|
q = q.order("post_count desc")
|
||||||
|
|
||||||
when "date"
|
when "date"
|
||||||
q = q.order("created_at")
|
q = q.order("created_at desc")
|
||||||
|
|
||||||
else
|
else
|
||||||
q = q.order("name")
|
q = q.order("name")
|
||||||
|
|||||||
@@ -3,11 +3,6 @@
|
|||||||
<%= form_tag(pool_element_path, :class => "simple_form") do %>
|
<%= form_tag(pool_element_path, :class => "simple_form") do %>
|
||||||
<%= hidden_field_tag "post_id", @post.id %>
|
<%= hidden_field_tag "post_id", @post.id %>
|
||||||
|
|
||||||
<div class="input">
|
|
||||||
<label>Pool</label>
|
|
||||||
<%= select_tag "pool_id", options_for_select([["", ""]] + Pool.options) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<label>Pool Name</label>
|
<label>Pool Name</label>
|
||||||
<%= text_field_tag "pool_name", "", :size => 20 %>
|
<%= text_field_tag "pool_name", "", :size => 20 %>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to h(pool.name), pool_path(pool) %>
|
<%= link_to h(pool.pretty_name), pool_path(pool) %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to h(pool.creator.name), user_path(pool.creator) %>
|
<%= link_to h(pool.creator.name), user_path(pool.creator) %>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div id="c-pools">
|
<div id="c-pools">
|
||||||
<div id="a-show">
|
<div id="a-show">
|
||||||
<h1>Pool: <%= @pool.name %></h1>
|
<h1>Pool: <%= @pool.pretty_name %></h1>
|
||||||
|
|
||||||
<div id="description">
|
<div id="description">
|
||||||
<%= format_text(@pool.description) %>
|
<%= format_text(@pool.description) %>
|
||||||
|
|||||||
Reference in New Issue
Block a user