{% extends "package/resource_edit_base.html" %}

{% import 'macros/form.html' as form %}

{% block subtitle %}{{ h.dataset_display_name(pkg) }} - {{ h.resource_display_name(res) }}{% endblock %}

{% block primary_content_inner %}

  {% set action = h.url_for(
    controller='ckanext.datastore.controller:DatastoreController',
    action='dictionary', id=pkg.name, resource_id=res.id) %}

  <form method="post" action="{{ action }}" >
    {% block dictionary_form %}
      {% for f in fields %}
        <h3>{{ _( "Field {num}.").format(num=loop.index) }} {{ f.id }} ({{ f.type }})</h3>
        {{ form.select('info__' ~ loop.index ~ '__type_override',
          label=_('Type Override'), options=[
          {'name': '', 'value': ''},
          {'name': 'text', 'value': 'text'},
          {'name': 'numeric', 'value': 'numeric'},
          {'name': 'timestamp', 'value': 'timestamp'},
          ], selected=f.get('info', {}).get('type_override', '')) }}
        {{ form.input('info__' ~ loop.index ~ '__label',
          label=_('Label'), id='field-f' ~ loop.index ~ 'label',
          value=f.get('info', {}).get('label', ''), classes=['control-full']) }}
        {{ form.markdown('info__' ~ loop.index ~ '__notes',
          label=_('Description'), id='field-d' ~ loop.index ~ 'notes',
          value=f.get('info', {}).get('notes', '')) }}
      {% endfor %}
    {% endblock %}
    <button class="btn btn-primary" name="save" type="submit">
      <i class="fa fa-book"></i> {{ _('Save') }}
    </button>
  </form>
{% endblock %}
