Skip to content

Commit

Permalink
Extract wiki_page_attachments to partial
Browse files Browse the repository at this point in the history
  • Loading branch information
alno committed Apr 17, 2016
1 parent bb2721b commit 0613686
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
14 changes: 14 additions & 0 deletions app/views/base_wiki_pages/_wiki_page_attachments.html.erb
@@ -0,0 +1,14 @@
<% page.attachments.each do |attachment| %>
<%= image_tag(attachment.wiki_page_attachment.url(:thumb)) %>
Attachment_<%= attachment.id %>
<%= link_to(wt('Remove'), wiki_remove_page_attachment_path(attachment.id), method: :delete) %>
<% end %>
<%= form_for(Irwi.config.page_attachment_class.new,
as: :wiki_page_attachment,
url: wiki_add_page_attachment_path(page),
html: { multipart: true }) do |form| %>
<%= form.file_field :wiki_page_attachment %>
<%= form.hidden_field :page_id, value: page.id %>
<%= form.submit 'New Attachment' %>
<% end %>
17 changes: 1 addition & 16 deletions lib/irwi/helpers/wiki_pages_helper.rb
Expand Up @@ -124,21 +124,6 @@ def wiki_page_history(page = nil, versions = nil)
end

def wiki_page_attachments(page = @page)
return unless Irwi.config.page_attachment_class_name

page.attachments.each do |attachment|
concat image_tag(attachment.wiki_page_attachment.url(:thumb))
concat "Attachment_#{attachment.id}"
concat link_to(wt('Remove'), wiki_remove_page_attachment_path(attachment.id), method: :delete)
end

form_for(Irwi.config.page_attachment_class.new,
as: :wiki_page_attachment,
url: wiki_add_page_attachment_path(page),
html: { multipart: true }) do |form|
concat form.file_field :wiki_page_attachment
concat form.hidden_field :page_id, value: page.id
concat form.submit 'Add Attachment'
end
render partial: "#{template_dir '_wiki_page_actions'}/wiki_page_attachments", locals: { page: page }
end
end

0 comments on commit 0613686

Please sign in to comment.