Skip to content

Commit

Permalink
nicer layout for nested links in forms
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Sep 4, 2024
1 parent 006a54f commit 604f726
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/views/application/_link_fields.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= cocooned_item class: "row mb-3 input-group" do %>
<%= f.label :url, class: "col-sm-2 col-form-label" %>
<%= f.label :url, class: "col col-auto col-form-label" %>
<%= f.url_field :url, class: "form-control col-auto", placeholder: "Any related web page" %>
<%= cocooned_remove_item_button icon(:trash, "Delete"), f, class: "btn btn-outline-danger col-auto" %>
<% end %>
29 changes: 18 additions & 11 deletions app/views/application/_links_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<%= cocooned_container id: "cocooned-links" do %>
<%= form.fields_for :links do |f| %>
<%= render "link_fields", f: f %>
<% end %>
<% end %>
<div class="row mb-3">
<%= tag.div class: "col-auto offset-sm-2 ps-0" do %>
<%= cocooned_add_item_button t(".add"), form, :links,
class: "btn btn-secondary",
insertion_node: "#cocooned-links",
insertion_method: "append" %>
<% end %>
<div class="col col-sm-2 col-form-label">
<%= t(".links") %>
</div>
<div class="col col-sm-10 border p-3">
<%= cocooned_container id: "cocooned-links" do %>
<%= form.fields_for :links do |f| %>
<%= render "link_fields", f: f %>
<% end %>
<% end %>
<div class="row mb-3">
<%= tag.div class: "col-auto offset-sm-2 ps-0" do %>
<%= cocooned_add_item_button t(".add"), form, :links,
class: "btn btn-secondary",
insertion_node: "#cocooned-links",
insertion_method: "append" %>
<% end %>
</div>
</div>
</div>
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ en:
storage_service: Storage Service
tag_regex: Required Tags
link:
url: Link
url: URL
model:
caption: Caption
collection_id: Collection
Expand Down Expand Up @@ -224,6 +224,7 @@ en:
version: Version
links_form:
add: add another link
links: Web Links
navbar:
account: Account
activity: Activity
Expand Down

0 comments on commit 604f726

Please sign in to comment.