file order mechanism changed
This commit is contained in:
parent
c676e4cabe
commit
fb8ea6ebc7
|
@ -39,7 +39,7 @@ class Admin::ArchiveFilesController < OrbitAdminController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @archive_file.save
|
if @archive_file.save
|
||||||
format.html { redirect_to(admin_archive_files_path) }
|
format.html { redirect_to(edit_admin_archive_file_path(@archive_file.id)) }
|
||||||
format.xml { render :xml => @archive_file, :status => :created, :location => @archive_file }
|
format.xml { render :xml => @archive_file, :status => :created, :location => @archive_file }
|
||||||
else
|
else
|
||||||
@tags = @module_app.tags
|
@tags = @module_app.tags
|
||||||
|
@ -58,7 +58,7 @@ class Admin::ArchiveFilesController < OrbitAdminController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @archive_file.update_attributes(archive_vars)
|
if @archive_file.update_attributes(archive_vars)
|
||||||
format.html { redirect_to(admin_archive_files_path(:page => params[:page])) }
|
format.html { redirect_to(edit_admin_archive_file_path(@archive_file.id)) }
|
||||||
format.xml { head :ok }
|
format.xml { head :ok }
|
||||||
else
|
else
|
||||||
format.html { render :action => "edit" }
|
format.html { render :action => "edit" }
|
||||||
|
|
|
@ -20,7 +20,7 @@ class ArchivesController < ApplicationController
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
files = []
|
files = []
|
||||||
archive.archive_file_multiples.order_by(:sort_number=>'asc').each do |file|
|
archive.archive_file_multiples.order_by(:sort_number=>'desc').each do |file|
|
||||||
if file.choose_lang.include?(I18n.locale.to_s)
|
if file.choose_lang.include?(I18n.locale.to_s)
|
||||||
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
||||||
extension = file.file.file.extension.downcase rescue ""
|
extension = file.file.file.extension.downcase rescue ""
|
||||||
|
|
|
@ -3,11 +3,18 @@
|
||||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||||
<%= stylesheet_link_tag "lib/fileupload" %>
|
<%= stylesheet_link_tag "lib/fileupload" %>
|
||||||
<%= stylesheet_link_tag "lib/main-list" %>
|
<%= stylesheet_link_tag "lib/main-list" %>
|
||||||
|
<style type="text/css">
|
||||||
|
.sort-order-icon{
|
||||||
|
font-size: 25px;
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% content_for :page_specific_javascript do %>
|
<% content_for :page_specific_javascript do %>
|
||||||
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
|
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
|
||||||
<%= javascript_include_tag "lib/file-type" %>
|
<%= javascript_include_tag "lib/file-type" %>
|
||||||
<%= javascript_include_tag "lib/module-area" %>
|
<%= javascript_include_tag "lib/module-area" %>
|
||||||
|
<%= javascript_include_tag "lib/jquery-ui-sortable.min" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%#= f.error_messages %>
|
<%#= f.error_messages %>
|
||||||
|
@ -123,11 +130,20 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted"><%= t(:file_) %></label>
|
<label class="control-label muted"><%= t(:file_) %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
<p class="add-btn">
|
||||||
|
<%= hidden_field_tag 'archive_file_multiple_field_count', @archive_file.archive_file_multiples.count %>
|
||||||
|
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<div class="controls">
|
||||||
|
<!-- Add -->
|
||||||
|
<div class="add-target" id="add-target"></div>
|
||||||
<!-- Exist -->
|
<!-- Exist -->
|
||||||
<% if @archive_file && !@archive_file.archive_file_multiples.blank? %>
|
<% if @archive_file && !@archive_file.archive_file_multiples.blank? %>
|
||||||
<div class="exist">
|
<div class="exist plugin-sortable">
|
||||||
<% @archive_file.archive_file_multiples.each_with_index do |archive_file_multiple, i| %>
|
<% @archive_file.archive_file_multiples.desc(:sort_number).each_with_index do |archive_file_multiple, i| %>
|
||||||
<%= f.fields_for :archive_file_multiples, archive_file_multiple do |f| %>
|
<%= f.fields_for :archive_file_multiples, archive_file_multiple do |f| %>
|
||||||
<%= render :partial => 'form_file', :object => archive_file_multiple, :locals => {:f => f, :i => i} %>
|
<%= render :partial => 'form_file', :object => archive_file_multiple, :locals => {:f => f, :i => i} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -135,40 +151,38 @@
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<!-- Add -->
|
|
||||||
<div class="add-target">
|
|
||||||
</div>
|
|
||||||
<p class="add-btn">
|
|
||||||
<%= hidden_field_tag 'archive_file_multiple_field_count', @archive_file.archive_file_multiples.count %>
|
|
||||||
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Form Actions -->
|
<!-- Form Actions -->
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<%= hidden_field_tag 'page', params[:page] if !params[:page].blank? %>
|
<%= hidden_field_tag 'page', params[:page] if !params[:page].blank? %>
|
||||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||||
<a href="/<%= I18n.locale.to_s %>/admin/archive_files/" class="btn" >Cancel</a>
|
<a href="<%= admin_archive_files_path %>" class="btn">Back to Archives</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% content_for :page_specific_javascript do %>
|
<% content_for :page_specific_javascript do %>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
$(".plugin-sortable").sortable({
|
||||||
|
update : function(event, ui){
|
||||||
|
var existingfiles = $(".exist.plugin-sortable div.fileupload")
|
||||||
|
existingfiles.each(function(i, file){
|
||||||
|
$(file).find("input.file-sort-number-field").val(existingfiles.length - i);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
$('.main-forms .add-on').tooltip();
|
$('.main-forms .add-on').tooltip();
|
||||||
$(document).on('click', '#add_file', function(){
|
$(document).on('click', '#add_file', function(){
|
||||||
var new_id = $(this).prev().attr('value');
|
var new_id = $(this).prev().attr('value');
|
||||||
var old_id = new RegExp("new_archive_file_multiples", "g");
|
var old_id = new RegExp("new_archive_file_multiples", "g");
|
||||||
var on = $('.language-nav li.active').index();
|
var on = $('.language-nav li.active').index();
|
||||||
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
|
var le = $('#add-target').children('.start-line').length;
|
||||||
$(this).prev().attr('value', parseInt(new_id) + 1);
|
$(this).prev().attr('value', parseInt(new_id) + 1);
|
||||||
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :archive_file_multiples) %>").replace(old_id, new_id));
|
$('#add-target').prepend(("<%= escape_javascript(add_attribute 'form_file', f, :archive_file_multiples) %>").replace(old_id, new_id).replace("new_archive_file_sort_order_XXX", parseInt(new_id) + 1));
|
||||||
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
|
$('#add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
|
||||||
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
|
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
|
||||||
});
|
});
|
||||||
formTip();
|
formTip();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
|
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
|
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
|
||||||
|
<i class="icons-list-2 sort-order-icon"></i>
|
||||||
<% if form_file.file.blank? %>
|
<% if form_file.file.blank? %>
|
||||||
<%= t(:no_file) %>
|
<%= t(:no_file) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
@ -30,11 +31,6 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="add-on icon-list-ol" title="<%= t(:sort_number) %>"></span>
|
|
||||||
<span class="tab-content">
|
|
||||||
<%= f.text_field :sort_number , :class => "input-mini" %>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span class="add-on btn-group btn" title="<%= t('archive.show_lang') %>">
|
<span class="add-on btn-group btn" title="<%= t('archive.show_lang') %>">
|
||||||
<i class="icons-earth"></i> <span class="caret"></span>
|
<i class="icons-earth"></i> <span class="caret"></span>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
|
@ -53,10 +49,12 @@
|
||||||
<% if form_file.new_record? %>
|
<% if form_file.new_record? %>
|
||||||
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
|
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
|
||||||
<a class="icon-trash"></a>
|
<a class="icon-trash"></a>
|
||||||
|
<%= f.hidden_field :sort_number, :value => "new_archive_file_sort_order_XXX", :class => "input-mini" %>
|
||||||
</span>
|
</span>
|
||||||
<% else %>
|
<% else %>
|
||||||
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
|
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
|
||||||
<%= f.hidden_field :id %>
|
<%= f.hidden_field :id %>
|
||||||
|
<%= f.hidden_field :sort_number , :class => "file-sort-number-field" %>
|
||||||
<a class=" icon-remove"></a>
|
<a class=" icon-remove"></a>
|
||||||
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
|
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
|
||||||
</span>
|
</span>
|
||||||
|
|
Loading…
Reference in New Issue