Skip to content

Commit

Permalink
Merge pull request #8534 from google/tag-no-dups
Browse files Browse the repository at this point in the history
tags.html: don't allow users to enter duplicate tags
  • Loading branch information
m4rc1e authored Nov 22, 2024
2 parents f5dd6c0 + d4ed13f commit e6122fc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .ci/tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -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", "Ζαφείρι δέξου πάγκαλο, βαθῶν ψυχῆς τὸ σῆμα"],
Expand Down Expand Up @@ -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}`);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e6122fc

Please sign in to comment.