Update web/templates/entry_edit.html
This commit is contained in:
parent
681d138558
commit
b264bd8ede
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block body_class %}themed-bg{% endblock %}
|
{% block body_class %}themed-bg{% endblock %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
@ -18,84 +17,84 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Card -->
|
<!-- Card -->
|
||||||
<div class="card entry-form modern-form">
|
<div class="card entry-form modern-form" style="padding: 24px;">
|
||||||
<form id="entry-edit-form" method="post">
|
<form id="entry-edit-form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
<div class="f-grid">
|
<div class="f-grid">
|
||||||
<div class="f-row">
|
<div class="f-row">
|
||||||
<div class="f-label">Subject</div>
|
<div class="f-label" style="font-weight: 600; font-size: 1.05em;">Subject</div>
|
||||||
<div class="f-control">
|
<div class="f-control">
|
||||||
{{ form.subject }}
|
{{ form.subject }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="f-row tall">
|
<div class="f-row tall">
|
||||||
<div class="f-label">Illustration</div>
|
<div class="f-label" style="font-weight: 600; font-size: 1.05em;">Illustration</div>
|
||||||
<div class="f-control">
|
<div class="f-control">
|
||||||
{{ form.illustration }}
|
{{ form.illustration }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="f-row tall">
|
<div class="f-row tall">
|
||||||
<div class="f-label">Application</div>
|
<div class="f-label" style="font-weight: 600; font-size: 1.05em;">Application</div>
|
||||||
<div class="f-control">
|
<div class="f-control">
|
||||||
{{ form.application }}
|
{{ form.application }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="f-row">
|
<div class="f-row">
|
||||||
<div class="f-label">Scripture</div>
|
<div class="f-label" style="font-weight: 600; font-size: 1.05em;">Scripture</div>
|
||||||
<div class="f-control">
|
<div class="f-control">
|
||||||
{{ form.scripture_raw }}
|
{{ form.scripture_raw }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="f-row">
|
<div class="f-row">
|
||||||
<div class="f-label">Source</div>
|
<div class="f-label" style="font-weight: 600; font-size: 1.05em;">Source</div>
|
||||||
<div class="f-control">
|
<div class="f-control">
|
||||||
{{ form.source }}
|
{{ form.source }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="f-row">
|
<div class="f-row">
|
||||||
<div class="f-label">Talk Title</div>
|
<div class="f-label" style="font-weight: 600; font-size: 1.05em;">Talk Title</div>
|
||||||
<div class="f-control">
|
<div class="f-control">
|
||||||
{{ form.talk_title }}
|
{{ form.talk_title }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="f-row">
|
<div class="f-row">
|
||||||
<div class="f-label">Talk Number</div>
|
<div class="f-label" style="font-weight: 600; font-size: 1.05em;">Talk Number</div>
|
||||||
<div class="f-control">
|
<div class="f-control">
|
||||||
{{ form.talk_number }}
|
{{ form.talk_number }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="f-row">
|
<div class="f-row">
|
||||||
<div class="f-label">Entry Code</div>
|
<div class="f-label" style="font-weight: 600; font-size: 1.05em;">Entry Code</div>
|
||||||
<div class="f-control">
|
<div class="f-control">
|
||||||
{{ form.entry_code }}
|
{{ form.entry_code }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="f-row">
|
<div class="f-row">
|
||||||
<div class="f-label">Date Added</div>
|
<div class="f-label" style="font-weight: 600; font-size: 1.05em;">Date Added</div>
|
||||||
<div class="f-control">
|
<div class="f-control">
|
||||||
{{ form.date_added }}
|
{{ form.date_added }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="f-row">
|
<div class="f-row">
|
||||||
<div class="f-label">Date Edited</div>
|
<div class="f-label" style="font-weight: 600; font-size: 1.05em;">Date Edited</div>
|
||||||
<div class="f-control">
|
<div class="f-control">
|
||||||
{{ form.date_edited }}
|
{{ form.date_edited }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- bottom actions (hidden by CSS if you prefer only the top bar) -->
|
<!-- bottom actions -->
|
||||||
<div class="form-actions bottom-actions">
|
<div class="form-actions bottom-actions" style="margin-top: 20px;">
|
||||||
<a class="btn btn-secondary" href="{% url 'entry_view' entry.id %}">Cancel</a>
|
<a class="btn btn-secondary" href="{% url 'entry_view' entry.id %}">Cancel</a>
|
||||||
<button class="btn btn-primary">Save</button>
|
<button class="btn btn-primary">Save</button>
|
||||||
</div>
|
</div>
|
||||||
@ -103,10 +102,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Talk title auto-fill (same behavior as entry_add) -->
|
<!-- Talk title auto-fill -->
|
||||||
<script>
|
<script>
|
||||||
(function () {
|
(function () {
|
||||||
// Location of your mapping file
|
|
||||||
const talksUrl = "{% static 'talks.json' %}";
|
const talksUrl = "{% static 'talks.json' %}";
|
||||||
|
|
||||||
function wireAutofill(talkMap) {
|
function wireAutofill(talkMap) {
|
||||||
@ -114,13 +112,11 @@
|
|||||||
const titleEl = document.getElementById("id_talk_title");
|
const titleEl = document.getElementById("id_talk_title");
|
||||||
if (!numberEl || !titleEl) return;
|
if (!numberEl || !titleEl) return;
|
||||||
|
|
||||||
// Consider "-" or "—" as empty (lets autofill replace them)
|
|
||||||
const isEffectivelyEmpty = (s) => {
|
const isEffectivelyEmpty = (s) => {
|
||||||
const t = (s || "").trim();
|
const t = (s || "").trim();
|
||||||
return t === "" || t === "-" || t === "—";
|
return t === "" || t === "-" || t === "—";
|
||||||
};
|
};
|
||||||
|
|
||||||
// Track if user has typed something custom
|
|
||||||
let userTyped = false;
|
let userTyped = false;
|
||||||
|
|
||||||
titleEl.addEventListener("input", () => {
|
titleEl.addEventListener("input", () => {
|
||||||
@ -137,18 +133,14 @@
|
|||||||
titleEl.value = mapped;
|
titleEl.value = mapped;
|
||||||
titleEl.dataset.autofilled = "1";
|
titleEl.dataset.autofilled = "1";
|
||||||
} else if (titleEl.dataset.autofilled === "1") {
|
} else if (titleEl.dataset.autofilled === "1") {
|
||||||
// Previously autofilled but new number has no title: clear it
|
|
||||||
titleEl.value = "";
|
titleEl.value = "";
|
||||||
titleEl.dataset.autofilled = "0";
|
titleEl.dataset.autofilled = "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change -> try to fill
|
|
||||||
numberEl.addEventListener("change", maybeAutofill);
|
numberEl.addEventListener("change", maybeAutofill);
|
||||||
|
|
||||||
// Initial fill on page load:
|
|
||||||
// If current title is empty/hyphen, allow autofill; otherwise respect user text
|
|
||||||
if (isEffectivelyEmpty(titleEl.value)) {
|
if (isEffectivelyEmpty(titleEl.value)) {
|
||||||
userTyped = false;
|
userTyped = false;
|
||||||
maybeAutofill();
|
maybeAutofill();
|
||||||
@ -157,7 +149,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the mapping; if it fails, no worries—form still works
|
|
||||||
fetch(talksUrl, {cache: "no-store"})
|
fetch(talksUrl, {cache: "no-store"})
|
||||||
.then(r => r.ok ? r.json() : {})
|
.then(r => r.ok ? r.json() : {})
|
||||||
.then(map => wireAutofill(map))
|
.then(map => wireAutofill(map))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user