To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / vendor / plugins / redmine_tags / lib / redmine_tags / patches / project_patch.rb @ 756:18b0f6e6d7a8

History | View | Annotate | Download (2.22 KB)

1 727:e3e958595e07 luis
# C4DM
2
3
require_dependency 'project'
4
5
module RedmineTags
6
  module Patches
7
    module ProjectPatch
8 729:291c4d7dc0b6 luis
      def self.included(base) # :nodoc:
9 727:e3e958595e07 luis
        base.extend(ClassMethods)
10 730:4a9bb3b8d5cd luis
        base.send(:include, InstanceMethods)
11 727:e3e958595e07 luis
12
        base.class_eval do
13
          unloadable
14 730:4a9bb3b8d5cd luis
15
          attr_accessor :tag_list
16
17 727:e3e958595e07 luis
          acts_as_taggable
18 730:4a9bb3b8d5cd luis
19 727:e3e958595e07 luis
        end
20
      end
21
22 730:4a9bb3b8d5cd luis
      def before_save_with_save_tags()
23
#        debugger
24
        logger.error { "GONNA SAVE TAG LIST" }
25 729:291c4d7dc0b6 luis
26 730:4a9bb3b8d5cd luis
27
#        params[:tag_list]
28
29
30
        # logger.error { @project.name }
31 729:291c4d7dc0b6 luis
32
    #    if params && params[:project] && !params[:project][:tag_list].nil?
33
    #      old_tags = context[:project].tag_list.to_s
34
    #      context[:project].tag_list = params[:project][:tag_list]
35
    #      new_tags = context[:project].tag_list.to_s
36
    #
37
    #      unless (old_tags == new_tags || context[:project].current_journal.blank?)
38
    #        context[:project].current_journal.details << JournalDetail.new(:property => 'attr',
39
    #                                                                     :prop_key => 'tag_list',
40
    #                                                                     :old_value => old_tags,
41
    #                                                                     :value => new_tags)
42
    #      end
43
    #    end
44
      end
45
46 730:4a9bb3b8d5cd luis
      module InstanceMethods
47
48
      end
49 729:291c4d7dc0b6 luis
50 727:e3e958595e07 luis
      module ClassMethods
51 739:b7ac21913927 luis
        def search_by_question(question)
52
          if question.length > 1
53
            search(RedmineProjectFiltering.calculate_tokens(question), nil, :all_words => true).first.sort_by(&:lft)
54
          else
55
            all(:order => 'lft')
56
          end
57
        end
58
59
60 745:4acfc770e79f luis
        # Returns available project tags
61
        #  does not show tags from private projects
62 746:2ced57750157 luis
        def available_tags( options = {} )
63
64
          name_like = options[:name_like]
65 745:4acfc770e79f luis
          options = {}
66 727:e3e958595e07 luis
          visible   = ARCondition.new
67 745:4acfc770e79f luis
68
          visible << ["#{Project.table_name}.is_public = \"1\""]
69 746:2ced57750157 luis
70
          if name_like
71
            visible << ["#{ActsAsTaggableOn::Tag.table_name}.name LIKE ?", "%#{name_like.downcase}%"]
72
          end
73
74 727:e3e958595e07 luis
          options[:conditions] = visible.conditions
75 746:2ced57750157 luis
76 745:4acfc770e79f luis
          self.all_tag_counts(options)
77 727:e3e958595e07 luis
        end
78
      end
79
    end
80
  end
81
end