mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
Javascript code linting
This commit is contained in:
@@ -5,15 +5,15 @@ export default class extends Controller {
|
||||
|
||||
addTag() {
|
||||
// Check if tag already exist
|
||||
const newTagName = this.newTagTarget.value
|
||||
const newTagName = this.newTagTarget.value;
|
||||
const tags = this.tagListTarget.value.split(",");
|
||||
const index = tags.indexOf(newTagName);
|
||||
if (index != -1) {
|
||||
// highlight the value in red
|
||||
this.newTagTarget.classList.add("tag-error")
|
||||
return
|
||||
}
|
||||
|
||||
this.newTagTarget.classList.add("tag-error");
|
||||
return;
|
||||
}
|
||||
|
||||
// add to tagList
|
||||
this.tagListTarget.value = this.tagListTarget.value.concat(`,${newTagName}`);
|
||||
|
||||
@@ -47,9 +47,9 @@ export default class extends Controller {
|
||||
filterInput(event) {
|
||||
// clear error class if key is not enter
|
||||
if (event.key !== "Enter") {
|
||||
this.newTagTarget.classList.remove("tag-error")
|
||||
this.newTagTarget.classList.remove("tag-error");
|
||||
}
|
||||
|
||||
|
||||
// Strip comma from tag name
|
||||
if (event.key === ",") {
|
||||
event.srcElement.value = event.srcElement.value.replace(",", "");
|
||||
|
||||
Reference in New Issue
Block a user