From d4ed13f489b7c78cf8bb78822b05ce68db714da8 Mon Sep 17 00:00:00 2001 From: Marc Foley Date: Fri, 22 Nov 2024 14:39:37 +0000 Subject: [PATCH] tags.html: don't allow users to enter duplicate tags --- .ci/tags.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.ci/tags.html b/.ci/tags.html index 6bf7a8428f..12fcec9aae 100644 --- a/.ci/tags.html +++ b/.ci/tags.html @@ -157,6 +157,7 @@ CurrentCategory: "/Expressive/Calm", Categories: new Set(), Families: [], + Seen: new Set(), Pangrams: new Map([ ["English", "The quick brown fox jumps over the lazy dog."], ["Greek", "Ζαφείρι δέξου πάγκαλο, βαθῶν ψυχῆς τὸ σῆμα"], @@ -307,6 +308,11 @@ AddFamily() { this.isEdited = true; let newFamily = { Weight: this.newWeight, Family: this.newFamily, "Group/Tag": this.CurrentCategory } + let tagKey = `${newFamily.Family},${newFamily["Group/Tag"]}`; + if (this.Seen.has(tagKey)) { + alert(`Tag "${newFamily.Family}" already exists in "${this.CurrentCategory}"`); + return; + } this.Families.push(newFamily); this.history.push(`+ ${newFamily.Family},${newFamily["Group/Tag"]},${newFamily.Weight}`); @@ -397,6 +403,16 @@ header: true, complete: (results) => { this.Categories = new Set(results.data.map((row) => row["Group/Tag"])); + results.data.map((row) => { + this.Seen.add(`${row.Family},${row["Group/Tag"]}`); + this.Families.push( + { + Family: row.Family, + "Group/Tag": row["Group/Tag"], + Weight: parseInt(row.Weight, 10) + } + ) + }); this.Families = results.data.map((row) => ({ Weight: row.Weight, Family: row.Family,