Create food kinds in Settings only, not from the Ate dialog
Inventing a kind mid-log put list-keeping in the middle of logging, where the thing you came to do is record that the dog ate. A name typed in a hurry is also easy to get slightly wrong, and nothing enforces unique names — so the cost of a typo is a near-duplicate kind that can only be cleared up by relabelling every meal logged under it first. The dialog still picks from the kinds that exist, unchanged. This drops the new-kind row from it, both its handlers, and the guest guard that existed only to keep that row out of a guest's hands. addFoodKind now has a single caller, in Settings. Also drops the sentence advertising the removed box from the changelog entry that shipped it: that banner is what someone upgrading across several versions reads, so leaving it would describe a field that is no longer there.
This commit is contained in:
1 parent
fab0ae1420
commit
a0cdc1f669
3 files changed
+4
-25
No files matched your search
+2
-20
@@ -3884,11 +3884,9 @@
|
||||
const noteGramsField = document.getElementById("note-grams-field");
|
||||
const noteKindField = document.getElementById("note-kind-field");
|
||||
const noteKindPicker = document.getElementById("note-kind-picker");
|
||||
const noteKindNew = document.getElementById("note-kind-new");
|
||||
const noteKindName = document.getElementById("note-kind-name");
|
||||
// Which kind the dialog currently has selected. Held here rather than read
|
||||
// off the DOM so the picker can be redrawn (after adding a kind) without
|
||||
// losing the choice.
|
||||
// off the DOM, so redrawing the picker to move the active chip does not lose
|
||||
// the choice.
|
||||
let notePickedKind = NO_KIND;
|
||||
|
||||
function drawNoteKindPicker() {
|
||||
@@ -3898,20 +3896,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Inventing a kind mid-log: it is created, selected, and the box clears, so
|
||||
// you carry on logging the meal you came here for.
|
||||
document.getElementById("note-kind-add").addEventListener("click", () => {
|
||||
const name = noteKindName.value.trim();
|
||||
if (!name) return;
|
||||
notePickedKind = addFoodKind(name).id;
|
||||
noteKindName.value = "";
|
||||
drawNoteKindPicker();
|
||||
});
|
||||
noteKindName.addEventListener("keydown", (e) => {
|
||||
if (e.key !== "Enter") return;
|
||||
e.preventDefault(); // the dialog's default button would otherwise save
|
||||
document.getElementById("note-kind-add").click();
|
||||
});
|
||||
const noteGrams = document.getElementById("note-grams");
|
||||
let pendingType = null;
|
||||
let notePhotos = []; // pending photos for this dialog: [{ blob, url }]
|
||||
@@ -3992,8 +3976,6 @@
|
||||
// A new meal starts on whichever kind is the default, which may well be no
|
||||
// kind — that is the starting state and stays a legitimate choice.
|
||||
notePickedKind = defaultFoodKindId();
|
||||
noteKindNew.hidden = isGuest(); // inventing a kind is the owner's
|
||||
noteKindName.value = "";
|
||||
if (isEat) drawNoteKindPicker();
|
||||
else noteKindField.hidden = true;
|
||||
clearNotePhotos();
|
||||
|
||||
Reference in new issue
Block a user