refactor: remodel settings inputType

Flatten inputType to fit new core translation

Closes #59
This commit is contained in:
Sebastian Lange
2019-04-24 13:50:49 +02:00
parent d3790adbd8
commit bab675b806
6 changed files with 171 additions and 162 deletions

136
package-lock.json generated
View File

@@ -14,12 +14,12 @@
}
},
"@babel/generator": {
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.0.tgz",
"integrity": "sha512-/v5I+a1jhGSKLgZDcmAUZ4K/VePi43eRkUs3yePW1HB1iANOD5tqJXwGSG4BZhSksP8J9ejSlwGeTiiOFZOrXQ==",
"version": "7.4.4",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.4.tgz",
"integrity": "sha512-53UOLK6TVNqKxf7RUh8NE851EHRxOOeVXKbK2bivdb+iziMyk03Sr4eaE9OELCbyZAAafAKPDwF2TPUES5QbxQ==",
"dev": true,
"requires": {
"@babel/types": "^7.4.0",
"@babel/types": "^7.4.4",
"jsesc": "^2.5.1",
"lodash": "^4.17.11",
"source-map": "^0.5.0",
@@ -55,12 +55,12 @@
}
},
"@babel/helper-split-export-declaration": {
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.0.tgz",
"integrity": "sha512-7Cuc6JZiYShaZnybDmfwhY4UYHzI6rlqhWjaIqbsJGsIqPimEYy5uh3akSRLMg65LSdSEnJ8a8/bWQN6u2oMGw==",
"version": "7.4.4",
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz",
"integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==",
"dev": true,
"requires": {
"@babel/types": "^7.4.0"
"@babel/types": "^7.4.4"
}
},
"@babel/highlight": {
@@ -83,43 +83,43 @@
}
},
"@babel/parser": {
"version": "7.4.3",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.3.tgz",
"integrity": "sha512-gxpEUhTS1sGA63EGQGuA+WESPR/6tz6ng7tSHFCmaTJK/cGK8y37cBTspX+U2xCAue2IQVvF6Z0oigmjwD8YGQ==",
"version": "7.4.4",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.4.tgz",
"integrity": "sha512-5pCS4mOsL+ANsFZGdvNLybx4wtqAZJ0MJjMHxvzI3bvIsz6sQvzW8XX92EYIkiPtIvcfG3Aj+Ir5VNyjnZhP7w==",
"dev": true
},
"@babel/runtime": {
"version": "7.4.3",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.4.3.tgz",
"integrity": "sha512-9lsJwJLxDh/T3Q3SZszfWOTkk3pHbkmH+3KY+zwIDmsNlxsumuhS2TH3NIpktU4kNvfzy+k3eLT7aTJSPTo0OA==",
"version": "7.4.4",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.4.4.tgz",
"integrity": "sha512-w0+uT71b6Yi7i5SE0co4NioIpSYS6lLiXvCzWzGSKvpK5vdQtCbICHMj+gbAKAOtxiV6HsVh/MBdaF9EQ6faSg==",
"dev": true,
"requires": {
"regenerator-runtime": "^0.13.2"
}
},
"@babel/template": {
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.0.tgz",
"integrity": "sha512-SOWwxxClTTh5NdbbYZ0BmaBVzxzTh2tO/TeLTbF6MO6EzVhHTnff8CdBXx3mEtazFBoysmEM6GU/wF+SuSx4Fw==",
"version": "7.4.4",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz",
"integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
"@babel/parser": "^7.4.0",
"@babel/types": "^7.4.0"
"@babel/parser": "^7.4.4",
"@babel/types": "^7.4.4"
}
},
"@babel/traverse": {
"version": "7.4.3",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.3.tgz",
"integrity": "sha512-HmA01qrtaCwwJWpSKpA948cBvU5BrmviAief/b3AVw936DtcdsTexlbyzNuDnthwhOQ37xshn7hvQaEQk7ISYQ==",
"version": "7.4.4",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.4.tgz",
"integrity": "sha512-Gw6qqkw/e6AGzlyj9KnkabJX7VcubqPtkUQVAwkc0wUMldr3A/hezNB3Rc5eIvId95iSGkGIOe5hh1kMKf951A==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
"@babel/generator": "^7.4.0",
"@babel/generator": "^7.4.4",
"@babel/helper-function-name": "^7.1.0",
"@babel/helper-split-export-declaration": "^7.4.0",
"@babel/parser": "^7.4.3",
"@babel/types": "^7.4.0",
"@babel/helper-split-export-declaration": "^7.4.4",
"@babel/parser": "^7.4.4",
"@babel/types": "^7.4.4",
"debug": "^4.1.0",
"globals": "^11.1.0",
"lodash": "^4.17.11"
@@ -137,9 +137,9 @@
}
},
"@babel/types": {
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.0.tgz",
"integrity": "sha512-aPvkXyU2SPOnztlgo8n9cEiXW755mgyvueUPcpStqdzoSPm0fjO0vQBjLkt3JKJW7ufikfcnMTTPsN1xaTsBPA==",
"version": "7.4.4",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.4.tgz",
"integrity": "sha512-dOllgYdnEFOebhkKCjzSVFqw/PmmB8pH6RGOWkY4GsboQNd47b1fBThBSwlHAq9alF9vc1M3+6oqR47R50L0tQ==",
"dev": true,
"requires": {
"esutils": "^2.0.2",
@@ -334,9 +334,9 @@
}
},
"@types/shelljs": {
"version": "0.8.4",
"resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.4.tgz",
"integrity": "sha512-UNACC6scKFVljWEvO3rHBkbbKXu3QkKPBOMCisxI7au9cnFK7tjOGPsKh5OjedAPLmtsKSarmk+YeehKTQSKtg==",
"version": "0.8.5",
"resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.5.tgz",
"integrity": "sha512-bZgjwIWu9gHCjirKJoOlLzGi5N0QgZ5t7EXEuoqyWCHTuSddURXo3FOBYDyRPNOWzZ6NbkLvZnVkn483Y/tvcQ==",
"dev": true,
"requires": {
"@types/glob": "*",
@@ -689,15 +689,15 @@
"dev": true
},
"conventional-changelog": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-3.1.3.tgz",
"integrity": "sha512-JBfdDSdSGasTNaBRZbOeFn8CJTIpP/sB/kiawmWAiLapLZ+wCDVDZR6Q+Hh9rjh3dxNAFR03bWTeqjKajXvPYA==",
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-3.1.4.tgz",
"integrity": "sha512-uMeTSzEb2oKFlL00Oh9j3+00PFq1MNneLzyy0TBftxo4PFrs7OiaRJXmXtEgSvJDdkc0RSd6ch2N+yTxPagZ0A==",
"dev": true,
"requires": {
"conventional-changelog-angular": "^5.0.3",
"conventional-changelog-atom": "^2.0.1",
"conventional-changelog-codemirror": "^2.0.1",
"conventional-changelog-conventionalcommits": "^1.1.1",
"conventional-changelog-conventionalcommits": "^1.1.2",
"conventional-changelog-core": "^3.2.2",
"conventional-changelog-ember": "^2.0.2",
"conventional-changelog-eslint": "^3.0.2",
@@ -749,9 +749,9 @@
}
},
"conventional-changelog-conventionalcommits": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-1.1.1.tgz",
"integrity": "sha512-21BcbiSfvYIon7sF80Rwn6vnfhaiuZUyHHFYr9Zz8H2B+O/3grud5TbEYpU1/SFXD5aD48IdSme/KkJl9wCsCw==",
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-1.1.2.tgz",
"integrity": "sha512-t8VyibJHGrtsDwSHjgpW9v7oBbqDGQooCMo/a2rc0z5cousV5O11palcSPpyshEVWVijxPtzBNG02EQkMDJ8CA==",
"dev": true,
"requires": {
"compare-func": "^1.3.1",
@@ -1800,27 +1800,27 @@
"dev": true
},
"is-path-cwd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.0.0.tgz",
"integrity": "sha512-m5dHHzpOXEiv18JEORttBO64UgTEypx99vCxQLjbBvGhOJxnTNglYoFXxwo6AbsQb79sqqycQEHv2hWkHZAijA==",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.1.0.tgz",
"integrity": "sha512-Sc5j3/YnM8tDeyCsVeKlm/0p95075DyLmDEIkSgQ7mXkrOX+uTCtmQFm0CYzVyJwcCCmO3k8qfJt17SxQwB5Zw==",
"dev": true
},
"is-path-in-cwd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-2.0.0.tgz",
"integrity": "sha512-6Vz5Gc9s/sDA3JBVu0FzWufm8xaBsqy1zn8Q6gmvGP6nSDMw78aS4poBNeatWjaRpTpxxLn1WOndAiOlk+qY8A==",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-2.1.0.tgz",
"integrity": "sha512-rNocXHgipO+rvnP6dk3zI20RpOtrAM/kzbB258Uw5BWr3TpXi861yzjo16Dn4hUox07iw5AyeMLHWsujkjzvRQ==",
"dev": true,
"requires": {
"is-path-inside": "^1.0.0"
"is-path-inside": "^2.1.0"
}
},
"is-path-inside": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz",
"integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-2.1.0.tgz",
"integrity": "sha512-wiyhTzfDWsvwAW53OBWF5zuvaOGlZ6PwYxAbPVDhpm+gM09xKQGjBq/8uYN12aDvMxnAnq3dxTyoSoRNmg5YFg==",
"dev": true,
"requires": {
"path-is-inside": "^1.0.1"
"path-is-inside": "^1.0.2"
}
},
"is-plain-obj": {
@@ -1965,9 +1965,9 @@
}
},
"istanbul-reports": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-2.2.2.tgz",
"integrity": "sha512-ZFuTdBQ3PSaPnm02aEA4R6mzQ2AF9w03CYiXADzWbbE48v/EFOWF4MaX4FT0NRdqIk48I7o0RPi+S8TMswaCbQ==",
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-2.2.3.tgz",
"integrity": "sha512-T6EbPuc8Cb620LWAYyZ4D8SSn06dY9i1+IgUX2lTH8gbwflMc9Obd33zHTyNX653ybjpamAHS9toKS3E6cGhTw==",
"dev": true,
"requires": {
"handlebars": "^4.1.0"
@@ -2287,9 +2287,9 @@
}
},
"mocha": {
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-6.1.3.tgz",
"integrity": "sha512-QdE/w//EPHrqgT5PNRUjRVHy6IJAzAf1R8n2O8W8K2RZ+NbPfOD5cBDp+PGa2Gptep37C/TdBiaNwakppEzEbg==",
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-6.1.4.tgz",
"integrity": "sha512-PN8CIy4RXsIoxoFJzS4QNnCH4psUCPWc4/rPrst/ecSJJbLBkubMiyGCP2Kj/9YnWbotFqAoeXyXMucj7gwCFg==",
"dev": true,
"requires": {
"ansi-colors": "3.2.3",
@@ -2301,7 +2301,7 @@
"glob": "7.1.3",
"growl": "1.10.5",
"he": "1.2.0",
"js-yaml": "3.13.0",
"js-yaml": "3.13.1",
"log-symbols": "2.2.0",
"minimatch": "3.0.4",
"mkdirp": "0.5.1",
@@ -2326,16 +2326,6 @@
"locate-path": "^3.0.0"
}
},
"js-yaml": {
"version": "3.13.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.0.tgz",
"integrity": "sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
}
},
"locate-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
@@ -3099,9 +3089,9 @@
"dev": true
},
"resolve": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz",
"integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==",
"version": "1.10.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.1.tgz",
"integrity": "sha512-KuIe4mf++td/eFb6wkaPbMDnP6kObCaEtIDuHOUED6MNUo4K670KZUHuuvYPZDxNF0WVLw49n06M2m2dXphEzA==",
"dev": true,
"requires": {
"path-parse": "^1.0.6"
@@ -3660,9 +3650,9 @@
"dev": true
},
"uglify-js": {
"version": "3.5.4",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.4.tgz",
"integrity": "sha512-GpKo28q/7Bm5BcX9vOu4S46FwisbPbAmkkqPnGIpKvKTM96I85N6XHQV+k4I6FA2wxgLhcsSyHoNhzucwCflvA==",
"version": "3.5.9",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.9.tgz",
"integrity": "sha512-WpT0RqsDtAWPNJK955DEnb6xjymR8Fn0OlK4TT4pS0ASYsVPqr5ELhgwOwLCP5J5vHeJ4xmMmz3DEgdqC10JeQ==",
"dev": true,
"optional": true,
"requires": {

View File

@@ -54,7 +54,7 @@
"chai": "4.2.0",
"commander": "2.20.0",
"conventional-changelog-cli": "2.0.12",
"mocha": "6.1.3",
"mocha": "6.1.4",
"mocha-typescript": "1.1.17",
"nyc": "14.0.0",
"rimraf": "2.6.3",

View File

@@ -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: {

View File

@@ -5,15 +5,13 @@
"privacy"
],
"description": "This is a Description",
"input": {
"defaultValue": "student",
"inputType": "singleChoice",
"values": [
"student",
"employee",
"guest"
]
},
"defaultValue": "student",
"inputType": "single choice",
"values": [
"student",
"employee",
"guest"
],
"name": "group",
"order": 0,
"origin": {
@@ -21,11 +19,6 @@
"name": "Dummy",
"type": "remote"
},
"translations": {
"de": {
"description": "Dies ist eine Beschreibung"
}
},
"type": "setting",
"uid": "c4ff2b08-be18-528e-9b09-cb8c1d18487b"
},

View File

@@ -5,20 +5,18 @@
"privacy"
],
"description": "This is a Description",
"input": {
"defaultValue": [],
"inputType": "multipleChoice",
"values": [
1,
2,
3,
4,
5,
6,
7,
8
]
},
"defaultValue": [],
"inputType": "multiple choice",
"values": [
1,
2,
3,
4,
5,
6,
7,
8
],
"name": "numbers",
"order": 1,
"origin": {
@@ -26,16 +24,6 @@
"name": "Dummy",
"type": "remote"
},
"translations": {
"de": {
"description": "Dies ist eine Beschreibung",
"name": "Nummern"
},
"en": {
"description": "This is a Description",
"name": "Numbers"
}
},
"type": "setting",
"uid": "9f0c362e-0b41-532f-9e8b-a0ac373fbede"
},

View File

@@ -0,0 +1,47 @@
{
"errorNames": [],
"instance": {
"categories": [
"profile"
],
"defaultValue": "en",
"description": "The language this app is going to use.",
"inputType": "single choice",
"name": "language",
"order": 0,
"origin": {
"indexed": "2018-09-11T12:30:00Z",
"name": "Dummy",
"type": "remote"
},
"translations": {
"de": {
"categories": ["Benutzer"],
"description": "Die Sprache in der die App angezeigt wird.",
"name": "Sprache",
"values": [
"English",
"German"
]
},
"en": {
"categories": [
"User"
],
"description": "The language this app is going to use.",
"name": "Language",
"values": [
"english",
"german"
]
}
},
"type": "setting",
"values": [
"en",
"de"
],
"uid": "184b717a-d020-46f5-995c-03023670cc62"
},
"schema": "SCSetting"
}