Skip to content

Commit

Permalink
add "accept: 'image/*'" to attachment form (#1898)
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta authored Aug 18, 2024
1 parent c8dd11d commit e9e446c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 44 deletions.
2 changes: 1 addition & 1 deletion app/views/carrier_types/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
<div class="field">
<%= f.label t('page.file') -%>
<%= f.file_field :attachment -%>
<%= f.file_field :attachment, accept: 'image/*' -%>
</div>

<% if f.object.attachment.present? %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/library_groups/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<div class="field">
<%= f.label :header_logo -%><br />
<%= f.file_field :header_logo -%>
<%= f.file_field :header_logo, accept: 'image/*' -%>
<br />
<%= f.check_box :delete_header_logo -%>
<%= t('page.destroy') %>
Expand Down
21 changes: 21 additions & 0 deletions app/views/picture_files/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<%= form_with(model: picture_file) do |f| -%>
<%= error_messages(picture_file) -%>

<div class="field">
<%= f.label t('page.file') -%><br />
<%= f.file_field :attachment, accept: 'image/*', required: true -%>
</div>

<% if picture_file.attachment.attached? %>
<div class="field">
<%= render 'picture_files/link', picture_file: picture_file %>
</div>
<% end %>

<%= f.hidden_field :picture_attachable_id -%>
<%= f.hidden_field :picture_attachable_type -%>

<div class="actions">
<%= f.submit %>
</div>
<%- end -%>
19 changes: 1 addition & 18 deletions app/views/picture_files/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
<div id="content_detail" class="ui-corner-all ui-widget-content">
<h1 class="title"><%= t('page.editing', model: t('activerecord.models.picture_file')) -%></h1>
<div id="content_list">

<%= form_with(model: @picture_file) do |f| -%>
<%= error_messages(@picture_file) -%>

<div class="field">
<%= f.label t('page.file') -%><br />
<%= f.file_field :attachment -%>
</div>

<div class="field">
<%= render 'picture_files/link', picture_file: @picture_file %>
</div>

<div class="actions">
<%= f.submit %>
</div>
<%- end -%>

<%= render 'form', picture_file: @picture_file %>
</div>
</div>

Expand Down
27 changes: 3 additions & 24 deletions app/views/picture_files/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
<div id="content_detail" class="ui-corner-all ui-widget-content">
<h1 class="title"><%= t('page.new', model: t('activerecord.models.picture_file')) -%></h1>
<div id="content_list">

<%= form_with(model: @picture_file) do |f| -%>
<% if @picture_file.errors.any? %>
<div id="error_explanation">
<ul>
<li><%= t('picture_file.invalid_file') %></li>
</ul>
</div>
<% end %>

<%= f.hidden_field :picture_attachable_id -%>
<%= f.hidden_field :picture_attachable_type -%>

<div class="field">
<%= f.label t('page.file') -%><br />
<%= f.file_field :attachment -%>
<h1 class="title"><%= t('page.new', model: t('activerecord.models.picture_file')) -%></h1>
<div id="content_list">
<%= render 'form', picture_file: @picture_file %>
</div>

<div class="actions">
<%= f.submit %>
</div>
<%- end -%>
</div>
</div>

<div id="submenu" class="ui-corner-all ui-widget-content">
Expand Down

0 comments on commit e9e446c

Please sign in to comment.