mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-29 13:28:49 +01:00
Autocompletion for predecessors working
This commit is contained in:
parent
d0a5f6b731
commit
71b0e188c1
5 changed files with 7 additions and 15 deletions
|
|
@ -620,7 +620,7 @@ class TodosController < ApplicationController
|
|||
:conditions => [ '(todos.state = ? OR todos.state = ?) AND ' +
|
||||
'NOT (id = ?) AND lower(description) LIKE ?',
|
||||
'active', 'pending',
|
||||
params[:id], '%' + params[:predecessor_list].downcase + '%' ],
|
||||
params[:id], '%' + params[:q].downcase + '%' ],
|
||||
:order => 'description ASC',
|
||||
:limit => 10
|
||||
)
|
||||
|
|
@ -631,7 +631,7 @@ class TodosController < ApplicationController
|
|||
:select => 'description, project_id, context_id, created_at',
|
||||
:conditions => [ '(todos.state = ? OR todos.state = ?) AND lower(description) LIKE ?',
|
||||
'active', 'pending',
|
||||
'%' + params[:predecessor_list].downcase + '%' ],
|
||||
'%' + params[:q].downcase + '%' ],
|
||||
:order => 'description ASC',
|
||||
:limit => 10
|
||||
)
|
||||
|
|
|
|||
|
|
@ -313,12 +313,7 @@ module TodosHelper
|
|||
end
|
||||
|
||||
def auto_complete_result2(entries, phrase = nil)
|
||||
return unless entries
|
||||
items = entries.map do |entry|
|
||||
item = entry.specification()
|
||||
content_tag("li", phrase ? highlight(h(item), phrase) : h(item))
|
||||
end
|
||||
content_tag("ul", items.uniq)
|
||||
return entries.map{|e| e.specification()}.join("\n") rescue ''
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -53,12 +53,6 @@
|
|||
|
||||
<label for="predecessor_list">Depends on</label>
|
||||
<%= text_field_tag "predecessor_list", nil, :size => 30, :tabindex => 8 %>
|
||||
<%= content_tag("div", "", :id => "predecessor_list_auto_complete", :class => "auto_complete") %>
|
||||
<%= auto_complete_field 'predecessor_list', {
|
||||
:url => {:controller => 'todos', :action => 'auto_complete_for_predecessor', :id => nil},
|
||||
:tokens => [',']
|
||||
} %>
|
||||
|
||||
<%= source_view_tag( @source_view ) %>
|
||||
<%= hidden_field_tag :_tag_name, @tag_name.underscore.gsub(/\s+/,'_') if source_view_is :tag %>
|
||||
|
||||
|
|
|
|||
|
|
@ -191,6 +191,8 @@ function enable_rich_interaction(){
|
|||
$('input[name=project[default_context_name]]').autocomplete(contextNames, {matchContains: true});
|
||||
$('input[name=project_name]').autocomplete(projectNames, {matchContains: true});
|
||||
$('input[name=tag_list]').autocomplete(tagNames, {multiple: true,multipleSeparator:',',matchContains:true});
|
||||
$('input[name=predecessor_list]').autocomplete('/todos/auto_complete_for_predecessor',
|
||||
{multiple: true,multipleSeparator:','});
|
||||
|
||||
/* have to bind on keypress because of limitataions of live() */
|
||||
$('input[name=project_name]').live('keypress', function(){
|
||||
|
|
|
|||
|
|
@ -364,6 +364,7 @@ $.Autocompleter = function(input, options) {
|
|||
// limit abortion to this input
|
||||
port: "autocomplete" + input.name,
|
||||
dataType: options.dataType,
|
||||
type: 'POST',
|
||||
url: options.url,
|
||||
data: $.extend({
|
||||
q: lastWord(term),
|
||||
|
|
@ -805,4 +806,4 @@ $.fn.selection = function(start, end) {
|
|||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue