From b2ddfc94c360e34d0c3a66d9a044cd9273a2b694 Mon Sep 17 00:00:00 2001 From: Christoph Kappestein Date: Sun, 3 Nov 2024 21:18:54 +0100 Subject: [PATCH] add type links --- .../typeschema-angular-editor/package.json | 2 +- .../src/lib/editor/editor.component.html | 35 +++++++++++-------- .../src/lib/editor/editor.component.ts | 14 ++++++++ .../src/lib/editor/link/link.component.css | 0 .../src/lib/editor/link/link.component.html | 7 ++++ .../src/lib/editor/link/link.component.ts | 18 ++++++++++ .../src/lib/typeschema-editor.module.ts | 2 ++ 7 files changed, 63 insertions(+), 15 deletions(-) create mode 100644 projects/typeschema-angular-editor/src/lib/editor/link/link.component.css create mode 100644 projects/typeschema-angular-editor/src/lib/editor/link/link.component.html create mode 100644 projects/typeschema-angular-editor/src/lib/editor/link/link.component.ts diff --git a/projects/typeschema-angular-editor/package.json b/projects/typeschema-angular-editor/package.json index 78a0f1e..c4f3425 100644 --- a/projects/typeschema-angular-editor/package.json +++ b/projects/typeschema-angular-editor/package.json @@ -1,6 +1,6 @@ { "name": "ngx-typeschema-editor", - "version": "3.0.6", + "version": "3.0.7", "description": "Editor to model and design a TypeAPI/TypeSchema specification", "keywords": [ "TypeAPI", diff --git a/projects/typeschema-angular-editor/src/lib/editor/editor.component.html b/projects/typeschema-angular-editor/src/lib/editor/editor.component.html index d18f652..31fa502 100644 --- a/projects/typeschema-angular-editor/src/lib/editor/editor.component.html +++ b/projects/typeschema-angular-editor/src/lib/editor/editor.component.html @@ -92,7 +92,7 @@ {{ argument.name }} - {{ argument.type }} + {{ argument.in }} @@ -107,10 +107,10 @@ payload - Array<{{ operation.payload }}> - Map<string, {{ operation.payload }}> + Array<> + Map<string, > {{ operation.payload }} - {{ operation.payload }} + body @@ -141,10 +141,10 @@ {{ operation.httpCode }} - Array<{{ operation.return }}> - Map<string, {{ operation.return }}> + Array<> + Map<string, > {{ operation.return }} - {{ operation.return }} + @@ -153,10 +153,10 @@ {{ throw_.code }} - Array<{{ throw_.type }}> - Map<string, {{ throw_.type }}> + Array<> + Map<string, > {{ throw_.type }} - {{ throw_.type }} + @@ -184,7 +184,10 @@
-
{{ type.name }} {{ type.parent }}
+
+ {{ type.name }} + +
{{ type.description }}
@@ -206,7 +209,7 @@
*
- {{ type.reference }} + @@ -233,7 +236,9 @@ {{ mapping.value }}
- {{ mapping.key }} + + +
@@ -266,7 +271,9 @@ {{ property.type }} - {{ property.reference }} + + + {{ property.generic }} {{ property.format }} diff --git a/projects/typeschema-angular-editor/src/lib/editor/editor.component.ts b/projects/typeschema-angular-editor/src/lib/editor/editor.component.ts index b7fce4e..e0fc2ba 100644 --- a/projects/typeschema-angular-editor/src/lib/editor/editor.component.ts +++ b/projects/typeschema-angular-editor/src/lib/editor/editor.component.ts @@ -451,6 +451,20 @@ export class EditorComponent implements OnInit { return null; } + isLinkableType(typeName: string): boolean { + if (typeName === 'string' || typeName === 'number' || typeName === 'integer' || typeName === 'boolean' || typeName === 'generic' || typeName === 'any') { + return false; + } + + for (let i = 0; i < this.specification.types.length; i++) { + if (this.specification.types[i].name === typeName) { + return true; + } + } + + return false; + } + findTypeByName(typeName: string): Type|null { for (let i = 0; i < this.specification.types.length; i++) { if (this.specification.types[i].name === typeName) { diff --git a/projects/typeschema-angular-editor/src/lib/editor/link/link.component.css b/projects/typeschema-angular-editor/src/lib/editor/link/link.component.css new file mode 100644 index 0000000..e69de29 diff --git a/projects/typeschema-angular-editor/src/lib/editor/link/link.component.html b/projects/typeschema-angular-editor/src/lib/editor/link/link.component.html new file mode 100644 index 0000000..2b955fa --- /dev/null +++ b/projects/typeschema-angular-editor/src/lib/editor/link/link.component.html @@ -0,0 +1,7 @@ + + + {{ type }} + + + {{ type }} + diff --git a/projects/typeschema-angular-editor/src/lib/editor/link/link.component.ts b/projects/typeschema-angular-editor/src/lib/editor/link/link.component.ts new file mode 100644 index 0000000..b37b087 --- /dev/null +++ b/projects/typeschema-angular-editor/src/lib/editor/link/link.component.ts @@ -0,0 +1,18 @@ +import {Component, Input, OnInit} from '@angular/core'; + +@Component({ + selector: 'typeschema-link', + templateUrl: './link.component.html', + styleUrls: ['./link.component.css'] +}) +export class LinkComponent implements OnInit { + + @Input() type!: string; + @Input() linkable!: boolean; + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/projects/typeschema-angular-editor/src/lib/typeschema-editor.module.ts b/projects/typeschema-angular-editor/src/lib/typeschema-editor.module.ts index 72ad88f..4bfdc11 100644 --- a/projects/typeschema-angular-editor/src/lib/typeschema-editor.module.ts +++ b/projects/typeschema-angular-editor/src/lib/typeschema-editor.module.ts @@ -4,6 +4,7 @@ import {NgbModule} from "@ng-bootstrap/ng-bootstrap"; import {CommonModule} from "@angular/common"; import {FormsModule} from "@angular/forms"; import {ArgumentComponent} from "./editor/argument/argument.component"; +import {LinkComponent} from "./editor/link/link.component"; import {TagsComponent} from "./editor/tags/tags.component"; import {CsvPipe} from "./editor/tags/csv.pipe"; import {ThrowComponent} from "./editor/throw/throw.component"; @@ -12,6 +13,7 @@ import {ThrowComponent} from "./editor/throw/throw.component"; declarations: [ ArgumentComponent, CsvPipe, + LinkComponent, TagsComponent, ThrowComponent, EditorComponent