diff --git a/app/models/mongoid/sortable.rb b/app/models/mongoid/sortable.rb index 1e7302b8b..16a69defb 100644 --- a/app/models/mongoid/sortable.rb +++ b/app/models/mongoid/sortable.rb @@ -21,7 +21,7 @@ module Mongoid private def set_sort_number - if self.sort_number.nil? + if self.new? && self.sort_number.nil? last_record = self.class.desc(:sort_number).first if last_record self.sort_number = (last_record.sort_number + 10) / 10 * 10 diff --git a/vendor/built_in_modules/archive/app/models/archive_file_multiple.rb b/vendor/built_in_modules/archive/app/models/archive_file_multiple.rb index 9dc833632..d45d34a82 100644 --- a/vendor/built_in_modules/archive/app/models/archive_file_multiple.rb +++ b/vendor/built_in_modules/archive/app/models/archive_file_multiple.rb @@ -2,23 +2,26 @@ class ArchiveFileMultiple include Mongoid::Document include Mongoid::Timestamps + include Mongoid::Sortable mount_uploader :file, AssetUploader - + field :file_title, localize: true # field :description field :choose_lang, :type => Array, :default => nil - + field :should_destroy, :type => Boolean + default_scope asc(:sort_number) + def choose_lang_display(lang) self.choose_lang.include?(lang) end - + belongs_to :archive_file - + # has_many :archive_file_multiple_langs, :autosave => true, :dependent => :destroy - + # accepts_nested_attributes_for :archive_file_multiple_langs, :allow_destroy => true - + end diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb index 01bd76e07..318ba6b51 100644 --- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb +++ b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb @@ -82,6 +82,7 @@