diff --git a/frontend/package-lock.json b/frontend/package-lock.json index b5e04738e..7c02a5f4d 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -49,7 +49,7 @@ "patch-db-client": "file: ../../../patch-db/client", "pbkdf2": "^3.1.2", "rxjs": "^7.5.6", - "start-sdk": "^0.4.0-lib0.beta6", + "start-sdk": "^0.4.0-lib0.beta9", "swiper": "^8.2.4", "ts-matches": "^5.2.1", "tslib": "^2.3.0", @@ -13771,9 +13771,9 @@ } }, "node_modules/start-sdk": { - "version": "0.4.0-lib0.beta6", - "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.beta6.tgz", - "integrity": "sha512-9dR2noD/rJ4u/Xuhs5S0+lv95nqpERWzxbXlpXDbtjXzMKzX8v1zmKKMNfTir1oxaZC820llLlaCeuPG2VGNpg==", + "version": "0.4.0-lib0.beta9", + "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.beta9.tgz", + "integrity": "sha512-gTpvFG9HARW1XlljA3It+L1NdNEp8OZrTJjc9vTJpgKn14U9HCYI/+XZC+UzGvP2AJpfR+1bBKSv2UAfElfw9A==", "dependencies": { "@iarna/toml": "^2.2.5", "lodash": "^4.17.21", diff --git a/frontend/package.json b/frontend/package.json index d51703fe8..fd203caed 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -74,7 +74,7 @@ "patch-db-client": "file: ../../../patch-db/client", "pbkdf2": "^3.1.2", "rxjs": "^7.5.6", - "start-sdk": "^0.4.0-lib0.beta6", + "start-sdk": "^0.4.0-lib0.beta9", "swiper": "^8.2.4", "ts-matches": "^5.2.1", "tslib": "^2.3.0", diff --git a/frontend/projects/ui/src/app/components/form-object/form-object/controls/form-input/form-input.component.html b/frontend/projects/ui/src/app/components/form-object/form-object/controls/form-input/form-input.component.html index b6d2b8c53..b0599b891 100644 --- a/frontend/projects/ui/src/app/components/form-object/form-object/controls/form-input/form-input.component.html +++ b/frontend/projects/ui/src/app/components/form-object/form-object/controls/form-input/form-input.component.html @@ -26,7 +26,7 @@ [class.input_redacted]=" spec.type === 'string' && control.value && spec.masked && !unmasked " - [inputmode]="spec.type === 'number' ? 'tel' : 'text'" + [inputmode]="spec.type === 'string' ? spec.inputmode : 'tel'" [placeholder]="spec.placeholder" [formControl]="control" (ionFocus)="warning.onChange(name, spec)" diff --git a/frontend/projects/ui/src/app/components/form-object/form-object/form-object.component.html b/frontend/projects/ui/src/app/components/form-object/form-object/form-object.component.html index 1e0b4d3c6..387346634 100644 --- a/frontend/projects/ui/src/app/components/form-object/form-object/form-object.component.html +++ b/frontend/projects/ui/src/app/components/form-object/form-object/form-object.component.html @@ -95,7 +95,7 @@ " > - +
{ const spec = this.objectSpec[key] - if (spec.type === 'list' && ['object', 'union'].includes(spec.subtype)) { + if (spec.type === 'list' && spec.spec.type === 'object') { this.objectListDisplay[key] = [] this.formGroup.get(key)?.value.forEach((obj: any, index: number) => { const displayAs = (spec.spec as ListValueSpecOf<'object'>).displayAs @@ -209,8 +209,8 @@ export class FormObjectComponent { const index = arr.length arr.insert(index, newItem) - if (['object', 'union'].includes(listSpec.subtype)) { - const displayAs = (listSpec.spec as ListValueSpecOf<'object'>).displayAs + if (listSpec.spec.type === 'object') { + const displayAs = listSpec.spec.displayAs this.objectListDisplay[key].push({ expanded: false, displayAs: displayAs ? Mustache.render(displayAs, newItem.value) : '', @@ -223,7 +223,7 @@ export class FormObjectComponent { ) element?.parentElement?.scrollIntoView({ behavior: 'smooth' }) - if (['object', 'union'].includes(listSpec.subtype)) { + if (listSpec.spec.type === 'object') { pauseFor(250).then(() => this.toggleExpandListObject(key, index)) } }, 100) diff --git a/frontend/projects/ui/src/app/pages/developer-routes/developer-list/developer-list.page.ts b/frontend/projects/ui/src/app/pages/developer-routes/developer-list/developer-list.page.ts index 57e01138a..0fcf04393 100644 --- a/frontend/projects/ui/src/app/pages/developer-routes/developer-list/developer-list.page.ts +++ b/frontend/projects/ui/src/app/pages/developer-routes/developer-list/developer-list.page.ts @@ -235,7 +235,6 @@ const SAMPLE_CONFIG: InputSpec = { 'sample-number': { type: 'number', name: 'Example Number Input', - inputmode: 'decimal', required: true, range: '[5,1000000]', integral: true, diff --git a/frontend/projects/ui/src/app/services/api/api.fixures.ts b/frontend/projects/ui/src/app/services/api/api.fixures.ts index 4829ccf04..88f9b6e4a 100644 --- a/frontend/projects/ui/src/app/services/api/api.fixures.ts +++ b/frontend/projects/ui/src/app/services/api/api.fixures.ts @@ -746,7 +746,6 @@ export module Mock { }, 'p2p-port': { type: 'number', - inputmode: 'numeric', name: 'P2P Port', description: 'The port that your Bitcoin Core P2P server is bound to', @@ -866,7 +865,6 @@ export module Mock { 'object-list': { name: 'Object List', type: 'list', - subtype: 'object', description: 'This is a list of objects, like users or something', warning: null, range: '[0,4]', @@ -885,6 +883,7 @@ export module Mock { // the outer spec here, at the list level, says that what's inside (the inner spec) pertains to its inner elements. // it just so happens that ValueSpecObject's have the field { spec: InputSpec } spec: { + type: 'object', uniqueBy: 'last-name', displayAs: `I'm {{last-name}}, {{first-name}} {{last-name}}`, spec: { @@ -919,7 +918,6 @@ export module Mock { }, age: { name: 'Age', - inputmode: 'numeric', type: 'number', description: 'The age of the user', required: false, @@ -963,7 +961,6 @@ export module Mock { }, 'favorite-number': { name: 'Favorite Number', - inputmode: 'decimal', type: 'number', integral: false, description: 'Your favorite number of all time', @@ -978,11 +975,10 @@ export module Mock { 'unlucky-numbers': { name: 'Unlucky Numbers', type: 'list', - subtype: 'number', description: 'Numbers that you like but are not your top favorite.', warning: null, spec: { - inputmode: 'decimal', + type: 'number', integral: false, range: '[-100,200)', units: null, @@ -1034,12 +1030,12 @@ export module Mock { rulemakers: { name: 'Rule Makers', type: 'list', - subtype: 'object', description: 'the people who make the rules', warning: null, range: '[0,2]', default: [], spec: { + type: 'object', uniqueBy: null, displayAs: null, spec: { @@ -1185,7 +1181,6 @@ export module Mock { }, port: { name: 'Port', - inputmode: 'numeric', type: 'number', integral: true, description: @@ -1214,7 +1209,6 @@ export module Mock { rpcallowip: { name: 'RPC Allowed IPs', type: 'list', - subtype: 'string', description: 'external ip addresses that are authorized to access your Bitcoin node', warning: @@ -1222,6 +1216,7 @@ export module Mock { range: '[1,10]', default: ['192.168.1.1'], spec: { + type: 'string', inputmode: 'text', masked: false, placeholder: null, @@ -1233,12 +1228,12 @@ export module Mock { rpcauth: { name: 'RPC Auth', type: 'list', - subtype: 'string', description: 'api keys that are authorized to access your Bitcoin node.', warning: null, range: '[0,*)', default: [], spec: { + type: 'string', inputmode: 'text', masked: false, placeholder: null, @@ -1307,12 +1302,12 @@ export module Mock { law3: { name: 'Third Law', type: 'list', - subtype: 'object', description: 'the third law', warning: null, range: '[0,2]', default: [], spec: { + type: 'object', uniqueBy: null, displayAs: null, spec: { @@ -1368,12 +1363,12 @@ export module Mock { rulemakers: { name: 'Rule Makers', type: 'list', - subtype: 'object', description: 'the people who make the rules', warning: null, range: '[0,2]', default: [], spec: { + type: 'object', uniqueBy: null, displayAs: null, spec: { diff --git a/frontend/projects/ui/src/app/services/form.service.ts b/frontend/projects/ui/src/app/services/form.service.ts index eb50ba21e..a49839898 100644 --- a/frontend/projects/ui/src/app/services/form.service.ts +++ b/frontend/projects/ui/src/app/services/form.service.ts @@ -337,13 +337,12 @@ export function listUnique(spec: ValueSpecList): ValidatorFn { function listItemEquals(spec: ValueSpecList, val1: any, val2: any): boolean { // TODO: fix types - switch (spec.subtype) { + switch (spec.spec.type) { case 'string': case 'number': return val1 == val2 case 'object': - const obj: ListValueSpecObject = spec.spec as any - + const obj = spec.spec return listObjEquals(obj.uniqueBy, obj, val1, val2) default: return false @@ -553,15 +552,15 @@ export function convertValuesRecursive( const formArr = group.get(key) as UntypedFormArray const { controls } = formArr - if (valueSpec.subtype === 'number') { + if (valueSpec.spec.type === 'number') { controls.forEach(control => { control.setValue(control.value ? Number(control.value) : null) }) - } else if (valueSpec.subtype === 'string') { + } else if (valueSpec.spec.type === 'string') { controls.forEach(control => { if (!control.value) control.setValue(null) }) - } else if (valueSpec.subtype === 'object') { + } else if (valueSpec.spec.type === 'object') { controls.forEach(formGroup => { const objectSpec = valueSpec.spec as ListValueSpecObject convertValuesRecursive(objectSpec.spec, formGroup as UntypedFormGroup)