src/app/core/basic-datatypes/configurable-enum/configurable-enum.types.ts
Support for types of configurable enums that impose a total ordering of their elements. Not all configurable enums (should sensibly) be able to be ordered. For example, it does not make sense to see which school / center is "greater than" another center, or which gender is above which other gender.
For other enum types it is, however, sensible to impose a total ordering such as warning levels ('OK' is somewhat 'better' than 'WARNING').
Configurable enum values that impose a total ordering can be compared, which also means that they can be sorted, and thus have a notion of one element being 'greater than' or 'less than' to another element. The interpretation of 'greater' or 'less' than is dependent on the concrete enum.
No results matching.
export interface ConfigurableEnumValue extends HasOrdinal {
/**
* identifier that is unique among all values of the same enum and does not change even when label or other things are edited
*/
id: string;
/**
* human-readable name that is displayed representing the value in the UI
*/
label: string;
/**
* an optional color code which should be displayed
*/
color?: string;
/**
* indicates this is a fallback option generated by configurable-enum datatype for
* a value that is not included in the selectable enum options of the config.
*/
isInvalidOption?: boolean;
/**
* optional styling class that should be applied when displaying this value
*/
style?: string;
}
export const EMPTY: ConfigurableEnumValue = {
id: "",
label: "",
};
/**
* Interface specifying overall object representing an enum with all its options
* as stored in the config database
*/
export type ConfigurableEnumConfig<
T extends ConfigurableEnumValue = ConfigurableEnumValue,
> = Array<T>;
/**
* Support for types of configurable enums that impose a total ordering of their elements.
* Not all configurable enums (should sensibly) be able to be ordered. For example, it does
* not make sense to see which school / center is "greater than" another center, or which gender is above
* which other gender.
*
* For other enum types it is, however, sensible to impose a total ordering such as warning levels ('OK' is
* somewhat 'better' than 'WARNING').
*
* Configurable enum values that impose a total ordering can be compared, which also means that they can be sorted,
* and thus have a notion of one element being 'greater than' or 'less than' to another element. The interpretation
* of 'greater' or 'less' than is dependent on the concrete enum.
*/
export interface HasOrdinal {
_ordinal?: number;
}