mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 16:42:56 +00:00
refactor: remodel settings inputType
Flatten inputType to fit new core translation Closes #59
This commit is contained in:
@@ -28,11 +28,14 @@ export type SCSettingCategories = string;
|
||||
*/
|
||||
export interface SCSettingWithoutReferences
|
||||
extends SCThingWithCategoriesWithoutReferences<SCSettingCategories, SCThingWithCategoriesSpecificValues> {
|
||||
|
||||
/**
|
||||
* The type of input/value this setting is carrying
|
||||
* The default value of a setting
|
||||
*/
|
||||
input: SCSettingInputType;
|
||||
defaultValue: SCSettingValue | SCSettingValues;
|
||||
/**
|
||||
* The input type of this setting
|
||||
*/
|
||||
inputType: SCSettingInputType;
|
||||
/**
|
||||
* The order number this setting should show up in its category list
|
||||
*/
|
||||
@@ -45,16 +48,26 @@ export interface SCSettingWithoutReferences
|
||||
* The type of this model
|
||||
*/
|
||||
type: SCThingType.Setting;
|
||||
/**
|
||||
* The key of a value of a setting
|
||||
*/
|
||||
value?: SCSettingValue | SCSettingValues;
|
||||
/**
|
||||
* The possible values of a setting
|
||||
*/
|
||||
values?: SCSettingValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* The types of input/value a setting object can carry
|
||||
*/
|
||||
export type SCSettingInputType = SCSettingSingleChoice
|
||||
| SCSettingMultipleChoice
|
||||
| SCSettingNumber
|
||||
| SCSettingText
|
||||
| SCSettingPassword;
|
||||
export enum SCSettingInputType {
|
||||
SingleChoice = 'single choice',
|
||||
MultipleChoice = 'multiple choice',
|
||||
Number = 'number',
|
||||
Text = 'text',
|
||||
Password = 'password',
|
||||
}
|
||||
|
||||
/**
|
||||
* A setting with references
|
||||
@@ -69,58 +82,23 @@ export interface SCSetting extends SCSettingWithoutReferences {
|
||||
}
|
||||
|
||||
/**
|
||||
* Input type with single choice as value
|
||||
* The type a value of a setting can have
|
||||
*/
|
||||
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
|
||||
* The type of multiple values a setting can have
|
||||
*/
|
||||
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;
|
||||
}
|
||||
export type SCSettingValues = SCSettingValue[];
|
||||
|
||||
/**
|
||||
* Translatable properties of a setting
|
||||
*/
|
||||
export interface SCSettingValueTranslatableProperties extends SCThingWithCategoriesTranslatableProperties {
|
||||
/**
|
||||
* The translations of the possible values of a setting
|
||||
*/
|
||||
values?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,11 +113,17 @@ export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations<SCS
|
||||
// tslint:disable-next-line:max-line-length
|
||||
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
|
||||
SCThingWithCategoriesSpecificValues>().fieldTranslations.de,
|
||||
defaultValue: 'Standard Wert',
|
||||
inputType: 'Eingabetyp',
|
||||
value: 'Wert',
|
||||
values: 'Werte',
|
||||
},
|
||||
en: {
|
||||
// tslint:disable-next-line:max-line-length
|
||||
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
|
||||
SCThingWithCategoriesSpecificValues>().fieldTranslations.en,
|
||||
defaultValue: 'default value',
|
||||
inputType: 'input type',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -151,6 +135,13 @@ export class SCSettingMeta extends SCThingMeta implements SCMetaTranslations<SCS
|
||||
// tslint:disable-next-line:max-line-length
|
||||
... SCThingWithCategoriesWithoutReferencesMeta.getInstance<SCSettingCategories,
|
||||
SCThingWithCategoriesSpecificValues>().fieldValueTranslations.de,
|
||||
inputType: {
|
||||
'multiple choice': 'mehrfach Auswahl',
|
||||
number: 'Zahl',
|
||||
password: 'Passwort',
|
||||
'single choice': 'einfache Auswahl',
|
||||
text: 'Text',
|
||||
},
|
||||
type: 'Einstellung',
|
||||
},
|
||||
en: {
|
||||
|
||||
Reference in New Issue
Block a user