From 72a0c7f0fd6e3ed77d6a31b0b4a550dad5331876 Mon Sep 17 00:00:00 2001 From: kulgg <75735874+kulgg@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:56:20 +0200 Subject: [PATCH] chore: DRY data offer form (#779) --- .../edit-asset-form-input.component.html | 31 ++ .../edit-asset-form-input.component.ts | 17 + .../edit-asset-form-textarea.component.html | 19 + .../edit-asset-form-textarea.component.ts | 18 + .../edit-asset-form/edit-asset-form.module.ts | 4 + .../edit-asset-form.component.html | 487 ++++++------------ .../property-grid.component.html | 68 +-- src/app/core/validators/url-validator.ts | 14 +- ...t-agreement-transfer-dialog.component.html | 2 +- 9 files changed, 283 insertions(+), 377 deletions(-) create mode 100644 src/app/component-library/edit-asset-form/edit-asset-form-input/edit-asset-form-input.component.html create mode 100644 src/app/component-library/edit-asset-form/edit-asset-form-input/edit-asset-form-input.component.ts create mode 100644 src/app/component-library/edit-asset-form/edit-asset-form-textarea/edit-asset-form-textarea.component.html create mode 100644 src/app/component-library/edit-asset-form/edit-asset-form-textarea/edit-asset-form-textarea.component.ts diff --git a/src/app/component-library/edit-asset-form/edit-asset-form-input/edit-asset-form-input.component.html b/src/app/component-library/edit-asset-form/edit-asset-form-input/edit-asset-form-input.component.html new file mode 100644 index 000000000..df8414a1e --- /dev/null +++ b/src/app/component-library/edit-asset-form/edit-asset-form-input/edit-asset-form-input.component.html @@ -0,0 +1,31 @@ + + + + + + {{ validationMessages.invalidUrlMessage }} + + + {{ validationMessages.invalidEmailMessage }} + + + {{ validationMessages.invalidWhitespacesOrColonsMessage }} + + + {{ validationMessages.invalidPrefix('ID', 'urn:artifact') }} + + + {{ ctrl.errors?.exists }} + + + + + diff --git a/src/app/component-library/edit-asset-form/edit-asset-form-input/edit-asset-form-input.component.ts b/src/app/component-library/edit-asset-form/edit-asset-form-input/edit-asset-form-input.component.ts new file mode 100644 index 000000000..3e53805fc --- /dev/null +++ b/src/app/component-library/edit-asset-form/edit-asset-form-input/edit-asset-form-input.component.ts @@ -0,0 +1,17 @@ +import {Component, Input} from '@angular/core'; +import {FormControl} from '@angular/forms'; +import {ValidationMessages} from 'src/app/core/validators/validation-messages'; + +@Component({ + selector: 'edit-asset-form-input', + templateUrl: './edit-asset-form-input.component.html', +}) +export class EditAssetFormInputComponent { + @Input() ctrl!: FormControl; + @Input() fieldId = 'missing-id-' + Math.random().toString(36).substring(7); + @Input() label!: string; + @Input() placeholder: string = '...'; + @Input() hideHint: boolean = false; + + constructor(public validationMessages: ValidationMessages) {} +} diff --git a/src/app/component-library/edit-asset-form/edit-asset-form-textarea/edit-asset-form-textarea.component.html b/src/app/component-library/edit-asset-form/edit-asset-form-textarea/edit-asset-form-textarea.component.html new file mode 100644 index 000000000..01917df80 --- /dev/null +++ b/src/app/component-library/edit-asset-form/edit-asset-form-textarea/edit-asset-form-textarea.component.html @@ -0,0 +1,19 @@ + + + + + + {{ validationMessages.invalidJsonMessage }} + + + + + diff --git a/src/app/component-library/edit-asset-form/edit-asset-form-textarea/edit-asset-form-textarea.component.ts b/src/app/component-library/edit-asset-form/edit-asset-form-textarea/edit-asset-form-textarea.component.ts new file mode 100644 index 000000000..93d1ee63e --- /dev/null +++ b/src/app/component-library/edit-asset-form/edit-asset-form-textarea/edit-asset-form-textarea.component.ts @@ -0,0 +1,18 @@ +import {Component, Input} from '@angular/core'; +import {FormControl} from '@angular/forms'; +import {ValidationMessages} from 'src/app/core/validators/validation-messages'; + +@Component({ + selector: 'edit-asset-form-textarea', + templateUrl: './edit-asset-form-textarea.component.html', +}) +export class EditAssetFormTextareaComponent { + @Input() ctrl!: FormControl; + @Input() fieldId = 'missing-id-' + Math.random().toString(36).substring(7); + @Input() label!: string; + @Input() placeholder: string = '...'; + @Input() hideHint: boolean = false; + @Input() textareaClasses: string = 'h-36'; + + constructor(public validationMessages: ValidationMessages) {} +} diff --git a/src/app/component-library/edit-asset-form/edit-asset-form.module.ts b/src/app/component-library/edit-asset-form/edit-asset-form.module.ts index cef836df3..47d79dac2 100644 --- a/src/app/component-library/edit-asset-form/edit-asset-form.module.ts +++ b/src/app/component-library/edit-asset-form/edit-asset-form.module.ts @@ -30,7 +30,9 @@ import {DataSubcategoryItemsPipe} from './data-subcategory-select/data-subcatego import {DataSubcategorySelectComponent} from './data-subcategory-select/data-subcategory-select.component'; import {EditAssetFormDataAddressTypeSelectComponent} from './edit-asset-form-data-address-type-select/edit-asset-form-data-address-type-select.component'; import {EditAssetFormGroupComponent} from './edit-asset-form-group/edit-asset-form-group.component'; +import {EditAssetFormInputComponent} from './edit-asset-form-input/edit-asset-form-input.component'; import {EditAssetFormLabelComponent} from './edit-asset-form-label/edit-asset-form-label.component'; +import {EditAssetFormTextareaComponent} from './edit-asset-form-textarea/edit-asset-form-textarea.component'; import {EditAssetFormComponent} from './edit-asset-form/edit-asset-form.component'; import {KeywordSelectComponent} from './keyword-select/keyword-select.component'; import {LanguageSelectComponent} from './language-select/language-select.component'; @@ -75,6 +77,8 @@ import {TransportModeSelectComponent} from './transport-mode-select/transport-mo EditAssetFormComponent, EditAssetFormGroupComponent, EditAssetFormLabelComponent, + EditAssetFormInputComponent, + EditAssetFormTextareaComponent, KeywordSelectComponent, DataCategorySelectComponent, DataSubcategorySelectComponent, diff --git a/src/app/component-library/edit-asset-form/edit-asset-form/edit-asset-form.component.html b/src/app/component-library/edit-asset-form/edit-asset-form/edit-asset-form.component.html index 82f9c2d2e..da2054554 100644 --- a/src/app/component-library/edit-asset-form/edit-asset-form/edit-asset-form.component.html +++ b/src/app/component-library/edit-asset-form/edit-asset-form/edit-asset-form.component.html @@ -31,57 +31,27 @@ -
- - - - - {{ validationMessages.invalidEmailMessage }} - - - This email address will be offered to potential consumers for - contacting you. This is done in place of having an actual data - source connected. - - -
+ This email address will be offered to potential consumers for + contacting you. This is done in place of having an actual data source + connected. -
- - - - - Will be added to the mailto-link and displayed to potential - consumers to use. - - -
+ Will be added to the mailto-link and displayed to potential consumers + to use.
-
- - - - - {{ validationMessages.invalidJsonMessage }} - - -
+ " + label="Custom Datasource Config (JSON)" + fieldId="create-asset-form-custom-datasource-json" + placeholder='{"https://w3id.org/edc/v0.0.1/ns/type": "HttpData", ...}' + [ctrl]="ctrl"> @@ -163,25 +121,17 @@
- - - - - {{ validationMessages.invalidUrlMessage }} - - - The consuming side must provide a Custom HTTP Subpath - with method parameterization enabled. The Custom HTTP Subpath - will be appended to the base path. - - + >The consuming side must provide a Custom HTTP Subpath with + method parameterization enabled. The Custom HTTP Subpath will be + appended to the base path. +
-
- - - - -
+ -
- - - - - {{ validationMessages.invalidWhitespacesOrColonsMessage }} - - - {{ validationMessages.invalidPrefix('ID', 'urn:artifact') }} - - - {{ ctrl.errors?.exists }} - - -
+ -
- - - - - The description uses - Markdown syntax - - -
+ +
+ The description uses + Markdown syntax +
+
@@ -528,27 +444,17 @@ -
- - - - -
+ -
- -
+
@@ -583,19 +489,11 @@ "> -
- - - - -
+ @@ -604,38 +502,20 @@ myTitle="Documentation" description="Provide context information about the datasource"> -
- - - - -
+ -
- - - - -
+ @@ -708,29 +588,16 @@
-
- - - - Additional information regarding the reference files - - -
+ class="mt-2" + textareaClasses="h-28" + label="Reference files description" + fieldId="edit-asset-form-reference-files-description" + placeholder="..." + [ctrl]="form.advanced.controls.referenceFilesDescription"> + Additional information regarding the reference files + @@ -767,53 +634,30 @@
-
- - - - -
+ -
- - - - -
+ -
- - - - -
+
@@ -853,78 +697,41 @@ myTitle="Legal Information" description="Provide legal information and define the conditions for use"> -
- - - - Legal name of the data owner - -
+ Legal name of the data owner -
- - - - -
+ -
- - - - -
+ -
- - - - Additional not legally relevant usage instructions (e.g. how to - cite the dataset) - - -
+ + Additional not legally relevant usage instructions (e.g. how to cite the + dataset) + - - - - - {{ prop.text }} - - {{ prop.text }}Show {{ prop.label }} - - + + + + + {{ prop.text }} + Show {{ prop.label }}{{ prop.text }} - {{ prop.text }} - - {{ prop.textIconAfter }} - - + + + {{ prop.text }} + + {{ prop.textIconAfter }} + + +