UNPKG

@manuth/woltlab-compiler

Version:

A compiler for generating WoltLab-Package `.tar` Archives and other WoltLab-Package Components

128 lines 3.22 kB
import { Localization } from "../Globalization/Localization.js"; import { NodeItem } from "../NodeSystem/NodeItem.js"; /** * Represents an option-category. * * @template TOption * The type of the options. * * @template TOptionOptions * The type of the data for generating options. */ export class Category extends NodeItem { /** * Initializes a new instance of the {@link Category `Category<TOption, TOptionOptions>`} class. * * @param node * The node of the category. * * @param options * The options of the category. * * @param generator * A function for generating options. */ constructor(node, options, generator) { super(node); /** * The human-readable name of the category. */ this.displayName = new Localization(); /** * The description of the category. */ this.description = new Localization(); /** * A value for ordering the category. */ this.showOrder = null; /** * The options of which at least one needs to be enabled for the category to be shown to the user. */ this.enableOptions = []; /** * The options of the category. */ this.options = []; if ((options.DisplayName !== null) && (options.DisplayName !== undefined)) { this.DisplayName.Load(options.DisplayName); } if ((options.Description !== null) && (options.Description !== undefined)) { this.Description.Load(options.Description); } if ((options.ShowOrder !== null) && (options.ShowOrder !== undefined)) { this.ShowOrder = options.ShowOrder; } if ((options.Options !== null) && (options.Options !== undefined)) { for (let option of options.Options) { this.options.push(generator(this, option)); } } if ((options.EnableOptions !== null) && (options.EnableOptions !== undefined)) { this.EnableOptions.push(...options.EnableOptions); } } /** * @inheritdoc */ get DisplayName() { return this.displayName; } /** * @inheritdoc */ get Description() { return this.description; } /** * @inheritdoc */ get ShowOrder() { return this.showOrder; } /** * @inheritdoc */ set ShowOrder(value) { this.showOrder = value; } /** * @inheritdoc */ get EnableOptions() { return this.enableOptions; } /** * @inheritdoc */ set EnableOptions(value) { this.enableOptions = value; } /** * @inheritdoc */ get Options() { return this.options; } /** * @inheritdoc * * @returns * The objects of the node. */ GetObjects() { let result = {}; for (let option of this.Options) { if (option.ID) { result[option.ID] = option; } } return result; } } //# sourceMappingURL=Category.js.map