Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proof of concept of combining query string with hash-prefixed tags
- Loading branch information
Mike Dvorkin
committed
Sep 23, 2009
1 parent
9a480a8
commit 009bc46
Showing
2 changed files
with
29 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
module CrmTags | ||
module Helper | ||
module Helpers | ||
|
||
#---------------------------------------------------------------------------- | ||
def tag_links(model) | ||
model.tag_list.inject([]) do |arr, tag| | ||
# arr << link_to(tag, url_for(:action => "index", :tag => tag), :title => tag) | ||
arr << link_to_function(tag, "$('query').value += ($('query').value.length > 0 ? ' ##{tag}' : '##{tag}'); crm.search('##{tag}', '#{model.class.to_s.tableize}')", :title => tag) | ||
query = controller.send(:current_query) || "" | ||
hashtag = "##{tag}" | ||
query += (query.empty? ? hashtag : " #{hashtag}") | ||
arr << link_to_function(hashtag, "$('query').value = '#{query}'; crm.search('#{query}', '#{model.class.to_s.tableize}')", :title => tag) | ||
end.join(", ") | ||
end | ||
|
||
end | ||
end | ||
|
||
ActionView::Base.send(:include, CrmTags::Helper) | ||
ActionView::Base.send(:include, CrmTags::Helpers) |