{#
The Mia! Accounting Project
form.html: The currency form

 Copyright (c) 2023 imacat.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

Author: imacat@mail.imacat.idv.tw (imacat)
First written: 2023/2/6
#}
{% extends "accounting/base.html" %}

{% block accounting_scripts %}
  <script src="{{ url_for("accounting.static", filename="js/currency-form.js") }}"></script>
{% endblock %}

{% block content %}

<div class="mb-3 accounting-toolbar">
  <a class="btn btn-primary" role="button" href="{% block back_url %}{% endblock %}">
    <i class="fa-solid fa-circle-chevron-left"></i>
    <span class="d-none d-md-inline">{{ A_("Back") }}</span>
  </a>
</div>

<form id="accounting-form" action="{% block action_url %}{% endblock %}" method="post">
  {{ form.csrf_token }}
  {% if request.args.next %}
    <input type="hidden" name="next" value="{{ request.args.next }}">
  {% endif %}
  <div class="form-floating mb-3">
    <input id="accounting-code" class="form-control {% if form.code.errors %} is-invalid {% endif %}" type="text" name="code" value="{{ form.code.data|accounting_default }}" placeholder=" " required="required" data-exists-url="{{ url_for("accounting.currency-api.exists") }}" data-original="{% block original_code %}{% endblock %}" data-blocklist="{{ form.CODE_BLOCKLIST|tojson|forceescape }}">
    <label class="form-label" for="accounting-code">{{ A_("Code") }}</label>
    <div id="accounting-code-error" class="invalid-feedback">{% if form.code.errors %}{{ form.code.errors[0] }}{% endif %}</div>
  </div>

  <div class="form-floating mb-3">
    <input id="accounting-name" class="form-control {% if form.name.errors %} is-invalid {% endif %}" type="text" name="name" value="{{ form.name.data|accounting_default }}" placeholder=" " required="required">
    <label class="form-label" for="accounting-name">{{ A_("Name") }}</label>
    <div id="accounting-name-error" class="invalid-feedback">{% if form.name.errors %}{{ form.name.errors[0] }}{% endif %}</div>
  </div>

  <div class="d-none d-md-block">
    <button class="btn btn-primary" type="submit">
      <i class="fa-solid fa-floppy-disk"></i>
      {{ A_("Save") }}
    </button>
  </div>

  <div class="d-md-none accounting-material-fab">
    <button class="btn btn-primary" type="submit">
      <i class="fa-solid fa-floppy-disk"></i>
    </button>
  </div>
</form>

{% endblock %}
