Commit 4252db4963c60b91db3443a6bd5956b20a7ff514
1 parent
87d91ff8
Exists in
master
and in
8 other branches
Search articles from portal on env link list block
Also fixed visualization on firefox (the trash icon was in the second line) (ActionItem2582)
Showing
3 changed files
with
42 additions
and
4 deletions
Show diff stats
app/controllers/box_organizer_controller.rb
| ... | ... | @@ -83,9 +83,13 @@ class BoxOrganizerController < ApplicationController |
| 83 | 83 | def search_autocomplete |
| 84 | 84 | if request.xhr? and params[:query] |
| 85 | 85 | search = params[:query] |
| 86 | - articles = @profile.articles.find(:all, :conditions=>"name ILIKE '%#{search}%' or path ILIKE '%#{search}%'", :limit=>20) | |
| 87 | - path_list = articles.map { |content| "/{profile}/"+content.path } | |
| 88 | - | |
| 86 | + path_list = if boxes_holder.is_a?(Environment) && boxes_holder.enabled?('use_portal_community') && boxes_holder.portal_community | |
| 87 | + boxes_holder.portal_community.articles.find(:all, :conditions=>"name ILIKE '%#{search}%' or path ILIKE '%#{search}%'", :limit=>20).map { |content| "/{portal}/"+content.path } | |
| 88 | + elsif boxes_holder.is_a?(Profile) | |
| 89 | + boxes_holder.articles.find(:all, :conditions=>"name ILIKE '%#{search}%' or path ILIKE '%#{search}%'", :limit=>20).map { |content| "/{profile}/"+content.path } | |
| 90 | + else | |
| 91 | + [] | |
| 92 | + end | |
| 89 | 93 | render :json => path_list.to_json |
| 90 | 94 | else |
| 91 | 95 | redirect_to "/" | ... | ... |
public/stylesheets/application.css
| ... | ... | @@ -1890,7 +1890,7 @@ a.button.disabled, input.disabled { |
| 1890 | 1890 | margin-bottom: 5px; |
| 1891 | 1891 | padding: 10px 1px 10px 10px; |
| 1892 | 1892 | cursor: pointer; |
| 1893 | - width: 90%; | |
| 1893 | + width: 97%; | |
| 1894 | 1894 | } |
| 1895 | 1895 | .link-list-row:hover { |
| 1896 | 1896 | background: #ddd url(/images/drag-and-drop.png) no-repeat; | ... | ... |
test/functional/environment_design_controller_test.rb
| ... | ... | @@ -379,4 +379,38 @@ class EnvironmentDesignControllerTest < ActionController::TestCase |
| 379 | 379 | end |
| 380 | 380 | end |
| 381 | 381 | |
| 382 | + should 'return a list of paths from portal related to the words used in the query search' do | |
| 383 | + env = Environment.default | |
| 384 | + login_as(create_admin_user(env)) | |
| 385 | + community = fast_create(Community, :environment_id => env) | |
| 386 | + env.portal_community = community | |
| 387 | + env.enable('use_portal_community') | |
| 388 | + env.save | |
| 389 | + @controller.stubs(:boxes_holder).returns(env) | |
| 390 | + article1 = fast_create(Article, :profile_id => community.id, :name => "Some thing") | |
| 391 | + article2 = fast_create(Article, :profile_id => community.id, :name => "Some article") | |
| 392 | + article3 = fast_create(Article, :profile_id => community.id, :name => "Not an article") | |
| 393 | + | |
| 394 | + xhr :get, :search_autocomplete, :query => 'Some' | |
| 395 | + | |
| 396 | + json_response = ActiveSupport::JSON.decode(@response.body) | |
| 397 | + | |
| 398 | + assert_response :success | |
| 399 | + assert_equal json_response.include?("/{portal}/"+article1.path), true | |
| 400 | + assert_equal json_response.include?("/{portal}/"+article2.path), true | |
| 401 | + assert_equal json_response.include?("/{portal}/"+article3.path), false | |
| 402 | + end | |
| 403 | + | |
| 404 | + should 'return empty if portal not configured' do | |
| 405 | + env = Environment.default | |
| 406 | + login_as(create_admin_user(env)) | |
| 407 | + | |
| 408 | + xhr :get, :search_autocomplete, :query => 'Some' | |
| 409 | + | |
| 410 | + json_response = ActiveSupport::JSON.decode(@response.body) | |
| 411 | + | |
| 412 | + assert_response :success | |
| 413 | + assert_equal json_response, [] | |
| 414 | + end | |
| 415 | + | |
| 382 | 416 | end | ... | ... |