{% import 'macros/form.html' as form %}
{% import 'macros/kata_form.html' as kata_form %}
{{ _('Basic information') }}
{{ _('Titles') }}
{% set titles = [] %}
{% if data.langtitle %}
{% set titles = data.langtitle %}
{% endif %}
{% if (titles|length) == 0 %}
{% for extra in range(1,2) %}
{% do titles.append({'value': '', 'lang': ''}) %}
{% endfor %}
{% endif %}
{# Render title fields #}
{% for langtitle in titles %}
{% set index = loop.index0 %}
{% call form.input('langtitle__' ~ index ~ '__value', id='langtitle__' ~ index ~ '__value_id', label=_('Title'), placeholder='', value=langtitle.value, classes=['control-group control-custom'], label_classes=['control-label kata-input-comp'], control_classes=['controls editor'], attrs={'class': "kata-medium-input"}) %}
{% if index == 0 %}
{{ kata_form.tooltip(tooltip=_("Field is compulsory.
Type an informative title for the research data. Choose the title\'s language from the language menu. You can add several titles in different languages using the \'+\' button. If you leave an added title field empty it is discarded. However, at least the first title field must have a value.")) }}
{% endif %}
{% if index == 0 %}
{{ kata_form.plusbutton(onclick="$(\'#lbtn__" ~ index ~ "__value_id\').change(); console.trace();") }}
{% endif %}
{#% if title.value %#}
{#% endif %#}
{% set authors = h.get_authors(data) %}
{% if authors|length == 0 %}
{% do authors.append(dict(role='author',)) %}
{% endif %}
{% set author_errors = h.get_dict_errors(errors, '__extras', 'author') %}
{% for agent in authors %}
{% set index = agent_index.increase() %}
{% call form.input('agent__' ~ index ~ '__name', label=_('Author'), id='agent__' ~ index ~ '__name_id', placeholder=_('Familyname, Firstname and/or http://orcid.org/'), value=agent.name, error=h.get_dict_field_errors(errors, 'agent', index, 'name'), classes=['control-custom'], label_classes=['kata-input-comp'], attrs={'class': "kata-medium-input"}) %}
{% if loop.index0 == 0 %}
{{ kata_form.tooltip(tooltip=_('Field is compulsory.
Author is a person or an organisation who has authored the dataset.
Type names of authors and organisations to the corresponding fields, one author per a field pair. You can add more fields for additional authors by pressing the \'+\' button. If you leave an added author field empty, it is discarded, but note that the first author/organisation field pair must have values.
You can enter the author\'s name or ID, such as an ORCID identifier. If you choose to enter a name, please use format "familyname, firstname".')) }}
{% endif %}
{% endcall %}
{% call form.input('agent__' ~ index ~ '__organisation', label=_('Organisation'), id='agent__' ~ index ~ '__organisation_id', placeholder=_('University. Faculty. Department.'), value=agent.organisation, error=h.get_dict_field_errors(errors, 'agent', index, 'organisation'), classes=['control-custom'], label_classes=['kata-input-comp'], attrs={'class': "kata-medium-input"}) %}
{% if loop.index0 == 0 %}
{{ kata_form.plusbutton(id="authors_add", onclick="$(\'#obtn__" ~ index ~ "__value_id\').change();") }}
{% endif %}
{% endcall %}
{% endfor %}
{% if author_errors and author_errors is iterable %}{{ author_errors|join('. ') }}{% endif %}
{{ _('Contributors') }}{{ kata_form.optional() }}
{% set contributors = h.get_contributors(data) %}
{% if contributors|length == 0 %}
{% do contributors.append(dict(role='contributor',)) %}
{% endif %}
{% set contributor_errors = h.get_dict_errors(errors, '__extras', 'contributors') %}
{% for agent in contributors %}
{% set index = agent_index.increase() %}
{% set agent_prefix = "agent__" ~ index ~ "__" %}
{% call form.input('agent__' ~ index ~ '__name', label=_('Name'), id='agent__' ~ index ~ '__name_id', placeholder=_('Familyname, Firstname and/or http://orcid.org/'), value=agent.name, error=h.get_dict_field_errors(errors, 'agent', index, 'name'), classes=['control-custom'], label_classes=['kata-input-comp'], attrs={'class': "kata-medium-input"}) %}
{% if loop.index0 == 0 %}
{{ kata_form.tooltip(tooltip=_("Field is not compulsory.
Contributor is a person or an organisation who, in addition to the author, has contributed significantly to the dataset.
Type names of contributors and organisations to the corresponding fields, one contributor per a field pair. You can add more fields for additional contributors by pressing the \'+\' button. If you leave an added contributor field empty, it is discarded.
You can enter the contributor's name or ID such as an ORCID identifier.")) }}
{% endif %}
{% endcall %}
{% call form.input('agent__' ~ index ~ '__organisation', label=_('Organisation'), id='agent__' ~ index ~ '__organisation_id', placeholder=_('University. Faculty. Department.'), value=agent.organisation, error=h.get_dict_field_errors(errors, 'agent', index, 'organisation'), classes=['control-custom'], label_classes=['kata-input-comp'], attrs={'class': "kata-medium-input"}) %}
{% if loop.index0 == 0 %}
{{ kata_form.plusbutton(id="contributors_add", onclick="$(\'#obtn__" ~ index ~ "__value_id\').change();") }}
{% endif %}
{% endcall %}
{% endfor %}
{% if owner_errors and owner_errors is iterable %}{{ contributor_errors|join('. ') }}{% endif %}
{# Autocomplete for keywords #}
{{ _('Subject') }}
{{ _('Search keywords from') }} KOKO{{ _(' ontology, select keywords with enter or mouse click.') }}
{# Languages #}
{{ _('This dataset contains non-textual data') }}
{% call form.input('language', label=_('Languages'), id='language', placeholder=_('eng, fin, swe ...'), value=data.language, error=errors.language, classes=['control-medium'], control_classes=["controls editor"], label_classes=['control-label'], attrs={'class': "kata-medium-input"}) %}
{{ kata_form.tooltip(tooltip=_('Field is compulsory, if checkbox is unchecked.
Type a comma separated list of languages, in ISO 639-2 T format, used in your data, for example \"eng, fin, swe\".')) }}
{% endcall %}
{{ _('Find language codes from: ') }} http://www.loc.gov/standards/iso639-2/php/code_list.php