Merge branch 'lukas/picked_archive' into development
This commit is contained in:
commit
b6c8a88b73
|
@ -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
|
||||
|
|
|
@ -2,6 +2,7 @@ class ArchiveFileMultiple
|
|||
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include Mongoid::Sortable
|
||||
|
||||
mount_uploader :file, AssetUploader
|
||||
|
||||
|
@ -11,6 +12,8 @@ class ArchiveFileMultiple
|
|||
|
||||
field :should_destroy, :type => Boolean
|
||||
|
||||
default_scope asc(:sort_number)
|
||||
|
||||
def choose_lang_display(lang)
|
||||
self.choose_lang.include?(lang)
|
||||
end
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>排序數</th>
|
||||
<th>File</th>
|
||||
<th>File Name</th>
|
||||
<th class="span2"><%= t('呈現語系')%></th>
|
||||
|
@ -137,7 +138,9 @@
|
|||
var new_id = $(this).prev().attr('value');
|
||||
var old_id = new RegExp("new_archive_file_multiples", "g");
|
||||
$(this).prev().attr('value', parseInt(new_id) + 1);
|
||||
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_file', f, :archive_file_multiples) %>").replace(old_id, new_id));
|
||||
var new_form_file = $("<%= escape_javascript(add_attribute 'form_file', f, :archive_file_multiples) %>".replace(old_id, new_id));
|
||||
new_form_file.find('input#archive_file_archive_file_multiples_attributes_'+new_id+'_sort_number').val(new_id * 10)
|
||||
$(this).parents('table').append(new_form_file);
|
||||
});
|
||||
|
||||
$('.archive_file_multiples_block a.delete').live('click', function(){
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
<% # encoding: utf-8 %>
|
||||
|
||||
<tr id="<%= "archive_file_multiple_#{form_file.id}" if !form_file.new_record? %>" class='list_item'>
|
||||
<td>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<%= f.text_field :sort_number %>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
|
|
Reference in New Issue