attachment new version

This commit is contained in:
Andreas Stephanides
2015-04-07 23:21:33 +02:00
parent b04b23e647
commit 0df5e72e15
17 changed files with 273 additions and 43 deletions

View File

@@ -4,6 +4,7 @@
<% if (!["jpg","png","jpeg"].find_index(data_ext).nil?) %>
<%= image_tag attachment.datei.thumb.url %>
<% else %>
<%= image_tag "pdf-logo.jpg" %>
<% end %>
<%= attachment.name %>

View File

@@ -0,0 +1,30 @@
<table class="table-striped" id="<%= Attachment.parent_attachment_list_id(parent) %>">
<% attachment_list.each do |a| %>
<tr>
<td>
<%= fa_icon("tag") if a.flag_titlepic %>
<%= link_to a.datei.url do %>
<%= render partial:"attachments/attachment_new", object: a %>
<% end %>
</td>
<% if editor %>
<td>
<div class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><%= fa_icon("chevron-down") %> Actions</a>
<ul class="dropdown-menu">
<li>
<%= link_to fa_icon("tag")+" Titlepic", set_titlepic_attachment_path(a,:params=>{:titlepic=>true}), remote: true %>
</li>
<li>
<%= link_to ff_icon("icon-pencil")+" Edit", edit_attachment_path(a) %>
</li>
<li>
<%= link_to fa_icon("trash")+" Delete", attachment_path(a), method: "DELETE", confirm: "Sure?" , class: "btn-danger " %>
</li>
</ul>
</div>
</td>
<% end %>
</tr>
<% end %>
</table>

View File

@@ -0,0 +1,14 @@
<% attachment=attachment_new %>
<% data_ext = attachment.datei.file.try(:extension).try(:downcase) %>
<% if (!["jpg","png","jpeg"].find_index(data_ext).nil?) %>
<%= image_tag attachment.datei.thumb_small.url %>
<% elsif (!["pdf"].find_index(data_ext).nil?)%>
<%= image_tag attachment.datei.cover.url %>
<% else %>
<%= ff_icon("ffi1-note20 fa-2x") %>
<% end %>
<%= attachment.name %>

View File

@@ -0,0 +1,145 @@
<div class="container-fluid">
<%= semantic_form_for [form_bulk2], :remote=>true, :html => { :multipart => true, :id => "fileupload" } do |f| %>
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="row-fluid">
<div class="span7">
<div class="fileupload-buttonbar">
<!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button">
<i class="icon-plus icon-white"></i>
<span>Add files...</span>
<%= f.file_field :datei, :multiple=>true %>
<%= f.input :parent_id , as: :hidden %>
<%= f.input :parent_type, as: :hidden %>
</span>
<button type="submit" class="btn btn-primary start">
<i class="icon-upload icon-white"></i>
<span>Start upload</span>
</button>
<button type="reset" class="btn btn-warning cancel">
<i class="icon-ban-circle icon-white"></i>
<span>Cancel upload</span>
</button>
<button type="button" class="btn btn-danger delete">
<i class="icon-trash icon-white"></i>
<span>Delete</span>
</button>
<input type="checkbox" class="toggle">
</div>
<div class="span5">
<!-- The global progress bar -->
<div class="progress progress-success progress-striped active fade">
<div class="bar" style="width:100%;"></div>
</div>
</div>
</div>
</div>
<!-- The loading indicator is shown during image processing -->
<div class="fileupload-loading"></div>
<br>
<!-- The table listing the files available for upload/download -->
<table class="table table-striped"><tbody class="files" data-toggle="modal-lva" data-target="#modal-lva"></tbody>
</table>
<% end %>
</div>
<script>
var fileUploadErrors = {
maxFileSize: 'File is too big',
minFileSize: 'File is too small',
acceptFileTypes: 'Filetype not allowed',
maxNumberOfFiles: 'Max number of files exceeded',
uploadedBytes: 'Uploaded bytes exceed file size',
emptyResult: 'Empty file upload result'
};
</script>
<!-- The template to display files available for upload -->
<script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<tr class="template-upload fade">
<!--<td class="preview"><span class="fade"></span></td>-->
<td class="name"><span>{%=file.name %}</span></td>
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
{% if (file.error) { %}
<td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
{% } else if (o.files.valid && !i) { %}
<td>
<div class="progress progress-success progress-striped active"><div class="bar" style="width:0%;"></div></div>
</td>
<td class="start">{% if (!o.options.autoUpload) { %}
<button class="btn btn-primary">
<i class="icon-upload icon-white"></i>
<span>{%=locale.fileupload.start%}</span>
</button>
{% } %}</td>
{% } else { %}
<td colspan="2"></td>
{% } %}
<td class="cancel">{% if (!i) { %}
<button class="btn btn-warning">
<i class="icon-ban-circle icon-white"></i>
<span>{%=locale.fileupload.cancel%}</span>
</button>
{% } %}</td>
</tr>
{% } %}
</script>
<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<tr class="template-download fade">
{% if (file.error) { %}
<td></td>
<td class="name"><span>{%=file.name%}</span></td>
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
<td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
{% } else { %}
<!--<td class="preview">{% if (file.thumbnail_url) { %}
<a href="{%=file.url%}" title="{%=file.name%}" rel="lva" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a>
{% } %}</td>-->
<td class="name">
<a href="{%=file.url%}" title="{%=file.name%}" rel="{%=file.thumbnail_url%}" download="{%=file.name%}">{%=file.name%}</a>
</td>
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
<td colspan="2"></td>
{% } %}
<td class="delete">
<button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
<i class="icon-trash icon-white"></i>
<span>{%=locale.fileupload.destroy%}</span>
</button>
<input type="checkbox" name="delete" value="1">
</td>
</tr>
{% } %}
</script>
<script type="text/javascript" charset="utf-8">
$(function () {
// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload();
$('#fileupload').bind('fileuploaddone',function(e,data){$.getScript("/attachments/refresh_list?parent_type=<%= form_bulk2.parent_type %>&parent_id=<%= form_bulk2.parent_id %>")});
//
// Load existing files:
$.getJSON($('#fileupload').prop('action'), function (files) {
var fu = $('#fileupload').data('blueimpFileupload'),
template;
fu._adjustMaxNumberOfFiles(-files.length);
console.log(files);
// no Download on Upload form
//template = fu._renderDownload(files)
//.appendTo($('#fileupload .files'));
// Force reflow:
fu._reflow = fu._transition && template.length &&
template[0].offsetWidth;
template.addClass('in');
$('#loading').remove();
});
$('#attachment_datei').attr('name', 'attachment[datei]');
$('#attachment_datei').fileupload();
});
</script>

