mirror of
https://github.com/TracksApp/tracks.git
synced 2026-04-18 01:59:02 +02:00
show attachment in view and make it downloadable
This commit is contained in:
parent
2bd68fecb7
commit
f2c6c2d3af
4 changed files with 28 additions and 0 deletions
|
|
@ -124,6 +124,11 @@ img.delete_item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.todo_attachment {
|
||||||
|
background: image-url('bottom_off.png') no-repeat top;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
a.undecorated_link {background-color:transparent;color:transparent;}
|
a.undecorated_link {background-color:transparent;color:transparent;}
|
||||||
img.todo_star {background-image: image-url('staricons.png'); background-repeat: no-repeat; border:none; background-position: -32px 0px;}
|
img.todo_star {background-image: image-url('staricons.png'); background-repeat: no-repeat; border:none; background-position: -32px 0px;}
|
||||||
img.todo_star.starred{ background-position: 0px 0px; }
|
img.todo_star.starred{ background-position: 0px 0px; }
|
||||||
|
|
|
||||||
|
|
@ -815,6 +815,20 @@ class TodosController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def attachment
|
||||||
|
id = params[:id]
|
||||||
|
filename = params[:filename]
|
||||||
|
attachment = current_user.attachments.find(id)
|
||||||
|
|
||||||
|
if attachment
|
||||||
|
send_file(attachment.file.path,
|
||||||
|
disposition: 'attachment',
|
||||||
|
type: 'message/rfc822')
|
||||||
|
else
|
||||||
|
head :not_found
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_group_view_by
|
def set_group_view_by
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,14 @@ module TodosHelper
|
||||||
link_to(t('todos.convert_to_project'), url, {:class => "icon_item_to_project", :id => dom_id(todo, "to_project")})
|
link_to(t('todos.convert_to_project'), url, {:class => "icon_item_to_project", :id => dom_id(todo, "to_project")})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def attachment_image(todo)
|
||||||
|
link_to(
|
||||||
|
image_tag('blank.png', width: 16, height: 16, border:0),
|
||||||
|
todo.attachments.first.file.url,
|
||||||
|
{:class => 'todo_attachment', title: 'Get attachments of this todo'}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def collapsed_notes_image(todo)
|
def collapsed_notes_image(todo)
|
||||||
link = link_to(
|
link = link_to(
|
||||||
image_tag( 'blank.png', :width=>'16', :height=>'16', :border=>'0' ),
|
image_tag( 'blank.png', :width=>'16', :height=>'16', :border=>'0' ),
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ cache [todo, current_user.date.strftime("%Y%m%d"), @source_view, current_user.pr
|
||||||
<%= project_and_context_links( todo, parent_container_type, :suppress_context => suppress_context, :suppress_project => suppress_project ) %>
|
<%= project_and_context_links( todo, parent_container_type, :suppress_context => suppress_context, :suppress_project => suppress_project ) %>
|
||||||
<%= collapsed_notes_image(todo) if todo.notes.present? %>
|
<%= collapsed_notes_image(todo) if todo.notes.present? %>
|
||||||
<%= collapsed_successors_image(todo) if todo.has_pending_successors %>
|
<%= collapsed_successors_image(todo) if todo.has_pending_successors %>
|
||||||
|
<%= attachment_image(todo) if todo.attachments.present? %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="<%= dom_id(todo, 'edit') %>" class="edit-form" style="display:none">
|
<div id="<%= dom_id(todo, 'edit') %>" class="edit-form" style="display:none">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue