mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
make search and feedlist pass
This commit is contained in:
parent
28b7df87a8
commit
7c935652fb
10 changed files with 40 additions and 19 deletions
|
|
@ -1160,7 +1160,7 @@ $.fn.clearDeps = function() {
|
||||||
/**************************************/
|
/**************************************/
|
||||||
|
|
||||||
function generic_get_script_for_list(element, getter, param){
|
function generic_get_script_for_list(element, getter, param){
|
||||||
$(element).load(relative_to_root(getter+'?'+param));
|
$(element).load(relative_to_root(getter+'.js?'+param));
|
||||||
}
|
}
|
||||||
|
|
||||||
function default_ajax_options_for_submit(ajax_type, element_to_block) {
|
function default_ajax_options_for_submit(ajax_type, element_to_block) {
|
||||||
|
|
|
||||||
|
|
@ -5,23 +5,25 @@ class SearchController < ApplicationController
|
||||||
def results
|
def results
|
||||||
@source_view = params['_source_view'] || 'search'
|
@source_view = params['_source_view'] || 'search'
|
||||||
@page_title = "TRACKS::Search Results for #{params[:search]}"
|
@page_title = "TRACKS::Search Results for #{params[:search]}"
|
||||||
terms = '%' + params[:search] + '%'
|
terms = "%#{params[:search]}%"
|
||||||
|
|
||||||
@found_not_complete_todos = current_user.todos.
|
@found_not_complete_todos = current_user.todos.
|
||||||
where("(todos.description LIKE ? OR todos.notes LIKE ?) AND todos.completed_at IS NULL", terms, terms).
|
where("(todos.description LIKE ? OR todos.notes LIKE ?) AND todos.completed_at IS NULL", terms, terms).
|
||||||
includes(Todo::DEFAULT_INCLUDES).
|
includes(Todo::DEFAULT_INCLUDES).
|
||||||
reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC")
|
reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC").
|
||||||
|
all
|
||||||
|
|
||||||
@found_complete_todos = current_user.todos.
|
@found_complete_todos = current_user.todos.
|
||||||
where("(todos.description LIKE ? OR todos.notes LIKE ?) AND NOT (todos.completed_at IS NULL)", terms, terms).
|
where("(todos.description LIKE ? OR todos.notes LIKE ?) AND NOT (todos.completed_at IS NULL)", terms, terms).
|
||||||
includes(Todo::DEFAULT_INCLUDES).
|
includes(Todo::DEFAULT_INCLUDES).
|
||||||
reorder("todos.completed_at DESC")
|
reorder("todos.completed_at DESC").
|
||||||
|
all
|
||||||
|
|
||||||
@found_todos = @found_not_complete_todos + @found_complete_todos
|
@found_todos = @found_not_complete_todos + @found_complete_todos
|
||||||
|
|
||||||
@found_projects = current_user.projects.where("name LIKE ? OR description LIKE ?", terms, terms)
|
@found_projects = current_user.projects.where("name LIKE ? OR description LIKE ?", terms, terms).all
|
||||||
@found_notes = current_user.notes.where("body LIKE ?", terms)
|
@found_notes = current_user.notes.where("body LIKE ?", terms).all
|
||||||
@found_contexts = current_user.contexts.where("name LIKE ?", terms)
|
@found_contexts = current_user.contexts.where("name LIKE ?", terms).all
|
||||||
|
|
||||||
# TODO: limit search to tags on todos
|
# TODO: limit search to tags on todos
|
||||||
@found_tags = Tagging.find_by_sql([
|
@found_tags = Tagging.find_by_sql([
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,12 @@ module FeedlistHelper
|
||||||
|
|
||||||
def text_formatted_link(options = {})
|
def text_formatted_link(options = {})
|
||||||
linkoptions = merge_hashes( {:format => 'txt'}, user_token_hash, options)
|
linkoptions = merge_hashes( {:format => 'txt'}, user_token_hash, options)
|
||||||
link_to('<span class="feed">TXT</span>', linkoptions, :title => "Plain text feed" )
|
link_to(content_tag(:span, 'TXT', {:class => 'feed', :title => "Plain text feed"}, linkoptions))
|
||||||
end
|
end
|
||||||
|
|
||||||
def ical_formatted_link(options = {})
|
def ical_formatted_link(options = {})
|
||||||
linkoptions = merge_hashes( {:format => 'ics'}, user_token_hash, options)
|
linkoptions = merge_hashes( {:format => 'ics'}, user_token_hash, options)
|
||||||
link_to('<span class="feed">iCal</span>', linkoptions, :title => "iCal feed" )
|
link_to(content_tag(:span, 'iCal', {:class=>"feed", :title => "iCal feed"}, linkoptions))
|
||||||
end
|
end
|
||||||
|
|
||||||
def feed_links(feeds, link_options, title)
|
def feed_links(feeds, link_options, title)
|
||||||
|
|
@ -23,7 +23,7 @@ module FeedlistHelper
|
||||||
html << text_formatted_link(link_options)+space if feeds.include?(:txt)
|
html << text_formatted_link(link_options)+space if feeds.include?(:txt)
|
||||||
html << ical_formatted_link(link_options)+space if feeds.include?(:ical)
|
html << ical_formatted_link(link_options)+space if feeds.include?(:ical)
|
||||||
html << title
|
html << title
|
||||||
return html
|
return html.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_feed_links_for_project(project)
|
def all_feed_links_for_project(project)
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,10 @@ class Todo < ActiveRecord::Base
|
||||||
scope :with_tag, lambda { |tag_id| joins("INNER JOIN taggings ON todos.id = taggings.taggable_id").where("taggings.tag_id = ? ", tag_id) }
|
scope :with_tag, lambda { |tag_id| joins("INNER JOIN taggings ON todos.id = taggings.taggable_id").where("taggings.tag_id = ? ", tag_id) }
|
||||||
scope :with_tags, lambda { |tag_ids| where("EXISTS(SELECT * from taggings t WHERE t.tag_id IN (?) AND t.taggable_id=todos.id AND t.taggable_type='Todo')", tag_ids) }
|
scope :with_tags, lambda { |tag_ids| where("EXISTS(SELECT * from taggings t WHERE t.tag_id IN (?) AND t.taggable_id=todos.id AND t.taggable_type='Todo')", tag_ids) }
|
||||||
# scope :of_user, lambda { |user_id| {:conditions => ["todos.user_id = ? ", user_id] } }
|
# scope :of_user, lambda { |user_id| {:conditions => ["todos.user_id = ? ", user_id] } }
|
||||||
# scope :completed_after, lambda { |date| {:conditions => ["todos.completed_at > ?", date] } }
|
scope :completed_after, lambda { |date| where("todos.completed_at > ?", date) }
|
||||||
# scope :completed_before, lambda { |date| {:conditions => ["todos.completed_at < ?", date] } }
|
scope :completed_before, lambda { |date| where("todos.completed_at < ?", date) }
|
||||||
# scope :created_after, lambda { |date| {:conditions => ["todos.created_at > ?", date] } }
|
scope :created_after, lambda { |date| where("todos.created_at > ?", date) }
|
||||||
# scope :created_before, lambda { |date| {:conditions => ["todos.created_at < ?", date] } }
|
scope :created_before, lambda { |date| where("todos.created_at < ?", date) }
|
||||||
|
|
||||||
STARRED_TAG_NAME = "starred"
|
STARRED_TAG_NAME = "starred"
|
||||||
DEFAULT_INCLUDES = [ :project, :context, :tags, :taggings, :pending_successors, :uncompleted_predecessors, :recurring_todo ]
|
DEFAULT_INCLUDES = [ :project, :context, :tags, :taggings, :pending_successors, :uncompleted_predecessors, :recurring_todo ]
|
||||||
|
|
|
||||||
|
|
@ -68,14 +68,14 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li><%= navigation_link( t('layouts.navigation.calendar'), calendar_path, :title => t('layouts.navigation.calendar_title')) %></li>
|
<li><%= navigation_link( t('layouts.navigation.calendar'), calendar_path, :title => t('layouts.navigation.calendar_title')) %></li>
|
||||||
<li><%= navigation_link( t('layouts.navigation.completed_tasks'), done_overview_path, {:accesskey=>"d", :title=>t('layouts.navigation.completed_tasks_title')} ) %></li>
|
<li><%= navigation_link( t('layouts.navigation.completed_tasks'), done_overview_path, {:accesskey=>"d", :title=>t('layouts.navigation.completed_tasks_title')} ) %></li>
|
||||||
<li><%= navigation_link( t('layouts.navigation.feeds'), {:controller => "feedlist", :action => "index"}, :title => t('layouts.navigation.feeds_title')) %></li>
|
<li><%= navigation_link( t('layouts.navigation.feeds'), feeds_path, :title => t('layouts.navigation.feeds_title')) %></li>
|
||||||
<li><%= navigation_link( t('layouts.navigation.stats'), {:controller => "stats", :action => "index"}, :title => t('layouts.navigation.stats_title')) %></li>
|
<li><%= navigation_link( t('layouts.navigation.stats'), stats_path, :title => t('layouts.navigation.stats_title')) %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#"><%= t('layouts.navigation.admin') %></a>
|
<li><a href="#"><%= t('layouts.navigation.admin') %></a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><%= navigation_link( t('layouts.navigation.preferences'), preferences_path, {:accesskey => "u", :title => t('layouts.navigation.preferences_title')} ) %></li>
|
<li><%= navigation_link( t('layouts.navigation.preferences'), preferences_path, {:accesskey => "u", :title => t('layouts.navigation.preferences_title')} ) %></li>
|
||||||
<li><%= navigation_link( t('layouts.navigation.export'), {:controller => "data", :action => "index"}, {:accesskey => "i", :title => t('layouts.navigation.export_title')} ) %></li>
|
<li><%= navigation_link( t('layouts.navigation.export'), data_path, {:accesskey => "i", :title => t('layouts.navigation.export_title')} ) %></li>
|
||||||
<% if current_user.is_admin? -%>
|
<% if current_user.is_admin? -%>
|
||||||
<li><%= navigation_link(t('layouts.navigation.manage_users'), users_path, {:accesskey => "a", :title => t('layouts.navigation.manage_users_title')} ) %></li>
|
<li><%= navigation_link(t('layouts.navigation.manage_users'), users_path, {:accesskey => "a", :title => t('layouts.navigation.manage_users_title')} ) %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
@ -87,7 +87,7 @@
|
||||||
<li><%= link_to t('layouts.navigation.api_docs'), rest_api_docs_path %></li>
|
<li><%= link_to t('layouts.navigation.api_docs'), rest_api_docs_path %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><%= navigation_link(image_tag("system-search.png", :size => "16X16", :border => 0), {:controller => "search", :action => "index"}, :title => t('layouts.navigation.search')) %></li>
|
<li><%= navigation_link(image_tag("system-search.png", :size => "16X16", :border => 0), search_path, :title => t('layouts.navigation.search')) %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<%= render_flash %>
|
<%= render_flash %>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<div id="display_box_search">
|
<div id="display_box_search">
|
||||||
<%= form_tag({:action => :results}, :id => 'search-form') do %>
|
<%= form_tag(search_results_path, :id => 'search-form') do %>
|
||||||
<%= text_field_tag(:search, params[:search]) %>
|
<%= text_field_tag(:search, params[:search]) %>
|
||||||
<%= submit_tag t('common.search') %>
|
<%= submit_tag t('common.search') %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
@ -72,6 +72,10 @@ Tracksapp::Application.routes.draw do
|
||||||
match 'integrations/google_gadget.xml' => 'integrations#google_gadget', :as => 'google_gadget'
|
match 'integrations/google_gadget.xml' => 'integrations#google_gadget', :as => 'google_gadget'
|
||||||
match 'preferences' => "preferences#index"
|
match 'preferences' => "preferences#index"
|
||||||
match 'preferences/render_date_format' => "preferences#render_date_format"
|
match 'preferences/render_date_format' => "preferences#render_date_format"
|
||||||
|
match 'feeds' => "feedlist#index", :as => 'feeds'
|
||||||
|
match 'feedlist/get_feeds_for_context' => 'feedlist#get_feeds_for_context'
|
||||||
|
match 'feedlist/get_feeds_for_project' => 'feedlist#get_feeds_for_project'
|
||||||
|
match 'data' => "data#index"
|
||||||
|
|
||||||
resources :contexts do
|
resources :contexts do
|
||||||
member do
|
member do
|
||||||
|
|
@ -144,6 +148,9 @@ Tracksapp::Application.routes.draw do
|
||||||
|
|
||||||
resources :notes
|
resources :notes
|
||||||
|
|
||||||
|
match 'search' => 'search#index'
|
||||||
|
match 'search/results' => 'search#results', :via => 'post'
|
||||||
|
|
||||||
# map.resources :users,
|
# map.resources :users,
|
||||||
# :member => {:change_password => :get, :update_password => :post,
|
# :member => {:change_password => :get, :update_password => :post,
|
||||||
# :change_auth_type => :get, :update_auth_type => :post, :complete => :get,
|
# :change_auth_type => :get, :update_auth_type => :post, :complete => :get,
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,17 @@ class FeedlistControllerTest < ActionController::TestCase
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal "TRACKS::Feeds", assigns['page_title']
|
assert_equal "TRACKS::Feeds", assigns['page_title']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_get_feeds_for_context_using_xhr
|
||||||
|
login_as(:admin_user)
|
||||||
|
xhr :get, :get_feeds_for_context, :context_id => contexts(:errand).id
|
||||||
|
assert_response 200
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_feeds_for_project_using_xhr
|
||||||
|
login_as(:admin_user)
|
||||||
|
xhr :get, :get_feeds_for_project, :project_id => projects(:timemachine).id
|
||||||
|
assert_response 200
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue