Skip to content

Commit

Permalink
Merge pull request #33 from moevm/manucharova_edit
Browse files Browse the repository at this point in the history
add duplicate name property
  • Loading branch information
necitboss authored Dec 22, 2024
2 parents fc917de + 4e0703f commit 8294223
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions main/_front/src/js/add-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,22 @@ const addProperty = (element, name, value) => {
}
}


const property_btn = document.querySelector("#property_btn");
property_btn.addEventListener('click', (e) => {
let otherPropertiesArray = []
other_properties.querySelectorAll(".property").forEach(property => {
otherPropertiesArray.push(property.querySelector(".property__name").textContent)
})
console.log(otherPropertiesArray);
for (let i = 0; i < otherPropertiesArray.length; i++) {
console.log(input_property_name.value.trim())
console.log(otherPropertiesArray[i])
if (input_property_name.value.trim() === otherPropertiesArray[i].trim()){
alert("Нельзя добавить свойство с таким же именем")
return;
}
}
const input_name = input_property_name.value;
const input_value = input_property_value.value;
if (input_name !== "" && input_value !== "") {
Expand Down

0 comments on commit 8294223

Please sign in to comment.