UNPKG

woltlab-compiler

Version:

A compiler for WoltLab-Package Archives and WoltLab-Package Components

112 lines 3.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = require("util"); const Localization_1 = require("../Globalization/Localization"); const NodeItem_1 = require("../NodeSystem/NodeItem"); /** * Represents an option-category. */ class Category extends NodeItem_1.NodeItem { /** * Initializes a new instance of the `Category` class. * * @param generator * A function for generating options. */ constructor(node, options, generator) { super(node); /** * The human-readable name of the category. */ this.displayName = new Localization_1.Localization(); /** * The description of the category. */ this.description = new Localization_1.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 (!util_1.isNullOrUndefined(options.DisplayName)) { this.DisplayName.Data = options.DisplayName; } if (!util_1.isNullOrUndefined(options.Description)) { this.Description.Data = options.Description; } if (!util_1.isNullOrUndefined(options.ShowOrder)) { this.ShowOrder = options.ShowOrder; } if (!util_1.isNullOrUndefined(options.Options)) { for (let option of options.Options) { this.options.push(generator(this, option)); } } if (!util_1.isNullOrUndefined(options.EnableOptions)) { 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 */ GetObjects() { let result = {}; for (let option of this.Options) { if (!util_1.isNullOrUndefined(option.ID)) { result[option.ID] = option; } } return result; } } exports.Category = Category; //# sourceMappingURL=Category.js.map