Skip to main content

Eneumeration

Introduction

This document provides an overview of the Enumeration feature in the Digisquares platform. Enumerations are essential for defining a set of predefined, named values that a variable can take, ensuring data consistency and integrity throughout your application.

What are Enumerations?

An Enumeration is a set of predefined, named values that a variable can take. They help restrict the possible values for a variable, ensuring that the data remains consistent, predictable, and aligned with business logic.

Benefits of Using Enumerations

  • State Representation: Easily define and manage various states (e.g., order status, user roles).
  • Categorization: Use enumerations to ensure consistent data categorization across your application.
  • Data Validation: Enforce that only valid, predefined values are accepted for a variable.
  • Improved Readability: Enhance the readability and maintainability of code by using descriptive names for values.

Example Chart Visualizations

Here are some example visualizations created using Digisquares:


Creating and Managing Enumerations

Step-by-Step Guide

1. Accessing the Enumeration Menu

  1. Navigate to the Data Menu in your Digisquares application.
  2. Select the "Enumeration" option. This opens the enumeration configuration interface.

2. Defining a New Enumeration

  1. Group: Optionally, specify a group name for organizational purposes.
  2. Name: Enter a unique name for the enumeration.
  3. Type: Choose the data type for the enumeration values (e.g., string, number).
  4. Values: Add the values that the enumeration will contain. Use the "+" button to add new values.

Example:

{
"group": "UserManagement",
"name": "UserRoles",
"type": "string",
"values": ["Admin", "Editor", "Viewer"]
}

3. Saving the Enumeration

After defining the group, name, type, and values, click the "Save" button to save the enumeration configuration. The new enumeration is now available for use throughout the application.

Example Usage

State Representation

To use an enumeration for state representation:

  • Bind a variable to the enumeration.
  • The variable will only accept values defined in the enumeration.
{
"fieldName": "userRole",
"type": "UserRoles",
"value": "Admin"
}

Form Dropdown

To use an enumeration in a form dropdown:

  • Bind the dropdown menu options to the enumeration.
  • The dropdown will display the values defined in the enumeration.
<select name="userRole">
<option value="Admin">Admin</option>
<option value="Editor">Editor</option>
<option value="Viewer">Viewer</option>
</select>

Managing Existing Enumerations

To edit or delete an existing enumeration:

  • Navigate to the enumeration menu.
  • Select the enumeration you wish to manage.
  • Update the values, type, or name as needed, or delete the enumeration if it is no longer required.

Best Practices for Using Enumerations

  • Consistency: Use enumerations to ensure data consistency across your application.
  • Validation: Leverage enumerations for validating user inputs and other variable values.
  • Descriptive Names: Use clear and descriptive names for enumerations and their values to improve readability and maintainability.
  • Centralized Management: Manage enumerations centrally to easily update and maintain valid value sets across the application.

Conclusion

Enumerations are a powerful feature in a Digisquares application, providing a way to define and enforce valid value sets for variables. By understanding how to define, use, and manage enumerations, you can ensure data consistency, improve validation, and enhance the overall readability and maintainability of your application.