Sha256: 798f3a75f48150324c4ba5df41e29991ee8e7aa4ff5b45da5745bede44e2dfbf

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

<%= simple_form_for([:admin, @document, @document_distribution]) do |f| %>
  <%= f.error_notification %>
  <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

  <div class="form-inputs">
    <%= f.input :friendlier_id, input_html: { value: @document.friendlier_id, readonly: true } %>
    <%= f.input :reference_type_id, as: :select, collection: ReferenceType.all.map { |r| [r.reference_type, r.id] }, label: 'Reference Type' %>
    <%= f.input :url, label: 'Distribution URL' %>
    <%= f.input :label, autofocus: true, input_html: { disabled: true, id: 'label-input' } %>
    
  </div>

  <div class="form-actions">
    <%= f.button :submit, 'Create Download URL', {class: 'btn btn-primary'} %>
  </div>
<% end %>

<script>
document.addEventListener('DOMContentLoaded', function() {
  const distributionSelect = document.querySelector('select[name="document_distribution[reference_type_id]"]');
  const labelInput = document.getElementById('label-input');

  function toggleLabelInput() {
    if (distributionSelect.options[distributionSelect.selectedIndex].text === 'Download file') {
      labelInput.disabled = false;
    } else {
      labelInput.disabled = true;
    }
  }

  distributionSelect.addEventListener('change', toggleLabelInput);
    toggleLabelInput(); // Initial check
  });
</script>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geoblacklight_admin-0.6.0 app/views/admin/document_distributions/_form.html.erb