indentlabs/notebook

View on GitHub
app/views/content/attributes/fields/options/_link.html.erb

Summary

Maintainability
Test Coverage
<div class="row">
  <div class="col s12 center grey-text uppercase">
    Field options
  </div>
</div>
<div class="row">
  <div class="col s12">
    <p>
      Customize which pages this field can link to with the dropdown below.
      This won't remove any existing links you've already made between your pages.
    </p>
  </div>
  <div class="input-field col s12">
    <%= form_for field, remote: true do |f| %>
      <label>Linkable page types</label>
      <select multiple 
        name="attribute_field[field_options][linkable_types][]" 
        prompt="Please select at least one page type for this field to link to"
        class="autosave-closest-form-on-change"
      >
        <%=
          options_for_select(
            Rails.application.config.content_types[:all].map { |klass| [klass.name.pluralize, klass.name] }, 
            field.migrated_from_legacy? \
              ? (field.field_options || {}).fetch('linkable_types', []) # New-style links
              : (@dummy_model.send(field.old_column_source).klass)      # Old-style links
          )
        %>
      </select>
      <small class="grey-text">Changes will automatically save.</small><br />
    <% end %>
  </div>
</div>