95 lines
5.0 KiB
HTML
95 lines
5.0 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block content %}
|
|
{% if mission_ops_tabs %}
|
|
{% include "_mission_ops_tabs.html" %}
|
|
{% endif %}
|
|
<section class="hero-panel compact page-header-compact">
|
|
<div class="hero-copy">
|
|
<p class="eyebrow">{{ eyebrow }}</p>
|
|
<h1>{{ heading }}</h1>
|
|
</div>
|
|
</section>
|
|
|
|
{% set field_error_map = field_errors|default({}, true) %}
|
|
|
|
<form method="post" class="edit-layout">
|
|
{% set hidden_field_values = hidden_fields|default({}, true) %}
|
|
{% for name, value in hidden_field_values.items() %}
|
|
<input type="hidden" name="{{ name }}" value="{{ value }}">
|
|
{% endfor %}
|
|
<section class="panel panel-wide">
|
|
{% set option_map = form_options|default({}) %}
|
|
{% set combo_custom_option_value = custom_option_value|default('__custom__') %}
|
|
<div class="form-grid resource-form-grid">
|
|
{% for field in fields %}
|
|
{% set current_value = values.get(field.name) %}
|
|
{% set has_error = field_error_map.get(field.name) %}
|
|
{% if field.kind == 'textarea' %}
|
|
<label class="field-span-three{% if has_error %} field-error-shell{% endif %}"{% if has_error %} data-field-error="true"{% endif %}>
|
|
<span class="field-label">{{ field.label }}</span>
|
|
<textarea class="{% if has_error %}field-error-input{% endif %}" name="{{ field.name }}" rows="4">{{ current_value if current_value is not none else '' }}</textarea>
|
|
</label>
|
|
{% elif field.kind == 'checkbox' %}
|
|
<label class="checkbox-row{% if has_error %} field-error-shell{% endif %}"{% if has_error %} data-field-error="true"{% endif %}>
|
|
<input type="checkbox" name="{{ field.name }}" {% if current_value %}checked{% endif %}>
|
|
<span>{{ field.label }}</span>
|
|
</label>
|
|
{% elif field.kind == 'combo' %}
|
|
{% set normalized_value = current_value if current_value is not none else '' %}
|
|
{% set options = option_map.get(field.name, []) %}
|
|
{% set custom_value = '' if not normalized_value or normalized_value in options else normalized_value %}
|
|
<label class="{% if has_error %}field-error-shell{% endif %}"{% if has_error %} data-field-error="true"{% endif %}>
|
|
<span class="field-label">{{ field.label }}</span>
|
|
<select class="{% if has_error %}field-error-input{% endif %}" name="{{ field.name }}" {% if field.required and not custom_value %}required{% endif %}>
|
|
<option value="">请选择</option>
|
|
{% for option in options %}
|
|
<option value="{{ option }}" {% if option == normalized_value %}selected{% endif %}>{{ option }}</option>
|
|
{% endfor %}
|
|
<option value="{{ combo_custom_option_value }}" {% if custom_value %}selected{% endif %}>新增选项</option>
|
|
</select>
|
|
<input
|
|
class="combo-custom-input{% if has_error %} field-error-input{% endif %}"
|
|
type="text"
|
|
name="{{ field.name }}__custom"
|
|
value="{{ custom_value }}"
|
|
placeholder="没有合适选项时,在这里输入新的 {{ field.label }}"
|
|
>
|
|
</label>
|
|
{% else %}
|
|
<label class="{% if has_error %}field-error-shell{% endif %}"{% if has_error %} data-field-error="true"{% endif %}>
|
|
<span class="field-label">{{ field.label }}</span>
|
|
<input
|
|
class="{% if has_error %}field-error-input{% endif %}"
|
|
type="text"
|
|
name="{{ field.name }}"
|
|
value="{{ current_value if current_value is not none else '' }}"
|
|
{% if field.required %}required{% endif %}
|
|
>
|
|
</label>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<div class="button-row top-gap">
|
|
<button class="primary-button" type="submit">{{ submit_label }}</button>
|
|
<a class="secondary-button" href="{{ cancel_url }}">返回</a>
|
|
</div>
|
|
</section>
|
|
</form>
|
|
|
|
{% if delete_url %}
|
|
<section class="panel danger-panel top-gap">
|
|
<p class="small-muted">删除后不可恢复,请谨慎操作。</p>
|
|
<form method="post" action="{{ delete_url }}" class="inline-form" onsubmit="return confirm('{{ delete_confirm or '确认删除?' }}')">
|
|
{% set delete_hidden_field_values = delete_hidden_fields|default(hidden_field_values, true) %}
|
|
{% for name, value in delete_hidden_field_values.items() %}
|
|
<input type="hidden" name="{{ name }}" value="{{ value }}">
|
|
{% endfor %}
|
|
<button class="danger-link" type="submit">{{ delete_label or '删除' }}</button>
|
|
</form>
|
|
</section>
|
|
{% endif %}
|
|
{% include "_validation_dialog.html" %}
|
|
{% endblock %}
|