]> git.ipfire.org Git - thirdparty/google/fonts.git/commitdiff
tags.html: don't allow users to enter duplicate tags 8534/head
authorMarc Foley <m.foley.88@gmail.com>
Fri, 22 Nov 2024 14:39:37 +0000 (14:39 +0000)
committerMarc Foley <m.foley.88@gmail.com>
Fri, 22 Nov 2024 14:39:37 +0000 (14:39 +0000)
.ci/tags.html

index 6bf7a8428f0006cda1be85cb9727e42df6f01757..12fcec9aaee672d0ea14694c1515cfcb4d2dd3c8 100644 (file)
         CurrentCategory: "/Expressive/Calm",
         Categories: new Set(),
         Families: [],
+        Seen: new Set(),
         Pangrams: new Map([
           ["English", "The quick brown fox jumps over the lazy dog."],
           ["Greek", "Ζαφείρι δέξου πάγκαλο, βαθῶν ψυχῆς τὸ σῆμα"],
       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}`);
               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,