/* * Copyright (C) 2018 StApps * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ import { SCThingWithCategoriesSpecificValues, SCThingWithCategoriesTranslatableProperties, SCThingWithCategoriesWithoutReferences, } from '../base/ThingWithCategories'; import {SCThingMeta, SCThingType} from '../Thing'; import {SCTranslations} from '../types/i18n'; export type SCSettingCategories = string; /** * A setting without references */ export interface SCSettingWithoutReferences extends SCThingWithCategoriesWithoutReferences { /** * The type of input/value this setting is carrying */ input: SCSettingInputType; /** * The order number this setting should show up in its category list */ order: number; /** * Translated fields of a setting */ translations?: SCTranslations; /** * The type of this model */ type: SCThingType.Setting; } /** * The types of input/value a setting object can carry */ export type SCSettingInputType = SCSettingSingleChoice | SCSettingMultipleChoice | SCSettingNumber | SCSettingText | SCSettingPassword; /** * A setting with references * * @validatable */ export interface SCSetting extends SCSettingWithoutReferences { /** * The type of this model */ type: SCThingType.Setting; } /** * Input type with single choice as value */ export interface SCSettingSingleChoice { defaultValue: SCSettingValue; inputType: 'singleChoice'; value?: SCSettingValue; values: SCSettingValue[]; } /** * Input type with multiple choice as value */ export interface SCSettingMultipleChoice { defaultValue: SCSettingValue[]; inputType: 'multipleChoice'; value?: SCSettingValue[]; values: SCSettingValue[]; } export type SCSettingValue = string | number | boolean; /** * Input type with number as value */ export interface SCSettingNumber { defaultValue: number; inputType: 'number'; value?: number; } /** * Input type with text as value */ export interface SCSettingText { defaultValue: string; inputType: 'text'; value?: string; } /** * Input type with secret text (eq. password) as value */ export interface SCSettingPassword { defaultValue: string; inputType: 'password'; value?: string; } /** * Translatable properties of a setting */ export interface SCSettingValueTranslatableProperties extends SCThingWithCategoriesTranslatableProperties { } /** * Meta information about a setting */ export class SCSettingMeta extends SCThingMeta { static fieldTranslations = { ...SCThingMeta.fieldTranslations, }; }