Skip to content

Commit

Permalink
use input allow for files, add preview tags
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubik committed Feb 5, 2020
1 parent f8e398f commit fbcd5d3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/admin/news_article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
f.input :tpi_sector_ids, label: 'Sectors', as: :select,
collection: TPISector.order(:name), input_html: {multiple: true}
f.input :keywords_string, label: 'Keywords', hint: t('hint.tag'), as: :tags, collection: Keyword.pluck(:name)
f.input :image, as: :file
f.input :image, as: :file, input_html: {accept: 'image/*'}
end

f.actions
Expand Down
7 changes: 5 additions & 2 deletions app/admin/publication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@
f.input :tpi_sector_ids, label: 'Sectors', as: :select,
collection: TPISector.order(:name), input_html: {multiple: true}
f.input :keywords_string, label: 'Keywords', hint: t('hint.tag'), as: :tags, collection: Keyword.pluck(:name)
f.input :file, as: :file
f.input :image, as: :file
f.input :file,
as: :file,
hint: preview_file_tag(f.object.file),
input_html: {accept: 'application/pdf, application/vnd.ms-powerpoint, .ppt, .pptx'}
f.input :image, as: :file, hint: preview_file_tag(f.object.image), input_html: {accept: 'image/*'}
end

f.actions
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/pages/_image_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<%= content_tag :div, class: 'nested-fields inline-fields', data: { controller: 'image', new_record: is_new_record } do %>
<% if is_new_record || !form.object.logo.present? %>
<%= form.input :logo, as: :file %>
<%= form.input :logo, as: :file, input_html: {accept: 'image/*'} %>
<% else %>
<%= image_tag form.object.logo, style: 'height: 100px; width: 100px;' %>
<% end %>
Expand Down

0 comments on commit fbcd5d3

Please sign in to comment.