li7y/templates/item_class_edit.html
2024-07-11 01:16:37 +02:00

53 lines
1.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{#
SPDX-FileCopyrightText: 2024 Simon Bruder <simon@sbruder.de>
SPDX-License-Identifier: AGPL-3.0-or-later
#}
{% extends "base.html" %}
{% block title %}{% block page_title %}{{ item_class.name }}{% endblock %} Edit Item Class {{ branding }}{% endblock %}
{% block main %}
<form method="POST">
<div class="mb-3">
<label for="uuid" class="form-label">UUID</label>
<input type="text" class="form-control" id="uuid" disabled required value="{{ item_class.id }}">
</div>
<div class="mb-3">
<label for="name" class="form-label">Name</label>
<input type="text" class="form-control" id="name" name="name" required value="{{ item_class.name }}">
</div>
<div class="mb-3">
<label for="type" class="form-label">Type</label>
<select class="form-select" id="type" name="type" required value="{{ item_class.type }}">
{% 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"{% if let Some(parent) = item_class.parent %} value="{{ parent }}"{% else %} disabled{% endif %}>
</div>
<button type="submit" class="btn btn-primary">Edit</button>
</form>
<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 %}