@manuth/woltlab-compiler
Version:
A compiler for generating WoltLab-Package `.tar` Archives and other WoltLab-Package Components
260 lines • 7.19 kB
JavaScript
import { Localization } from "../Globalization/Localization.js";
import { OptionItem } from "./OptionItem.js";
import { OptionType } from "./OptionType.js";
/**
* Represents an option.
*/
export class Option {
/**
* Initializes a new instance of the {@link Option `Option`} class.
*
* @param category
* The category of the option.
*
* @param options
* The options of the option.
*/
constructor(category, options) {
/**
* The id of the option.
*/
this.id = null;
/**
* The human-readable name of the option.
*/
this.displayName = new Localization();
/**
* The description of the option.
*/
this.description = new Localization();
/**
* The category of the option.
*/
this.category = null;
/**
* The type of the option.
*/
this.type = OptionType.TextBox;
/**
* The default value of the option.
*/
this.defaultValue = null;
/**
* The show-order of the option.
*/
this.showOrder = null;
/**
* The validation-pattern of the option.
*/
this.validationPattern = null;
/**
* The items of the option.
*/
this.items = [];
/**
* A list of options of which at least one needs to be enabled for the option to be shown.
*/
this.options = [];
/**
* A list of options which should be visually enabled when this option is enabled.
*
* A leading exclamation mark (`!`, `U+0021`) will disable the specified option when this option is enabled.
* For `ComboBox` and `RadioButton` types the list should be prefixed by the name of the `selectoption`s followed by a colon (`:`, `U+003A`).
*
* This setting is a visual helper for the administrator only.
* It does not have an effect on the server side processing of the option.
*/
this.enableOptions = [];
/**
* A set of additional properties of the option.
*/
this.additionalProperties = {};
this.category = category;
if ((options.ID !== null) &&
(options.ID !== undefined)) {
this.ID = options.ID;
}
this.Name = options.Name;
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.Type !== null) &&
(options.Type !== undefined)) {
this.Type = options.Type;
}
if ((options.DefaultValue !== null) &&
(options.DefaultValue !== undefined)) {
this.DefaultValue = options.DefaultValue;
}
if ((options.ShowOrder !== null) &&
(options.ShowOrder !== undefined)) {
this.ShowOrder = options.ShowOrder;
}
if ((options.ValidationPattern !== null) &&
(options.ValidationPattern !== undefined)) {
this.ValidationPattern = options.ValidationPattern;
}
if ((options.Items !== null) &&
(options.Items !== undefined)) {
for (let item of options.Items) {
this.Items.push(new OptionItem(this, item));
}
}
if ((options.Options !== null) &&
(options.Options !== undefined)) {
this.Options = options.Options;
}
if ((options.EnableOptions !== null) &&
(options.EnableOptions !== undefined)) {
this.EnableOptions = options.EnableOptions;
}
if ((options.AdditionalProperties !== null) &&
(options.AdditionalProperties !== undefined)) {
this.AdditionalProperties = options.AdditionalProperties;
}
}
/**
* Gets or sets the id of the option.
*/
get ID() {
return this.id;
}
/**
* @inheritdoc
*/
set ID(value) {
this.id = value;
}
/**
* Gets or sets the name of the option.
*/
get Name() {
return this.name;
}
/**
* @inheritdoc
*/
set Name(value) {
this.name = value;
}
/**
* Gets the human-readable name of the option.
*/
get DisplayName() {
return this.displayName;
}
/**
* Gets the description of the option.
*/
get Description() {
return this.description;
}
/**
* Gets the category of the option.
*/
get Category() {
return this.category;
}
/**
* Gets or sets the type of the option.
*/
get Type() {
return this.type;
}
/**
* @inheritdoc
*/
set Type(value) {
this.type = value;
}
/**
* Gets or sets the default value of the option.
*/
get DefaultValue() {
return this.defaultValue;
}
/**
* @inheritdoc
*/
set DefaultValue(value) {
this.defaultValue = value;
}
/**
* Gets or sets the show-order of the option.
*/
get ShowOrder() {
return this.showOrder;
}
/**
* @inheritdoc
*/
set ShowOrder(value) {
this.showOrder = value;
}
/**
* Gets or sets the validation-pattern of the option.
*/
get ValidationPattern() {
return this.validationPattern;
}
/**
* @inheritdoc
*/
set ValidationPattern(value) {
this.validationPattern = value;
}
/**
* Gets the items of the option.
*/
get Items() {
return this.items;
}
/**
* Gets or sets a list of options of which at least one needs to be enabled for the option to be shown.
*/
get Options() {
return this.options;
}
/**
* @inheritdoc
*/
set Options(value) {
this.options = value;
}
/**
* Gets or sets a list of options which should be visually enabled when this option is enabled.
*
* A leading exclamation mark (`!`, `U+0021`) will disable the specified option when this option is enabled.
* For `ComboBox` and `RadioButton` types the list should be prefixed by the name of the `selectoption`s followed by a colon (`:`, `U+003A`).
*
* This setting is a visual helper for the administrator only.
* It does not have an effect on the server side processing of the option.
*/
get EnableOptions() {
return this.enableOptions;
}
/**
* @inheritdoc
*/
set EnableOptions(value) {
this.enableOptions = value;
}
/**
* Gets or sets a set of additional properties of the option.
*/
get AdditionalProperties() {
return this.additionalProperties;
}
/**
* @inheritdoc
*/
set AdditionalProperties(value) {
this.additionalProperties = value;
}
}
//# sourceMappingURL=Option.js.map