{#
SPDX-License-Identifier: GPL-3.0-or-later OR CC-BY-SA-4.0

Proxy web UI item loading page.

This file is part of Hydrilla&Haketilo.

Copyright (C) 2022 Wojtek Kosior

Dual licensed under
* GNU General Public License v3.0 or later and
* Creative Commons Attribution Share Alike 4.0 International.

You can choose to use either of these licenses or both.


I, Wojtek Kosior, thereby promise not to sue for violation of this
file's licenses. Although I request that you do not make use of this
code in a proprietary work, I am not going to enforce this in court.
#}
{% extends "base.html.jinja" %}

{% block title %} {{ _('web_ui.import.title') }} {% endblock %}

{% block style %}
  {{ super() }}

  input[type="file"]::-webkit-file-selector-button,
  input[type="file"]::file-selector-button {
      display: none;
  }

  input[type="file"] {
      display: block;
      font-size: inherit;
      font-style: inherit;
  }
{% endblock %}

{% block main %}
  <h3>{{ _('web_ui.import.heading') }}</h3>

  <h4>{{ _('web_ui.import.heading_import_from_file') }}</h4>

  <form method="POST" enctype="multipart/form-data">
    <input name="action" type="hidden" value="import_from_file">

    {% if uploaded_file_not_zip is defined %}
      {{ error_note(_('web_ui.err.uploaded_file_not_zip')) }}
    {% endif %}

    {% if invalid_uploaded_malcontent is defined %}
      {{ error_note(_('web_ui.err.invalid_uploaded_malcontent')) }}
    {% endif %}

    <input id="items_zipfile" name="items_zipfile" type="file"
           accept=".zip,application/zip" required=""
           class="block-with-bottom-margin">

    <label class="green-button block-with-bottom-margin" for="items_zipfile">
      {{ _('web_ui.import.choose_zipfile_button') }}
    </label>

    <div class="horizontal-separator"></div>

    <div class="flex-row">
      <button class="green-button">
        {{ _('web_ui.import.install_from_file_button') }}
      </button>
    </div>
  </form>

  <div class="horizontal-separator"></div>

  <h4>{{ _('web_ui.import.heading_import_ad_hoc') }}</h4>

  {% if invalid_ad_hoc_package is defined %}
    {{ error_note(_('web_ui.err.invalid_ad_hoc_package')) }}
  {% endif %}

  <form method="POST">
    <input name="action" type="hidden" value="import_ad_hoc">

    {{ label(_('web_ui.import.identifier_field_label'), 'identifier') }}
    {% if invalid_ad_hoc_identifier is defined %}
      {{ error_note(_('web_ui.err.invalid_ad_hoc_identifier')) }}
    {% endif %}
    {{ form_field('identifier') }}

    {{ label(_('web_ui.import.long_name_field_label'), 'long_name') }}
    {{ form_field('long_name', required=false) }}

    {{ label(_('web_ui.import.version_field_label'), 'version') }}
    {% if invalid_ad_hoc_version is defined %}
      {{ error_note(_('web_ui.err.invalid_ad_hoc_version')) }}
    {% endif %}
    {{ form_field('version', required=false) }}

    {{ label(_('web_ui.import.description_field_label'), 'description') }}
    {{ form_field('description', required=false, height=3) }}

    {{ label(_('web_ui.import.patterns_field_label'), 'patterns') }}
    {% if invalid_ad_hoc_patterns is defined %}
      {{ error_note(_('web_ui.err.invalid_ad_hoc_patterns')) }}
    {% endif %}
    {{ form_field('patterns', height=3) }}

    {{ label(_('web_ui.import.script_text_field_label'), 'script_text') }}
    {{ form_field('script_text', required=false, height=15) }}

    {{ label(_('web_ui.import.lic_text_field_label'), 'license_text') }}
    {{ form_field('license_text', required=false, height=10) }}

    <div class="flex-row">
      <button class="green-button">
        {{ _('web_ui.import.install_ad_hoc_button') }}
      </button>
    </div>
  </form>
{% endblock %}
