kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
51 lines
1.1 KiB
3 years ago
|
module Exports
|
||
4 years ago
|
module Formatters
|
||
|
class Default
|
||
|
include Redmine::I18n
|
||
|
|
||
3 years ago
|
attr_reader :attribute
|
||
|
|
||
|
def initialize(attribute)
|
||
|
@attribute = attribute
|
||
|
end
|
||
|
|
||
4 years ago
|
##
|
||
3 years ago
|
# Checks if this column is applicable for this column
|
||
|
def self.apply?(_attribute)
|
||
4 years ago
|
false
|
||
|
end
|
||
|
|
||
|
def self.key
|
||
3 years ago
|
name.demodulize.underscore.to_sym
|
||
4 years ago
|
end
|
||
|
|
||
|
##
|
||
3 years ago
|
# Takes a WorkPackage and an attribute and returns the value to be exported.
|
||
|
def format(object, **options)
|
||
|
value = object.try(attribute)
|
||
4 years ago
|
|
||
|
case value
|
||
|
when Date
|
||
|
format_date value
|
||
|
when Time, DateTime, ActiveSupport::TimeWithZone
|
||
|
format_time value
|
||
|
when Array
|
||
|
value.join options.fetch(:array_separator, ', ')
|
||
|
when nil
|
||
|
# ruby >=2.7.1 will return a frozen string for nil.to_s which will cause an error when e.g. trying to
|
||
|
# force an encoding
|
||
|
''
|
||
|
else
|
||
|
value.to_s
|
||
|
end
|
||
|
end
|
||
|
|
||
|
##
|
||
3 years ago
|
# Takes an attribute and returns format options for it.
|
||
|
def format_options
|
||
4 years ago
|
{}
|
||
|
end
|
||
|
end
|
||
|
end
|
||
3 years ago
|
end
|