Skip to content

programmfabrik/fylr-plugin-numeric-id-auto-incrementer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This Plugin / Repo is being maintained by a community of developers. There is no warranty given or bug fixing guarantee; especially not by Programmfabrik GmbH. Please use the GitHub issue tracking to report bugs and self organize bug fixing. Feel free to directly contact the committing developers.

Numeric ID auto incrementer plugin

This server plugin for fylr allows automatically setting the values of numeric ID fields when saving data. IDs are assigned in numerical order starting from 1. Optionally, the incrementation can be performed separately for each combination of values present in a defined set of base fields (see first example below).

Please note that the ID field as well as all base fields are expected to be either grouped inside the same nested field or located at the root level of the object.

IDs can be generated with the same incrementer used for multiple object types if the path to the ID field (and base fields, if present) are the same (see second example below).

Installation

The latest version of this plugin can be found here.

The ZIP can be downloaded and installed using the plugin manager, or used directly (recommended).

Usage

For the plugin to work, a new object type has to be created. This object type needs to have two fields "incrementer_id" and "incrementer_map" (both text fields). All users that will interact with the plugin need to have read and write access for this object type.

Configuration

All plugin configuration takes place in base configuration.

  • Incrementer object type: The object type that has been created for usage with the plugin
  • Incrementers:
    • Incrementer ID: The unique ID of this specific incrementer
    • Object types: The object types for which this incrementer works
    • Path to parent field: The path to the nested field that contains the ID field and the base fields (leave empty if the ID field and the base fields are on the root level of the object).
    • ID field name: The name of the ID field to be filled out by the plugin. This has to be a numeric field. The field will only be updated if it is empty, if the parent field has been newly created and if all base fields have been filled out by the user.
    • Base field names: The names of the base fields to consider when setting the ID. These can be text fields or fields of the custom data type DANTE.
    • IDs of pools to consider: If not empty, IDs are only updated for resources in the specified pools (and their child pools). Also, resources in other pools are not considered during ID generation.

Initializing

Before the plugin is used for the first time, the incrementer objects have to be created via calling the REST API endpoint "initialize":

POST /api/v1/plugin/extension/numeric-id-auto-incrementer/initialize?access_token=ACCESS_TOKEN

The endpoint can be called again at a later point in time to rebuild the incrementer objects based on the IDs currently set in the database.

Examples

Example 1: ID in nested field

Configuration

  • Object types: example
  • Path to parent field: _nested:example__parent
  • ID field name: id
  • Base field names: place, year

Result

The field "id" contains the respective value as generated by the plugin.

Object 1:

{
    "_nested:example__parent": [
        { "place": "London", "year": "2020", "id": 1 },
        { "place": "Berlin", "year": "2020", "id": 1 },
        { "place": "Berlin", "year": "2020", "id": 2 }
    ]
}

Object 2:

{
    "_nested:example__parent": [
        { "place": "London", "year": "2020", "id": 2 },
        { "place": "Berlin", "year": "2020", "id": 3 }
        { "place": "Berlin", "year": "2021", "id": 1 }
    ]
}

Example 2: ID on object root level without base fields, different object types

Configuration

  • Object types: example, example2
  • Path to parent field:
  • ID field name: id
  • Base field names:

Result

The field "id" contains the respective value as generated by the plugin.

Object 1 (Object type: "example"):

{
    "id": 1
}

Object 2 (Object type: "example2"):

{
    "id": 2
}

Object 3 (Object type: "example"):

{
    "id": 3
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors