diff options
Diffstat (limited to 'lib/plugins')
-rw-r--r-- | lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb index 626023b1b..344ff0866 100644 --- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -62,7 +62,19 @@ module Redmine def save_attachments(attachments, author=User.current) if attachments.is_a?(Hash) - attachments = attachments.values + attachments = attachments.stringify_keys + attachments = attachments.to_a.sort {|a, b| + if a.first.to_i > 0 && b.first.to_i > 0 + a.first.to_i <=> b.first.to_i + elsif a.first.to_i > 0 + 1 + elsif b.first.to_i > 0 + -1 + else + a.first <=> b.first + end + } + attachments = attachments.map(&:last) end if attachments.is_a?(Array) attachments.each do |attachment| |