{% extends 'package/snippets/resource_form.html' %}

{% block errors %}
  {%- if errors -%}
    {%- set schema = h.scheming_get_dataset_schema(dataset_type) -%}
    {%- snippet 'scheming/snippets/errors.html',
      errors=errors, fields=schema.resource_fields,
      entity_type='dataset', object_type=dataset_type -%}
  {%- endif -%}
{% endblock %}

{% block basic_fields %}
  {%- if not dataset_type -%}
    <p>
    dataset_type not passed to template. your version of CKAN
    might not be compatible with ckanext-scheming
    </p>
  {%- endif -%}

  {%- set schema = h.scheming_get_dataset_schema(dataset_type) -%}
  {%- if dataset_type == 'service' -%}
    <p>
      This is a service!
    </p>
  {%- snippet 'snippets/resource_fields.html', resource_type='deployment', schema=schema, dataset_type=dataset_type, data=data, errors=errors -%}
  {%- snippet 'snippets/resource_fields.html', resource_type='configuration', schema=schema, dataset_type=dataset_type, data=data, errors=errors -%}
  {%- snippet 'snippets/resource_fields.html', resource_type='readme', schema=schema, dataset_type=dataset_type, data=data, errors=errors -%}
  {%- endif -%}
  {%- if dataset_type == 'application' -%}
    <p>
      This is an application!
    </p>
  {%- snippet 'snippets/resource_fields.html', resource_type='Deployment file (docker-compose.xml) - mandatory', schema=schema, dataset_type=dataset_type, data=data, errors=errors -%}
  {%- snippet 'snippets/resource_fields.html', resource_type='Configuration file (.env) - optional', schema=schema, dataset_type=dataset_type, data=data, errors=errors -%}
  {%- snippet 'snippets/resource_fields.html', resource_type='Routing (.xml) - optional', schema=schema, dataset_type=dataset_type, data=data, errors=errors -%}
  {%- endif -%}
  {%- if dataset_type == 'dataset' -%}
    <p>
      This is a dataset!
    </p>
      {%- snippet 'snippets/resource_fields.html', resource_type='resource', schema=schema, dataset_type=dataset_type, data=data, errors=errors -%}
  {%- endif -%}


{% endblock %}


    {% block again_button %}
        {%- if dataset_type == 'dataset' -%}
            {{ super() }}
        {%- endif -%}
    {% endblock %}
    {% block metadata_fields %}
        {%- if dataset_type == 'dataset' -%}
            {{ super() }}
        {%- endif -%}
    {% endblock %}
