Code Monkey home page Code Monkey logo

term_tree_selector's Introduction

Term Tree Selector

Provides configurable root/leaf selector blocks for term trees with 2 or 3 levels.

Terms will only show in the selector if they are published and have content.

Installation

Once enabled, you can place one or more "Term Tree Selector" blocks with the following configuration:

Vocabulary: The hierarchical vocabulary to use

Root Label: The label for the root terms, e.g. "Make", used to display "Select Make" in the root select box.

Leaf Label: The label for the leaf terms, e.g. "Model", used to display "Select Model" in the leaf select box.

Leaf Level: The number levels to traverse to populate the leaf select box (Second, Third or All). "All" will show the second and third levels.

Description (optional): Text that will be displayed above the form

Submit Label: The text shown on the submit button

Auto Submit: If checked the form will automatically be submitted once a leaf has been selected

REST Endpoint

The following REST Export endpoint is provided by the "Term Tree Selector" view.

Root terms

/term-tree-selector/{vocabulary}/level/{level}

Returns the root level terms for provided vocabulary and level.

  • Parameters
    • vocabulary (string) - Vocabulary machine name
    • level - Leaf level to show (2,3,all)

Retrieve Root Terms [GET]

  • Response 200 (application/json)

    • Body

        [
          {
            "name": "Ford"
            "tid": 123,
            "url": "/ford"
          }
        ]
      

Leaf terms

/term-tree-selector/{vocabulary}/level/{level}/{tid}

Returns the leaf level terms for provided vocabulary, parent root ID and level.

  • Parameters
    • vocabulary (string) - Vocabulary machine name
    • level - Leaf level to show (2,3,all)
    • tid (number) - Term ID of the root term

Retrieve Leaf Terms [GET]

  • Response 200 (application/json)

    • Body

        [
          {
            "name": "Ford Focus"
            "tid": 456,
            "url": "/ford/focus"
          }
        ]
      

JavaScript Events

onTermTreeSelectorChange

Fired when the root or leaf element changes.

JSON data is passed as a property in the detail object.

Example usage:
  document.addEventListener('onTermTreeSelectorChange', function (e) {
     var data = e.detail.data;
     var options = e.target.options;
  }, false);

term_tree_selector's People

Contributors

davidgrayston avatar peteratdennis avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.