Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions app/views/shared/_form_image_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<% include_downloadable_asset ||= false %>
<% primary_title ||= "Primary image" %>
<% downloadable_title ||= "Downloadable attachment" %>
<% include_gallery_assets = true unless local_assigns.key?(:include_gallery_assets) %>
<% gallery_title ||= "Gallery attachments" %>

<div class="image-fields my-3">
Expand Down Expand Up @@ -57,34 +58,38 @@
<% end %>

<%# ---- GALLERY IMAGES ---- %>
<% counter = 1 %>
<%= f.fields_for :gallery_assets do |img| %>
<div class="flex flex-col text-left items-left gap-1 w-full md:w-1/3 lg:w-1/4 mb-6">
<%= render "shared/form_image_field",
f: img,
label: "#{gallery_title} #{counter}" %>
</div>
<% counter += 1 %>
<% if include_gallery_assets %>
<% counter = 1 %>
<%= f.fields_for :gallery_assets do |img| %>
<div class="flex flex-col text-left items-left gap-1 w-full md:w-1/3 lg:w-1/4 mb-6">
<%= render "shared/form_image_field",
f: img,
label: "#{gallery_title} #{counter}" %>
</div>
<% counter += 1 %>
<% end %>
<% end %>

</div>

<!-- Add file button (bottom-right) -->
<div class="mt-4 flex justify-end">
<%= link_to_add_association "Add another file",
f,
:gallery_assets,
insertion_node: ".image-fields-row",
insertion_method: :append,
partial: "shared/form_image_field_insert",
render_options: {
locals: {
label: "Additional #{gallery_title}",
resource: f.object.gallery_assets.build,
}
},
class: "text-blue-600 hover:text-blue-800 font-medium text-sm pr-2 pb-6" %>
</div>
<% if include_gallery_assets %>
<!-- Add file button (bottom-right) -->
<div class="mt-4 flex justify-end">
<%= link_to_add_association "Add another file",
f,
:gallery_assets,
insertion_node: ".image-fields-row",
insertion_method: :append,
partial: "shared/form_image_field_insert",
render_options: {
locals: {
label: "Additional #{gallery_title}",
resource: f.object.gallery_assets.build,
}
},
class: "text-blue-600 hover:text-blue-800 font-medium text-sm pr-2 pb-6" %>
</div>
<% end %>
</div>

<% if f.object.respond_to?(:images) && f.object.images.any? %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/story_ideas/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@
<% end %>

<div id="attachments">
<%= render "shared/form_image_fields", f: f, include_primary_asset: true,
primary_title: "Primary attachment", gallery_title: "Additional attachment" %>
<%= render "shared/form_image_fields", f: f, include_primary_asset: false,
gallery_title: "Additional attachment" %>
</div>

<div id="publish-preferences" class="flex pt-6 gap-4">
Expand Down
2 changes: 1 addition & 1 deletion app/views/workshop_ideas/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
</div>


<%= render "shared/form_image_fields", f: f, include_primary_asset: true %>
<%= render "shared/form_image_fields", f: f, include_primary_asset: false %>
<div class="action-buttons mt-8 flex justify-center gap-3">
<% if allowed_to?(:destroy?, f.object) %>
<%= link_to "Delete", @workshop_idea, class: "btn btn-danger-outline",
Expand Down
2 changes: 1 addition & 1 deletion app/views/workshop_variation_ideas/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
</div>
</div>
<% end %>
<%= render "shared/form_image_fields", f: f, include_primary_asset: true unless promoted_to_variation %>
<%= render "shared/form_image_fields", f: f, include_primary_asset: false unless promoted_to_variation %>
<div class="action-buttons mt-8 flex justify-center gap-3 pt-6">
<% if allowed_to?(:destroy?, f.object) && f.object. workshop_variations.none? && !promoted_to_variation %>
<span class="admin-only bg-blue-100 p-3">
Expand Down