Skip to content

Commit

Permalink
Fixed missing schema form input for lists and strings
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Dec 16, 2023
1 parent 7f5e651 commit 4abe87f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ThemeRegistryService } from '../../../services';
})
export class SchemaFormItemInputComponent {
@Input() item?: SchemaFormProperty;
@Input() data = '';
@Input() data: string | undefined;

@Output() dataChange = new EventEmitter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { JSONSchema6 } from 'json-schema';
})
export class SchemaFormItemListComponent {
@Input() item?: SchemaFormProperty;
@Input() data: unknown[] = [];
@Input() data: unknown[] | undefined;

@Output() dataChange = new EventEmitter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
</ng-container>
<ng-container *ngSwitchCase="'string'">
<app-schema-form-item-input
*ngIf="isString(data)"
*ngIf="isStringOrUndefined(data)"
[item]="item"
[(data)]="data"
(dataChange)="onInput($event, item)"
></app-schema-form-item-input>
</ng-container>
<ng-container *ngSwitchCase="'array'">
<app-schema-form-item-list
*ngIf="isArray(data)"
*ngIf="isArrayOrUndefined(data)"
[item]="item"
[(data)]="data"
(dataChange)="onInput($event, item)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,25 @@ export class SchemaFormItemComponent {
return typeof data === 'string';
}

isStringOrUndefined(data: unknown): data is string | undefined {
return typeof data === 'string' || typeof data === 'undefined';
}

isArray(data: unknown): data is unknown[] {
return Array.isArray(data);
}

isArrayOrUndefined(data: unknown): data is unknown[] | undefined {
return Array.isArray(data) || typeof data === 'undefined';
}

asArrayOrUndefined(data: unknown): unknown[] | undefined {
if (Array.isArray(data)) {
return data;
}
return undefined;
}

onInput(event: Event, item: SchemaFormProperty) {
// console.log(event, item);
this.dataChange.next(this.data);
Expand Down
2 changes: 0 additions & 2 deletions site/src/.vuepress/theme/components/Contributions.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<template>
<iframe src="https://altairgraphql.substack.com/embed" width="480" height="320" style="border:1px solid #EEE; background:var(--theme-bg-color);" frameborder="0" scrolling="no"></iframe>

<div class="contributions">

<template
Expand Down
15 changes: 5 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22934,10 +22934,10 @@ oauth-sign@~0.9.0:
resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455"
integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==

oauth@0.9.x:
version "0.9.15"
resolved "https://registry.yarnpkg.com/oauth/-/oauth-0.9.15.tgz#bd1fefaf686c96b75475aed5196412ff60cfb9c1"
integrity sha512-a5ERWK1kh38ExDEfoO6qUHJb32rd7aYmPHuyCu3Fta/cnICvYmgd2uhuKXvPD+PXB+gCEYYEaQdIRAjCOwAKNA==
oauth@0.10.0, oauth@0.9.x:
version "0.10.0"
resolved "https://registry.yarnpkg.com/oauth/-/oauth-0.10.0.tgz#3551c4c9b95c53ea437e1e21e46b649482339c58"
integrity sha512-1orQ9MT1vHFGQxhuy7E/0gECD3fd2fCC+PIX+/jgmU/gI3EpRocXtmtvxCO5x3WZ443FLTLFWNDjl5MPJf9u+Q==

object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1:
version "4.1.1"
Expand Down Expand Up @@ -30298,16 +30298,11 @@ xxhashjs@~0.2.2:
dependencies:
cuint "^0.2.2"

y18n@^4.0.0:
y18n@4.0.1, y18n@^4.0.0, y18n@^5.0.5:
version "4.0.1"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4"
integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==

y18n@^5.0.5:
version "5.0.8"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==

yaeti@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/yaeti/-/yaeti-0.0.6.tgz#f26f484d72684cf42bedfb76970aa1608fbf9577"
Expand Down

0 comments on commit 4abe87f

Please sign in to comment.