View File

@@ -3,4 +3,4 @@
<%= render 'form' %>
<%= link_to 'Back', thema_attachments_path(@attachment.thema,@attachment) %>
<%= link_to 'Back', attachments_path(@attachment) %>

View File

@@ -0,0 +1 @@
$("#<%= Attachment.parent_attachment_list_id(@parent) %>").replaceWith("<%= escape_javascript ( render partial:"attachments/attachment_list", object:@attachments, locals: {editor: true, parent: @parent} ) %>")

View File

@@ -1,10 +1,10 @@
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @attachment.name %>
<%= render @attachment %>
</p>
<%= link_to 'Edit', edit_attachment_path(@attachment) %> |
<%= link_to 'Back', attachments_path %>
<%= link_to 'Back', polymorphic_path(@attachment.parent) %>

View File

@@ -4,5 +4,5 @@
<%= fa_icon("file-text") %>
<%= link_to document.name, document %>
<%= link_to "edit", edit_document_path(document),:remote=>true if can? :edit, document %>
<%= link_to "rename", edit_document_path(document),:remote=>true if can? :edit, document %>
</div>

View File

@@ -17,7 +17,10 @@
<ul class='breadcrumb hidden-print'>
<% @document.versions.each do |v| %>
<li>
<%= link_to User.find(v.whodunnit).name+": "+ v.event + " (" + I18n.l(v.created_at)+ ") ", write_document_path(@document,:versionid=>v.id) %>
<%= link_to User.find(v.whodunnit).name+": "+ v.event + " (" + I18n.l(v.created_at)+ ") ", write_document_path(@document,:versionid=>v.id) unless v.whodunnit.nil? %>
<% end %> <span class="divider">/</span></li>
</ul>
<% end %>
<%= render_attachments_for(@document) %>

View File

@@ -78,6 +78,9 @@ end
<%= render @neuigkeit.meeting %>
<% end%>
<div id="calentry_new" ><%= link_to "new Calentry", new_calentry_path(:object_id=>@neuigkeit.id, :object_type=>"Neuigkeit"), :remote=>true if can? :edit, @neuigkeit %></div>
<%= %>
<%= render_attachments_for(@neuigkeit) %>
<%= render 'layouts/pretty_toolbar', :object=> @toolbar_elements %>
</div>
<%= render partial: 'nlink_list_whole', :object=>@neuigkeit.nlinks %>

View File

@@ -1,12 +1,7 @@
<div>
<b>Titlepics</b>
<% @thema.titlepics.each do |tp| %>
<%= link_to image_tag(tp.datei.thumb.url) , set_titlepic_thema_attachment_path(tp.thema,tp,:params=>{:titlepic=>false}) %>
<% end %></div>
<b> List </b>
<%= render partial: "themen/attachment_list", object:@thema.attachments ,locals: {:editor => true}%>
<div>
<b>Form</b>
<%= render :partial=>"attachments/form_bulk" %>
<%= render_attachments_for(@thema) %>
</div>

View File

@@ -78,7 +78,7 @@
<% unless small.hideattachment %>
<%= render partial: "themen/attachment_list", object: small.attachments, locals:{editor: false} unless small.attachments.empty? %>
<%= render partial: "attachments/attachment_list", object: small.attachments, locals:{editor: false, parent: small} unless small.attachments.empty? %>
<% end %>
<br/>