Revision 1244:a3ed5c4d90f0 plugins/redmine_tags
| plugins/redmine_tags/app/views/projects/_tags_form.html.erb | ||
|---|---|---|
| 5 | 5 |
<em class="info"><%= l(:text_tags_info).html_safe %></em> |
| 6 | 6 |
</p> |
| 7 | 7 |
<div id="project_tag_candidates" class="autocomplete"></div> |
| 8 |
<%= javascript_include_tag 'tags_input', :plugin => 'redmine_tags' %> |
|
| 9 |
<%= javascript_tag "observeProjectTagsField('#{url_for(:controller => 'auto_completes', :action => 'project_tags')}', false)" %>
|
|
| 8 |
<%= stylesheet_link_tag 'jquery.tagit.css', :plugin => 'redmine_tags' %> |
|
| 9 |
<%= stylesheet_link_tag 'redmine_tags', :plugin => 'redmine_tags' %> |
|
| 10 |
<%= javascript_include_tag 'tag-it', :plugin => 'redmine_tags' %> |
|
| 11 |
|
|
| 12 |
<%= javascript_tag "$('#project_tag_list').tagit({
|
|
| 13 |
tagSource: function(search, showChoices) {
|
|
| 14 |
var that = this; |
|
| 15 |
$.ajax({
|
|
| 16 |
url: '#{url_for(:controller => 'auto_completes', :action => 'project_tags')}',
|
|
| 17 |
data: {q: search.term},
|
|
| 18 |
success: function(choices) {
|
|
| 19 |
showChoices(that._subtractArray(jQuery.parseJSON(choices), that.assignedTags())); |
|
| 20 |
} |
|
| 21 |
}); |
|
| 22 |
}, |
|
| 23 |
}); |
|
| 24 |
" %> |
|
| 25 |
|
|
| 10 | 26 |
</div> |
| 11 | 27 |
<% end -%> |
| plugins/redmine_tags/lib/redmine_tags/hooks/model_project_hook.rb | ||
|---|---|---|
| 21 | 21 |
module Hooks |
| 22 | 22 |
class ModelProjectHook < Redmine::Hook::ViewListener |
| 23 | 23 |
def controller_project_before_save(context={})
|
| 24 |
debugger |
|
| 25 | 24 |
save_tags_to_project(context, true) |
| 26 | 25 |
end |
| 27 | 26 |
|
| ... | ... | |
| 30 | 29 |
# cleared on reload. So instead, hook in after the Issue#save to update |
| 31 | 30 |
# this issue's tag_list and call #save ourselves. |
| 32 | 31 |
def controller_projects_before_save(context={})
|
| 33 |
debugger |
|
| 34 | 32 |
save_tags_to_project(context, false) |
| 35 | 33 |
context[:project].save |
| 36 | 34 |
end |
| 37 | 35 |
|
| 38 | 36 |
def save_tags_to_project(context, create_journal) |
| 39 | 37 |
params = context[:params] |
| 40 |
debugger |
|
| 41 |
logger.error { "WORKING" }
|
|
| 42 | 38 |
|
| 43 | 39 |
# if params && params[:issue] && !params[:issue][:tag_list].nil? |
| 44 | 40 |
# old_tags = context[:issue].tag_list.to_s |
| plugins/redmine_tags/lib/redmine_tags/patches/project_patch.rb | ||
|---|---|---|
| 22 | 22 |
end |
| 23 | 23 |
|
| 24 | 24 |
module ClassMethods |
| 25 |
TAGGING_IDS_LIMIT_SQL = <<-SQL |
|
| 26 |
tag_id IN ( |
|
| 27 |
SELECT #{ActsAsTaggableOn::Tagging.table_name}.tag_id
|
|
| 28 |
FROM #{ActsAsTaggableOn::Tagging.table_name}
|
|
| 29 |
WHERE #{ActsAsTaggableOn::Tagging.table_name}.taggable_id IN (?)
|
|
| 30 |
) |
|
| 31 |
SQL |
|
| 32 |
|
|
| 25 | 33 |
def search_by_question(question) |
| 26 | 34 |
if question.length > 1 |
| 27 | 35 |
search(RedmineProjectFiltering.calculate_tokens(question), nil, :all_words => true).first.sort_by(&:lft) |
| ... | ... | |
| 30 | 38 |
end |
| 31 | 39 |
end |
| 32 | 40 |
|
| 41 |
# Returns available project tags |
|
| 42 |
# Does not return tags from private projects |
|
| 43 |
# === Parameters |
|
| 44 |
# * <i>options</i> = (optional) Options hash of |
|
| 45 |
# * name_like - String. Substring to filter found tags. |
|
| 46 |
def available_tags( options = {} )
|
|
| 47 |
ids_scope = Project.visible |
|
| 33 | 48 |
|
| 34 |
# Returns available project tags |
|
| 35 |
# does not show tags from private projects |
|
| 36 |
def available_tags( options = {} )
|
|
| 49 |
conditions = [""] |
|
| 37 | 50 |
|
| 38 |
name_like = options[:name_like] |
|
| 39 |
options = {}
|
|
| 40 |
visible = ARCondition.new |
|
| 41 |
|
|
| 42 |
visible << ["#{Project.table_name}.is_public = '1'"]
|
|
| 43 |
|
|
| 44 |
if name_like |
|
| 45 |
visible << ["#{ActsAsTaggableOn::Tag.table_name}.name LIKE ?", "%#{name_like.downcase}%"]
|
|
| 51 |
# limit to the tags matching given %name_like% |
|
| 52 |
if options[:name_like] |
|
| 53 |
conditions[0] << "#{ActsAsTaggableOn::Tag.table_name}.name LIKE ? AND "
|
|
| 54 |
conditions << "%#{options[:name_like].downcase}%"
|
|
| 46 | 55 |
end |
| 47 | 56 |
|
| 48 |
options[:conditions] = visible.conditions |
|
| 57 |
conditions[0] << TAGGING_IDS_LIMIT_SQL |
|
| 58 |
conditions << ids_scope.map{ |issue| issue.id }.push(-1)
|
|
| 49 | 59 |
|
| 50 |
self.all_tag_counts(options)
|
|
| 60 |
self.all_tag_counts(:conditions => conditions)
|
|
| 51 | 61 |
end |
| 52 | 62 |
end |
| 53 | 63 |
end |
Also available in: Unified diff