app/views/hyrax/base/_form_member_of_collections.html.erb
<%# [hyc-override] https://github.com/samvera/hyrax/tree/hyrax-v4.0.0/app/views/hyrax/base/_form_member_of_collections.html.erb %>
<%# Form UI behavior code and details;
Code:
app/assets/javascripts/hyrax/relationships
CSS:
[data-behavior="remove-relationship"] : Button to remove its parent TR from the table
[data-behavior="add-relationship"] : Button to clone its parent TR and inject a new row into the table
.message.has-warning : Used to display UI errors related to input values and server errors
HTML Properties:
table:
[data-behavior="child-relationships"] : allows the javascript to be initialized
data-param-key : the parameter key value for this model type %>
<h2 class="h3 mt-4"><%= t("hyrax.works.form.in_collections") %></h2>
<div class="form-group" data-behavior="collection-relationships" data-param-key="<%= f.object.model_name.param_key %>" data-members="<%= member_of_collections_json(f.object) %>">
<div class="form-inline mb-3">
<%= f.label :member_of_collection_ids %>
<%= f.input_field :member_of_collection_ids,
prompt: :translate,
data: {
autocomplete: 'collection',
'autocomplete-url' => Rails.application.routes.url_helpers.qa_path + '/search/collections?access=deposit'
} %>
<%# [hyc-override] Change to a button and add a tab index to make keyboard accessible %>
<button type="button" class="btn btn-secondary ml-2" tabindex="0" data-behavior="add-relationship"><%= t('.add') %></button>
</div>
<table class="table table-striped">
<caption><%= t('.caption') %></caption>
<thead>
<tr>
<th><%= t('.header.title') %></th>
<th><%= t('.header.actions') %></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<script type="text/x-tmpl" id="tmpl-collection">
<tr>
<td>{%= o.title %}</td>
<td><button class="btn btn-danger" data-behavior="remove-relationship" data-confirm-text="<%= t('.confirm.text') %>" data-confirm-cancel="<%= t('.confirm.cancel') %>" data-confirm-remove="<%= t('.confirm.remove') %>"><%= t('.actions.remove') %></button></td>
</tr>
</script>