feat: improve mission asset operations
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
</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() %}
|
||||
@@ -22,13 +24,14 @@
|
||||
<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">
|
||||
<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 name="{{ field.name }}" rows="4">{{ current_value if current_value is not none else '' }}</textarea>
|
||||
<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">
|
||||
<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>
|
||||
@@ -36,9 +39,9 @@
|
||||
{% 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>
|
||||
<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 name="{{ field.name }}" {% if field.required and not custom_value %}required{% endif %}>
|
||||
<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>
|
||||
@@ -46,7 +49,7 @@
|
||||
<option value="{{ combo_custom_option_value }}" {% if custom_value %}selected{% endif %}>新增选项</option>
|
||||
</select>
|
||||
<input
|
||||
class="combo-custom-input"
|
||||
class="combo-custom-input{% if has_error %} field-error-input{% endif %}"
|
||||
type="text"
|
||||
name="{{ field.name }}__custom"
|
||||
value="{{ custom_value }}"
|
||||
@@ -54,9 +57,10 @@
|
||||
>
|
||||
</label>
|
||||
{% else %}
|
||||
<label>
|
||||
<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 '' }}"
|
||||
@@ -86,4 +90,5 @@
|
||||
</form>
|
||||
</section>
|
||||
{% endif %}
|
||||
{% include "_validation_dialog.html" %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user