li7y/templates/item_class_add.html

51 lines
1.7 KiB
HTML
Raw Normal View History

2024-07-07 13:48:31 +02:00
{#
SPDX-FileCopyrightText: 2024 Simon Bruder <simon@sbruder.de>
SPDX-License-Identifier: AGPL-3.0-or-later
#}
{% extends "base.html" %}
{% block title %}{% block page_title %}Add Item Class{% endblock %} {{ branding }}{% endblock %}
{% block main %}
<form method="POST">
<div class="mb-3">
<label for="name" class="form-label">Name</label>
<input type="text" class="form-control" id="name" name="name" required{% if let Some(data) = data %} value="{{ data.name }}"{% endif %}>
</div>
<div class="mb-3">
<label for="type" class="form-label">Type</label>
<select class="form-select" id="type" name="type" required{% if let Some(data) = data %} value="{{ data.type }}"{% endif %}>
{% for variant in ItemClassType::VARIANTS %}
<option>{{ variant }}</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label for="parent" class="form-label">Parent</label>
<input type="text" class="form-control" id="parent" name="parent" disabled{% if let Some(data) = data %}{% if let Some(parent) = data.parent %} value="{{ parent }}"{% endif %}{% endif %}>
</div>
<button type="submit" class="btn btn-primary">Add</button>
</form>
{% endblock %}
{% block extra_scripts %}
<script>
(() => {
document.getElementById("type").addEventListener("change", e => {
console.log(e)
let parentInput = document.getElementById("parent")
switch (e.target.value) {
case "generic":
parentInput.disabled = true
parentInput.value = ""
break
case "specific":
parentInput.disabled = false
break
default:
console.error("invalid type!")
}
})
})()
</script>
{% endblock %}