flat-tree-builder
Advanced tools
Comparing version 1.5.26 to 1.5.27
{ | ||
"name": "flat-tree-builder", | ||
"version": "1.5.26", | ||
"version": "1.5.27", | ||
"description": "A package for building tree structures from postgres ltree data", | ||
@@ -5,0 +5,0 @@ "main": "classifier.mjs", |
@@ -6,3 +6,3 @@ import Sortable from "sortablejs"; | ||
import { createDeleteBtn, createSortElements } from "./utils/UI.js"; | ||
import { settingsIcon, toggleIcon } from "./utils/icons.js"; | ||
import { closeIcon, settingsIcon, toggleIcon } from "./utils/icons.js"; | ||
@@ -283,13 +283,12 @@ export default class Classifier { | ||
selectCheckbox.checked = this.selectedIds.has(item.id); | ||
selectCheckbox.classList.add("visually-hidden"); | ||
// selectCheckbox.classList.add("visually-hidden"); | ||
selectCheckbox.addEventListener("change", () => this.select(item.id)); | ||
selectLabel.classList.add("classifier__name--tick", "cursor-pointer", "classifier__name--hover"); | ||
selectLabel.append(selectCheckbox); | ||
selectLabel.append(selectSpan); | ||
selectLabel.classList.add("classifier__name--tick", "cursor-pointer", "classifier__name--hover", "classifier__select-label"); | ||
selectLabel.append(selectCheckbox, selectSpan); | ||
} | ||
selectLabel.append(selectSpan); | ||
liContainer.append(selectLabel); | ||
if (item.children.length || this.needBtn) liContainer.append(showLabel); | ||
liContainer.append(selectLabel); | ||
@@ -299,3 +298,3 @@ let editBtn; | ||
editBtn = document.createElement("button"); | ||
editBtn.classList.add("classifier__button"); | ||
editBtn.classList.add("classifier__button", "classifier__button--settings"); | ||
editBtn.innerHTML = settingsIcon; | ||
@@ -318,4 +317,3 @@ editBtn.addEventListener("click", () => this.openEditModal(item)); | ||
li.append(liContainer); | ||
li.append(ul); | ||
li.append(liContainer, ul); | ||
parentUl.append(li); | ||
@@ -392,8 +390,11 @@ | ||
this.targetInput.innerHTML = ""; | ||
let i = 0; | ||
this.selectedIds.forEach((id) => { | ||
if (this.data.find((x) => x.id === id)) { | ||
const option = document.createElement("option"); | ||
option.value = id; | ||
option.selected = true; | ||
this.targetInput.append(option); | ||
const input = document.createElement("input"); | ||
input.value = id; | ||
input.name = `article_version[classifiers_attributes][${i}][id]`; | ||
this.targetInput.append(input); | ||
i++; | ||
} | ||
@@ -410,19 +411,14 @@ }); | ||
const btn = document.createElement("button"); | ||
btn.classList.add("classifier__button", "classifier__button--rotated-icon"); | ||
btn.classList.add("classifier__button"); | ||
btn.type = "button"; | ||
btn.addEventListener("click", () => this.deselect(item)); | ||
btn.innerHTML = toggleIcon; | ||
btn.innerHTML = closeIcon; | ||
const span = document.createElement("span"); | ||
span.textContent = this.getName(item[this.path]); | ||
span.textContent = item[this.path]; | ||
const li = document.createElement("li"); | ||
li.classList.add("select-list__item"); | ||
li.classList.add("bg-secondary-subtle"); | ||
li.classList.add("rounded-1"); | ||
li.classList.add("p-1"); | ||
li.append(span); | ||
li.append(btn); | ||
li.classList.add("select-list__item", "bg-secondary-subtle", "rounded-1", "p-1"); | ||
li.append(span, btn); | ||
@@ -429,0 +425,0 @@ this.selectedList.append(li); |
@@ -0,12 +1,19 @@ | ||
// export const toggleIcon = ` | ||
// <?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools --> | ||
// <svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
// <path d="M4 12H20M12 4V20" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
// </svg> | ||
// ` | ||
export const toggleIcon = ` | ||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools --> | ||
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path d="M4 12H20M12 4V20" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
<path d="M6 9L12 15L18 9" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/> | ||
</svg> | ||
` | ||
`; | ||
export const settingsIcon = ` | ||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools --> | ||
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="m4.929 4.93.001-.002.002.001.527-.528a.575.575 0 0 1 .786-.025l1.21 1.061c.332.305.774.492 1.26.492.514 0 .98-.21 1.316-.548.318-.32.52-.754.539-1.235h.004l.105-1.607a.575.575 0 0 1 .574-.537h.746V2v.002h.747c.303 0 .554.235.574.537l.105 1.607h.005c.019.484.223.92.544 1.24.336.335.8.543 1.312.543.492 0 .94-.192 1.272-.504l1.196-1.05a.575.575 0 0 1 .786.026l.528.528.002-.002v.002l-.001.002.528.527a.575.575 0 0 1 .026.786l-1.06 1.212a1.85 1.85 0 0 0-.492 1.258c0 .515.21.98.548 1.317.32.318.753.52 1.235.539v.004l1.606.105c.303.02.538.271.538.574V12H22v.002h-.002v.746a.575.575 0 0 1-.537.574l-1.607.107v.001c-.484.02-.92.223-1.24.544-.335.336-.543.8-.543 1.312 0 .486.187.928.493 1.26h-.002l1.062 1.211c.2.228.188.572-.026.786l-.528.528v.002h-.001l-.528.527a.575.575 0 0 1-.785.026l-1.168-1.021a1.851 1.851 0 0 0-1.302-.534c-.515 0-.98.21-1.317.548-.318.32-.52.755-.54 1.238h-.004l-.105 1.607a.575.575 0 0 1-.54.536H11.22a.575.575 0 0 1-.54-.536l-.105-1.607h-.004a1.851 1.851 0 0 0-.545-1.244 1.851 1.851 0 0 0-1.31-.542c-.504 0-.96.2-1.295.526l-1.177 1.03a.575.575 0 0 1-.785-.027l-.528-.528-.001-.001-.528-.528a.575.575 0 0 1-.026-.786l1.062-1.21-.001-.001a1.85 1.85 0 0 0 .493-1.26c0-.515-.21-.98-.548-1.317a1.85 1.85 0 0 0-1.236-.539v-.001l-1.607-.107a.575.575 0 0 1-.537-.574v-.746H2V12h.001v-.747c0-.303.235-.554.538-.574l1.606-.105v-.004a1.851 1.851 0 0 0 1.242-.545c.335-.336.542-.8.542-1.31 0-.49-.19-.935-.499-1.267L4.376 6.244a.575.575 0 0 1 .026-.786l.528-.527-.001-.002zM16.286 12a4.286 4.286 0 1 1-8.572 0 4.286 4.286 0 0 1 8.572 0z" fill="#000000"/></svg> | ||
` | ||
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="m4.929 4.93.001-.002.002.001.527-.528a.575.575 0 0 1 .786-.025l1.21 1.061c.332.305.774.492 1.26.492.514 0 .98-.21 1.316-.548.318-.32.52-.754.539-1.235h.004l.105-1.607a.575.575 0 0 1 .574-.537h.746V2v.002h.747c.303 0 .554.235.574.537l.105 1.607h.005c.019.484.223.92.544 1.24.336.335.8.543 1.312.543.492 0 .94-.192 1.272-.504l1.196-1.05a.575.575 0 0 1 .786.026l.528.528.002-.002v.002l-.001.002.528.527a.575.575 0 0 1 .026.786l-1.06 1.212a1.85 1.85 0 0 0-.492 1.258c0 .515.21.98.548 1.317.32.318.753.52 1.235.539v.004l1.606.105c.303.02.538.271.538.574V12H22v.002h-.002v.746a.575.575 0 0 1-.537.574l-1.607.107v.001c-.484.02-.92.223-1.24.544-.335.336-.543.8-.543 1.312 0 .486.187.928.493 1.26h-.002l1.062 1.211c.2.228.188.572-.026.786l-.528.528v.002h-.001l-.528.527a.575.575 0 0 1-.785.026l-1.168-1.021a1.851 1.851 0 0 0-1.302-.534c-.515 0-.98.21-1.317.548-.318.32-.52.755-.54 1.238h-.004l-.105 1.607a.575.575 0 0 1-.54.536H11.22a.575.575 0 0 1-.54-.536l-.105-1.607h-.004a1.851 1.851 0 0 0-.545-1.244 1.851 1.851 0 0 0-1.31-.542c-.504 0-.96.2-1.295.526l-1.177 1.03a.575.575 0 0 1-.785-.027l-.528-.528-.001-.001-.528-.528a.575.575 0 0 1-.026-.786l1.062-1.21-.001-.001a1.85 1.85 0 0 0 .493-1.26c0-.515-.21-.98-.548-1.317a1.85 1.85 0 0 0-1.236-.539v-.001l-1.607-.107a.575.575 0 0 1-.537-.574v-.746H2V12h.001v-.747c0-.303.235-.554.538-.574l1.606-.105v-.004a1.851 1.851 0 0 0 1.242-.545c.335-.336.542-.8.542-1.31 0-.49-.19-.935-.499-1.267L4.376 6.244a.575.575 0 0 1 .026-.786l.528-.527-.001-.002zM16.286 12a4.286 4.286 0 1 1-8.572 0 4.286 4.286 0 0 1 8.572 0z" fill="currentColor"/></svg> | ||
`; | ||
@@ -16,5 +23,5 @@ export const sortIcon = ` | ||
<svg width="800px" height="800px" viewBox="-2 -2 28 28" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path d="M7 3V21M7 3L11 7M7 3L3 7M15.5 14H20.5L15.5 21H20.5M16 9H20M15 10L18 3L21 10" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
<path d="M7 3V21M7 3L11 7M7 3L3 7M15.5 14H20.5L15.5 21H20.5M16 9H20M15 10L18 3L21 10" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
</svg> | ||
` | ||
`; | ||
@@ -24,8 +31,13 @@ export const deleteIcon = ` | ||
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path d="M10 11V17" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
<path d="M14 11V17" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
<path d="M4 7H20" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
<path d="M6 7H12H18V18C18 19.6569 16.6569 21 15 21H9C7.34315 21 6 19.6569 6 18V7Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
<path d="M9 5C9 3.89543 9.89543 3 11 3H13C14.1046 3 15 3.89543 15 5V7H9V5Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
<path d="M10 11V17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
<path d="M14 11V17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
<path d="M4 7H20" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
<path d="M6 7H12H18V18C18 19.6569 16.6569 21 15 21H9C7.34315 21 6 19.6569 6 18V7Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
<path d="M9 5C9 3.89543 9.89543 3 11 3H13C14.1046 3 15 3.89543 15 5V7H9V5Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> | ||
</svg> | ||
` | ||
`; | ||
export const closeIcon = ` | ||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools --> | ||
<svg width="800px" height="800px" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"/></svg> | ||
`; |
@@ -97,3 +97,3 @@ export const searchMarkup = ` | ||
id: 3345265652346, | ||
path: "Первый.а", | ||
path: "Первый.Вложенный_2", | ||
created_at: "2023-11-17T17:41:37.682+03:00", | ||
@@ -106,3 +106,3 @@ updated_at: "2023-11-17T20:52:09.607+03:00", | ||
id: 12312333, | ||
path: "Первый.б", | ||
path: "Первый.Вложенный_1", | ||
created_at: "2023-11-17T17:41:37.682+03:00", | ||
@@ -109,0 +109,0 @@ updated_at: "2023-11-17T20:52:09.607+03:00", |
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
Sorry, the diff of this file is not supported yet
174969
4476