mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-12 18:34:22 +01:00
wire up downloading attachments from todo partial
This commit is contained in:
parent
4d7c453ca7
commit
6405bf5d1a
5 changed files with 32 additions and 3 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;}
|
||||
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; }
|
||||
|
|
|
|||
|
|
@ -701,7 +701,6 @@ class TodosController < ApplicationController
|
|||
@tag = Tag.where(:name => @tag_name).first_or_create
|
||||
end
|
||||
|
||||
|
||||
def tags
|
||||
# TODO: limit to current_user
|
||||
tags_beginning = Tag.where('name like ?', params[:term]+'%')
|
||||
|
|
@ -815,6 +814,23 @@ class TodosController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def attachment
|
||||
id = params[:id]
|
||||
filename = params[:filename]
|
||||
attachment = Attachment.where(id: id).first
|
||||
|
||||
if attachment
|
||||
if attachment.todo.user == current_user
|
||||
send_file(attachment.file.path)
|
||||
else
|
||||
head :forbidden
|
||||
end
|
||||
else
|
||||
head :not_found
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
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")})
|
||||
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)
|
||||
link = link_to(
|
||||
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 ) %>
|
||||
<%= collapsed_notes_image(todo) if todo.notes.present? %>
|
||||
<%= collapsed_successors_image(todo) if todo.has_pending_successors %>
|
||||
<%= attachment_image(todo) if todo.attachments.present? %>
|
||||
</div>
|
||||
</div>
|
||||
<div id="<%= dom_id(todo, 'edit') %>" class="edit-form" style="display:none">
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ Rails.application.routes.draw do
|
|||
get 'convert_to_project' # TODO: convert to PUT/POST
|
||||
delete 'remove_predecessor' # TODO: convert to PUT/POST
|
||||
post 'change_context'
|
||||
get 'attachment'
|
||||
end
|
||||
collection do
|
||||
get 'done'
|
||||
|
|
@ -106,7 +105,7 @@ Rails.application.routes.draw do
|
|||
# This means the controller action needs to parse the extension and set format/content type
|
||||
# Needed for /todos/tag/first.last.m to work
|
||||
get 'todos/tag/:name' => 'todos#tag', :as => :tag, :format => false, :name => /.*/
|
||||
|
||||
get 'attachments/:id/:filename' => "todos#attachment"
|
||||
get 'tags.autocomplete' => "todos#tags", :format => 'autocomplete'
|
||||
get 'todos/done/tag/:name' => "todos#done_tag", :as => :done_tag
|
||||
get 'todos/all_done/tag/:name' => "todos#all_done_tag", :as => :all_done_tag
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue