classifier-tree-builder
v1.1.2
Published
A package for building tree structures from postgres ltree data
Downloads
709
Readme
Classifier
Only for es module, only for Postgres ltree data
Testing
npm i
npm t
Integration
Download
npm i flat-tree-builder
html
- Create an element on the page where the element will be embedded, assign an id to the element
js
- Import the Classifier class from classifier.js
- Create an instance of the Classifier class, where the first parameter is the item id and the second parameter is the object with the parameters
css
- Connect the classifier.css file
- Connect bootstrap
Params object
- getUrl: url for get
- postClassifierUrl: url for post
- delUrl: url for delete, default: postClassifierUrl
- selectedIds: array of id's to be drawn initially
- path: tree line, default: 'tree_path'
- search: if the classifier is used for searching, type: Boolean, default: false
- test: run with test data, type: Boolean, default: false
- draggable: ability to drag and drop list items, type: Boolean, default: false
- isRootSelectable: ability to select a root classifier, type: Boolean, default: true
Example
<link
rel="stylesheet"
href="./node_modules/bootstrap/dist/css/bootstrap.min.css"
/>
<link rel="stylesheet" href="./node_modules/flat-tree-builder/classifier.css" />
<div id="test"></div>
import Classifier from "flat-tree-builder";
const classifier = new Classifier("#test", {
test: true,
search: true,
});
API
- toggleManual(id) - open or close the classifier with the passed id
- fillModalForm(text) - fill the field in the modal window with text from the parameters
- clickModalBtn() - simulates clicking the send button in a modal window
- getModalFormValue() - gets a string from a form in a modal window
- findById(id) - returns html element bound to id