flat-tree-builder
Advanced tools
Comparing version 1.5.9 to 1.5.10
{ | ||
"name": "flat-tree-builder", | ||
"version": "1.5.9", | ||
"version": "1.5.10", | ||
"description": "A package for building tree structures from postgres ltree data", | ||
@@ -5,0 +5,0 @@ "main": "classifier.mjs", |
27
src.js
@@ -98,3 +98,3 @@ import Sortable from "sortablejs"; | ||
<input class="form-control" type="text" placeholder="Название" /> | ||
<small class="feedback text-danger"></small> | ||
<ul class="feedback text-danger"></ul> | ||
<button | ||
@@ -202,3 +202,3 @@ class="btn btn-primary classifier__modal-btn mt-2 float-end" | ||
this.modalInput.value = ""; | ||
this.setModalFeedback(""); | ||
this.setModalFeedback(); | ||
this.modalButton.textContent = "Создать"; | ||
@@ -212,3 +212,3 @@ this.modalButton.onclick = this.new.bind(this); | ||
this.modalInput.value = this.getName(item.tree_path); | ||
this.setModalFeedback(""); | ||
this.setModalFeedback(); | ||
this.modalButton.textContent = "Сохранить"; | ||
@@ -492,4 +492,14 @@ this.modalButton.onclick = this.edit.bind(this); | ||
setModalFeedback(text) { | ||
this.modalFeedback.textContent = text; | ||
setModalFeedback(errors) { | ||
this.modalFeedback.textContent = ""; | ||
if (!errors) { | ||
return; | ||
} | ||
errors.forEach((error) => { | ||
const li = document.createElement("li"); | ||
li.textContent = error; | ||
this.modalFeedback.append(li); | ||
}); | ||
} | ||
@@ -522,3 +532,3 @@ | ||
} catch (error) { | ||
this.setModalFeedback("Error"); | ||
this.setModalFeedback(["Error"]); | ||
console.error(error); | ||
@@ -557,5 +567,8 @@ } finally { | ||
this.hideModal(); | ||
} else { | ||
const json = await response.json(); | ||
this.setModalFeedback(json.tree_path); | ||
} | ||
} catch (error) { | ||
this.setModalFeedback("Error"); | ||
this.setModalFeedback(["Error"]); | ||
console.error(error); | ||
@@ -562,0 +575,0 @@ } finally { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
178062
4706