UNPKG

idea-toolbox

Version:
89 lines (88 loc) 2.56 kB
import { Resource } from './resource.model'; import { CustomFieldTypes } from './customFieldTypes.enum'; import { Label } from './label.model'; import { Languages } from './languages.model'; import { Suggestion } from './suggestion.model'; /** * Metadata of a custom field. */ export declare class CustomFieldMeta extends Resource { /** * The id of the team owning the field. Optional. */ teamId?: string; /** * Id of the field. */ fieldId?: string; /** * Name of the field. */ name: Label; /** * Explanation of the field. */ description: Label; /** * The type of the custom field. */ type: CustomFieldTypes; /** * The list of the possible values (strings); available only with type ENUM. */ enum?: string[]; /** * The translations of the enum keys; available only with type ENUM. * Not obligatory: the fallback is always the enum key. */ enumLabels?: { [key: string]: Label; }; /** * Field default value. */ default: any; /** * If true, an obligatory check will be performed; ignored with type BOOLEAN. */ obligatory: boolean; /** * Min value the field can assume; available only with type NUMBER. */ min?: number; /** * Max value the field can assume; available only with type NUMBER. */ max?: number; /** * The icon to show to identify the field. */ icon: string; load(x: any, languages?: Languages): void; safeLoad(newData: any, safeData: any, languages?: Languages): void; validate(languages?: Languages): string[]; /** * Set a default value for the field, based on its type. * @return the determinated default value, based on the type */ fieldDefaultValue(): any; /** * Load a value based on the field configuration. * @param newField the value to load */ loadField(newField: any): any; /** * Validate a field value, based on the field configuration. * @param field the value to check * @return return false in case of error */ validateField(field: any): boolean; /** * Get the label to show for the enum, based on the translations available; if none, returns the key. */ getEnumElement(enumKey: string, language?: string, languages?: Languages): string; /** * Get the enum in the form of array of Suggestions. */ getEnumAsSuggestion(language?: string, languages?: Languages): Suggestion[]; }