Nuevo plugin Redmine Glossary 0.9.2
This commit is contained in:
parent
5d298a7529
commit
693eb3ee50
72 changed files with 2962 additions and 0 deletions
50
plugins/redmine_glossary/lib/grouping_terms.rb
Executable file
50
plugins/redmine_glossary/lib/grouping_terms.rb
Executable file
|
@ -0,0 +1,50 @@
|
|||
#
|
||||
# category_terms.rb
|
||||
#
|
||||
# Author : Mitsuyoshi Yoshida
|
||||
# This program is freely distributable under the terms of an MIT-style license.
|
||||
#
|
||||
|
||||
require 'i18n'
|
||||
|
||||
class GroupingTerms
|
||||
attr_reader :type, :target
|
||||
attr_accessor :ary
|
||||
|
||||
def initialize(type, target)
|
||||
@type = type
|
||||
@target = target
|
||||
@ary = []
|
||||
end
|
||||
|
||||
def name
|
||||
(@target) ? @target.name : I18n.t(:label_not_categorized)
|
||||
end
|
||||
|
||||
def <=>(rhterm)
|
||||
if (!@target and !rhterm.target)
|
||||
return 0
|
||||
elsif (!@target or !rhterm.target)
|
||||
return -1 if @target
|
||||
return 1 if rhterm.target
|
||||
end
|
||||
case type
|
||||
when GlossaryStyle::GroupByCategory
|
||||
@target.position <=> rhterm.target.position
|
||||
when GlossaryStyle::GroupByProject
|
||||
@target.identifier <=> rhterm.target.identifier
|
||||
end
|
||||
end
|
||||
|
||||
def self.flatten(gtarmsary)
|
||||
flatary = []
|
||||
gtarmsary.each {|gtarmsary|
|
||||
return gtarmsary unless gtarmsary.is_a?(GroupingTerms)
|
||||
flatary += gtarmsary.ary
|
||||
}
|
||||
flatary
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue