fix json output in controller, now it lists attachments as it should (no preview though).
This commit is contained in:
parent
a86b81e3c0
commit
b5d7a49741
2 changed files with 18 additions and 31 deletions
|
|
@ -5,10 +5,11 @@ class EventAttachmentsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@proposal = Event.find(params[:proposal_id])
|
@proposal = Event.find(params[:proposal_id])
|
||||||
@uploads = @proposal.event_attachments
|
@uploads = @proposal.event_attachments
|
||||||
|
@uploads = @uploads.map{|upload| upload.to_jq_upload }
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
format.json { render json: {files: @uploads.map{|upload| upload.to_jq_upload } }}
|
format.json { render json: @uploads.to_json}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -101,12 +102,13 @@ class EventAttachmentsController < ApplicationController
|
||||||
@upload = @proposal.event_attachments.find(params[:id])
|
@upload = @proposal.event_attachments.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
if @upload.destroy
|
@upload.destroy if !@upload.nil?
|
||||||
flash[:notice] = "Deleted successfully attachment '#{@upload.title}' for proposal '#{@proposal.title}'"
|
|
||||||
else
|
|
||||||
flash[:error] = "Attachment could not be deleted."
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_back_or_to conference_proposal_index_path(@conference.short_title)
|
respond_to do |format|
|
||||||
|
|
||||||
|
format.html { redirect_back_or_to conference_proposal_index_path(@conference.short_title), :notice => "Deleted successfully attachment '#{@upload.title}' for proposal '#{@proposal.title}'" }
|
||||||
|
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
= form_for EventAttachment.new, :url => conference_proposal_event_attachment_index_path(@conference.short_title, @event), :html => { :multipart => true, :id => "fileupload" } do |f|
|
= form_for EventAttachment.new, :url => conference_proposal_event_attachment_index_path(@conference.short_title, @event), :html => { :multipart => true, :id => "fileupload" } do |f|
|
||||||
%table.table.table-striped
|
%table.table.table-striped
|
||||||
%thead
|
%thead
|
||||||
|
%th
|
||||||
%th
|
%th
|
||||||
%b Filename
|
%b Filename
|
||||||
%th
|
%th
|
||||||
|
|
@ -22,23 +23,9 @@
|
||||||
%th
|
%th
|
||||||
%b Public
|
%b Public
|
||||||
%th
|
%th
|
||||||
|
%th
|
||||||
%tbody.files
|
%tbody.files
|
||||||
- @event.event_attachments.each do |a|
|
|
||||||
%tr
|
|
||||||
%td
|
|
||||||
= link_to a.attachment_file_name, conference_proposal_event_attachment_path(@conference.short_title, @event.id, a.id)
|
|
||||||
%td
|
|
||||||
= a.title
|
|
||||||
%td
|
|
||||||
= number_to_human_size a.attachment_file_size
|
|
||||||
%td
|
|
||||||
- if a.public?
|
|
||||||
Public
|
|
||||||
- else
|
|
||||||
Not Public
|
|
||||||
%td
|
|
||||||
= link_to "Delete", conference_proposal_event_attachment_path(@conference.short_title, @event.id, a.id),
|
|
||||||
:method => :delete, :confirm => "Are you sure you want to delete this attachment? It's permanant!"
|
|
||||||
|
|
||||||
.row-fluid.fileupload-buttonbar
|
.row-fluid.fileupload-buttonbar
|
||||||
.btn.btn-success.fileinput-button
|
.btn.btn-success.fileinput-button
|
||||||
|
|
@ -76,16 +63,15 @@
|
||||||
{% for (var i=0, file; file=o.files[i]; i++) { %}
|
{% for (var i=0, file; file=o.files[i]; i++) { %}
|
||||||
<tr class="template-upload fade">
|
<tr class="template-upload fade">
|
||||||
<td class="preview"><span class="fade"></span></td>
|
<td class="preview"><span class="fade"></span></td>
|
||||||
<td class="name"><span>{%=file.name%}</span></td>
|
<td class="name"><span>{%=file.name%}</span>
|
||||||
|
<div class="progress progress-success progress-striped active"><div class="bar" style="width:0%;"></div></div>
|
||||||
|
</td>
|
||||||
<td class="name"><input type="text" name="title[]" value="{%=file.name%}"/></td>
|
<td class="name"><input type="text" name="title[]" value="{%=file.name%}"/></td>
|
||||||
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
|
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
|
||||||
<td class="name"><input checked type="checkbox" name="public">Public</input></td>
|
<td class="name"><input checked type="checkbox" name="public">Public</input></td>
|
||||||
{% if (file.error) { %}
|
{% 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>
|
<td class="error"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
|
||||||
{% } else if (o.files.valid && !i) { %}
|
{% } 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) { %}
|
<td class="start">{% if (!o.options.autoUpload) { %}
|
||||||
<button class="btn btn-primary">
|
<button class="btn btn-primary">
|
||||||
<span class="glyphicon glyphicon-upload"></span>
|
<span class="glyphicon glyphicon-upload"></span>
|
||||||
|
|
@ -93,7 +79,7 @@
|
||||||
</button>
|
</button>
|
||||||
{% } %}</td>
|
{% } %}</td>
|
||||||
{% } else { %}
|
{% } else { %}
|
||||||
<td colspan="2"></td>
|
<td></td>
|
||||||
{% } %}
|
{% } %}
|
||||||
<td class="cancel">{% if (!i) { %}
|
<td class="cancel">{% if (!i) { %}
|
||||||
<button class="btn btn-warning">
|
<button class="btn btn-warning">
|
||||||
|
|
@ -123,9 +109,8 @@
|
||||||
<td>{%=file.title%}</td>
|
<td>{%=file.title%}</td>
|
||||||
<td class="size">{%=o.formatFileSize(file.size)%}</td>
|
<td class="size">{%=o.formatFileSize(file.size)%}</td>
|
||||||
<td>{%=file.public%}</td>
|
<td>{%=file.public%}</td>
|
||||||
<td colspan="2"></td>
|
|
||||||
{% } %}
|
{% } %}
|
||||||
<td class="delete">
|
<td class="delete" colspan="2">
|
||||||
<button class="btn btn-danger pull-right" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
|
<button class="btn btn-danger pull-right" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
|
||||||
<span class="glyphicon glyphicon-trash"></i>
|
<span class="glyphicon glyphicon-trash"></i>
|
||||||
<span>{%=locale.fileupload.destroy%}</span>
|
<span>{%=locale.fileupload.destroy%}</span>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue