Skip to content

Commit

Permalink
Add dropdown menu for prefilling header field
Browse files Browse the repository at this point in the history
  • Loading branch information
just806me committed Nov 26, 2023
1 parent e9b664a commit 9c6ee16
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/assets/javascripts/rails_admin/custom/ui.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$(document).on('click', '[data-action="prefill"]', function (e) {
const $prefillTarget = $($(this).data('target'));
const $eventTarget = $(e.target);
$prefillTarget.val($eventTarget.text());
});
10 changes: 9 additions & 1 deletion app/views/admin/spreadsheet_public.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
<div class="control-group row mb-3">
<%= f.label :header, 'Заголовок', class: 'col-sm-2 col-form-label text-md-end' %>
<div class="col-sm-10">
<%= f.text_field :header, class: 'form-control' %>
<div class="input-group">
<%= f.text_field :header, class: 'form-control' %>
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown"></button>
<ul class="dropdown-menu dropdown-menu-end" data-action="prefill" data-target="#spreadsheet_config_public_header">
<button type="button" class="dropdown-item">Протокол спільного засідання журі та оргкомітету <%= @object.display_name %></button>
<button type="button" class="dropdown-item">Попередні результати <%= @object.display_name %></button>
<button type="button" class="dropdown-item">Протокол засідання журі <%= @object.display_name %></button>
</ul>
</div>
</div>
</div>

Expand Down

0 comments on commit 9c6ee16

Please sign in to comment.