improvements to pool add
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
minLength: 4,
|
minLength: 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#pool").click(function(e) {
|
$("#pool").click(function(e) {
|
||||||
|
|||||||
@@ -5,14 +5,12 @@ class PoolElementsController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@pool = Pool.find_by_name(params[:pool_name]) || Pool.find_by_id(params[:pool_id])
|
@pool = Pool.find_by_name(params[:pool_name]) || Pool.find_by_id(params[:pool_id])
|
||||||
|
|
||||||
if @pool.nil?
|
if @pool.present?
|
||||||
|
@post = Post.find(params[:post_id])
|
||||||
return
|
@pool.add!(@post)
|
||||||
|
append_pool_to_session(@pool)
|
||||||
end
|
end
|
||||||
|
|
||||||
@post = Post.find(params[:post_id])
|
|
||||||
@pool.add!(@post)
|
|
||||||
append_pool_to_session(@pool)
|
|
||||||
respond_with(@pool, :location => post_path(@post))
|
respond_with(@pool, :location => post_path(@post))
|
||||||
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] += "*" unless params[:name_matches] =~ /\*/
|
||||||
q = q.where("name like ? escape E'\\\\'", params[:name_matches].to_escaped_for_sql_like)
|
q = q.where("name like ? escape E'\\\\'", params[:name_matches].to_escaped_for_sql_like)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -64,6 +65,10 @@ class Pool < ActiveRecord::Base
|
|||||||
select_value_sql("SELECT name FROM pools WHERE id = ?", id)
|
select_value_sql("SELECT name FROM pools WHERE id = ?", id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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"]]}
|
||||||
|
end
|
||||||
|
|
||||||
def self.create_anonymous
|
def self.create_anonymous
|
||||||
Pool.new do |pool|
|
Pool.new do |pool|
|
||||||
pool.name = "TEMP:#{Time.now.to_f}.#{rand(1_000_000)}"
|
pool.name = "TEMP:#{Time.now.to_f}.#{rand(1_000_000)}"
|
||||||
|
|||||||
@@ -1,9 +1,22 @@
|
|||||||
<div id="c-pool-elements">
|
<div id="c-pool-elements">
|
||||||
<div id="a-new">
|
<div id="a-new">
|
||||||
<%= form_tag(pool_element_path) do %>
|
<%= form_tag(pool_element_path, :class => "simple_form") do %>
|
||||||
<%= hidden_field_tag "post_id", @post.id %>
|
<%= hidden_field_tag "post_id", @post.id %>
|
||||||
<%= text_field_tag "pool_name", "", :size => 20 %>
|
|
||||||
<%= submit_tag "Select" %>
|
<div class="input">
|
||||||
|
<label>Pool</label>
|
||||||
|
<%= select_tag "pool_id", options_for_select([["", ""]] + Pool.options) %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input">
|
||||||
|
<%= submit_tag "Select" %>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if recent_updated_pools.any? %>
|
<% if recent_updated_pools.any? %>
|
||||||
|
|||||||
Reference in New Issue
Block a user