Mercurial > hg > soundsoftware-site
changeset 749:3f28aebc5fc1 feature_14
started building the project's tag filtering interface.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Tue, 08 Nov 2011 17:12:52 +0000 |
parents | 287c27cb8bd2 |
children | 3ee8507c841f |
files | vendor/plugins/redmine_tags/app/views/projects/_filter_tags.rhtml vendor/plugins/redmine_tags/app/views/projects/index.rhtml vendor/plugins/redmine_tags/lib/redmine_tags/hooks/model_project_hook.rb vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb |
diffstat | 4 files changed, 78 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/vendor/plugins/redmine_tags/app/views/projects/_filter_tags.rhtml Tue Nov 08 15:05:22 2011 +0000 +++ b/vendor/plugins/redmine_tags/app/views/projects/_filter_tags.rhtml Tue Nov 08 17:12:52 2011 +0000 @@ -1,12 +1,12 @@ <p class='tag'> - <%= label_tag 'Tag' %> - <%= select_tag("tag[#{tag.id}]", - options_from_collection_for_select( - [nil] + Project.available_tags, - 'to_s', - 'to_s', - @custom_fields[custom_field.id.to_s] - ) - ) - %> + <% fields_for @project, :builder => TabularFormBuilder do |f| -%> + <div> + <p id="project_tags"> + <%= f.text_field :tag_list, :label => :tags, :size => 60, :class => 'hol' %> + </p> + <div id="project_tag_candidates" class="autocomplete"></div> + <%= javascript_include_tag 'tags_input', :plugin => 'redmine_tags' %> + <%= javascript_tag "observeProjectTagsField('#{url_for(:controller => 'auto_completes', :action => 'project_tags')}')" %> + </div> + <% end -%> </p>
--- a/vendor/plugins/redmine_tags/app/views/projects/index.rhtml Tue Nov 08 15:05:22 2011 +0000 +++ b/vendor/plugins/redmine_tags/app/views/projects/index.rhtml Tue Nov 08 17:12:52 2011 +0000 @@ -18,6 +18,11 @@ <%= render :partial => 'custom_field', :collection => @custom_fields_used_for_project_filtering %> <p class='buttons'><%= submit_tag( l(:button_send), :id => 'filter_button') -%></p> </div> + + <div id='filter_tags'> + <%= render :partial => 'filter_tags' %> + </div> + </fieldset> <% end %>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_tags/lib/redmine_tags/hooks/model_project_hook.rb Tue Nov 08 17:12:52 2011 +0000 @@ -0,0 +1,58 @@ +# This file is a part of redmine_tags +# redMine plugin, that adds tagging support. +# +# Copyright (c) 2010 Eric Davis +# Copyright (c) 2010 Aleksey V Zapparov AKA ixti +# +# redmine_tags is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_tags is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_tags. If not, see <http://www.gnu.org/licenses/>. + +module RedmineTags + module Hooks + class ModelProjectHook < Redmine::Hook::ViewListener + def controller_project_before_save(context={}) + debugger + save_tags_to_project(context, true) + end + + # Issue has an after_save method that calls reload (update_nested_set_attributes) + # This makes it impossible for a new record to get a tag_list, it's + # cleared on reload. So instead, hook in after the Issue#save to update + # this issue's tag_list and call #save ourselves. + def controller_projects_before_save(context={}) + debugger + save_tags_to_project(context, false) + context[:project].save + end + + def save_tags_to_project(context, create_journal) + params = context[:params] + debugger + logger.error { "WORKING" } + + # if params && params[:issue] && !params[:issue][:tag_list].nil? + # old_tags = context[:issue].tag_list.to_s + # context[:issue].tag_list = params[:issue][:tag_list] + # new_tags = context[:issue].tag_list.to_s + # + # if create_journal and not (old_tags == new_tags || context[:issue].current_journal.blank?) + # context[:issue].current_journal.details << JournalDetail.new(:property => 'attr', + # :prop_key => 'tag_list', + # :old_value => old_tags, + # :value => new_tags) + # end + # end + end + end + end +end
--- a/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb Tue Nov 08 15:05:22 2011 +0000 +++ b/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb Tue Nov 08 17:12:52 2011 +0000 @@ -8,7 +8,7 @@ base.class_eval do unloadable before_filter :add_tags_to_project, :only => [:save, :update] - before_filter :filter_projects, :only => :index + before_filter :filter_projects, :only => :index end end @@ -30,9 +30,10 @@ end def filter_projects - - logger.error { "FILTRA PA!" } - + logger.error { "before_filter: filter_projects" } + + @project = Project.new + respond_to do |format| format.any(:html, :xml) { calculate_filtered_projects