FossilRepo

fossilrepo / templates / fossil / ticket_fields_form.html
1
{% extends "base.html" %}
2
{% block title %}{{ form_title }} — {{ project.name }} — Fossilrepo{% endblock %}
3
4
{% block content %}
5
<h1 class="text-2xl font-bold text-gray-100 mb-2">{{ project.name }}</h1>
6
{% include "fossil/_project_nav.html" %}
7
8
<div class="mb-4">
9
<a href="{% url 'fossil:ticket_fields' slug=project.slug %}" class="text-sm text-brand-light hover:text-brand">&larr; Back to Custom Fields</a>
10
</div>
11
12
<div class="mx-auto max-w-2xl">
13
<h2 class="text-xl font-bold text-gray-100 mb-4">{{ form_title }}</h2>
14
15
<form method="post" class="space-y-4 rounded-lg bg-gray-800 p-6 shadow border border-gray-700">
16
{% csrf_token %}
17
18
<div class="grid grid-cols-2 gap-4">
19
<div>
20
<label class="block text-sm font-medium text-gray-300 mb-1">Field Name <span class="text-red-400">*</span></label>
21
<input type="text" name="name" required placeholder="e.g. component"
22
value="{% if field_def %}{{ field_def.name }}{% endif %}"
23
pattern="[a-zA-Z_][a-zA-Z0-9_]*"
24
title="Letters, numbers, and underscores only. Must start with a letter or underscore."
25
class="w-full rounded-md border-gray-700 bg-gray-800 text-gray-100 shadow-sm focus:border-brand focus:ring-brand sm:text-sm font-mono">
26
<p class="mt-1 text-xs text-gray-500">Internal name used in the Fossil ticket table. Alphanumeric and underscores only.</p>
27
</div>
28
<div>
29
<label class="block text-sm font-medium text-gray-300 mb-1">Display Label <span class="text-red-400">*</span></label>
30
<input type="text" name="label" required placeholder="e.g. Component"
31
value="{% if field_def %}{{ field_def.label }}{% endif %}"
32
class="w-full rounded-md border-gray-700 bg-gray-800 text-gray-100 shadow-sm focus:border-brand focus:ring-brand sm:text-sm">
33
</div>
34
</div>
35
36
<div class="grid grid-cols-2 gap-4">
37
<div>
38
<label class="block text-sm font-medium text-gray-300 mb-1">Field Type</label>
39
<select name="field_type" id="field-type-select"
40
class="w-full rounded-md border-gray-700 bg-gray-800 text-gray-100 shadow-sm focus:border-brand focus:ring-brand sm:text-sm">
41
{% for value, label in field_type_choices %}
42
<option value="{{ value }}" {% if field_def and field_def.field_type == value %}selected{% endif %}>{{ label }}</option>
43
{% endfor %}
44
</select>
45
</div>
46
<div>
47
<label class="block text-sm font-medium text-gray-300 mb-1">Sort Order</label>
48
<input type="number" name="sort_order" value="{% if field_def %}{{ field_def.sort_order }}{% else %}0{% endif %}"
49
class="w-full rounded-md border-gray-700 bg-gray-800 text-gray-100 shadow-sm focus:border-brand focus:ring-brand sm:text-sm">
50
<p class="mt-1 text-xs text-gray-500">Lower numbers appear first.</p>
51
</div>
52
</div>
53
54
<div x-data="{ showChoices: '{% if field_def %}{{ field_def.field_type }}{% else %}text{% endif %}' === 'select' }">
55
<div x-show="showChoices" x-transition>
56
<label class="block text-sm font-medium text-gray-300 mb-1">Choices</label>
57
<textarea name="choices" rows="5" placeholder="One option per line"
58
class="w-full rounded-md border-gray-700 bg-gray-800 text-gray-100 shadow-sm focus:border-brand focus:ring-brand sm:text-sm font-mono">{% if field_def %}{{ field_def.choices }}{% endif %}</textarea>
59
<p class="mt-1 text-xs text-gray-500">One option per line. Only used for Select fields.</p>
60
</div>
61
<script>
62
document.getElementById('field-type-select').addEventListener('change', function() {
63
const comp = document.querySelector('[x-data]').__x.$data;
64
comp.showChoices = this.value === 'select';
65
});
66
</script>
67
</div>
68
69
<label class="flex items-center gap-2 text-sm text-gray-300 cursor-pointer">
70
<input type="checkbox" name="is_required"
71
{% if field_def and field_def.is_required %}checked{% endif %}
72
class="rounded border-gray-600 bg-gray-900 text-brand focus:ring-brand">
73
Required field
74
</label>
75
76
<div class="flex justify-end gap-3 pt-2">
77
<a href="{% url 'fossil:ticket_fields' slug=project.slug %}"
78
class="rounded-md bg-gray-700 px-4 py-2 text-sm font-semibold text-gray-100 shadow-sm ring-1 ring-inset ring-gray-600 hover:bg-gray-600">
79
Cancel
80
</a>
81
<button type="submit" class="rounded-md bg-brand px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-brand-hover">
82
{{ submit_label }}
83
</button>
84
</div>
85
</form>
86
</div>
87
{% endblock %}
88

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button