diff --git a/src/app/project-administration/project-edit/project-edit.component.html b/src/app/project-administration/project-edit/project-edit.component.html index 5acc17a7e..28e4a0c19 100644 --- a/src/app/project-administration/project-edit/project-edit.component.html +++ b/src/app/project-administration/project-edit/project-edit.component.html @@ -21,6 +21,8 @@
{{ data.Name }}
{{ data.Name }}
{{ data.Name }}
{{ data.Name }}
- +
diff --git a/src/app/project-administration/project-edit/project-edit.component.ts b/src/app/project-administration/project-edit/project-edit.component.ts index a55e6260f..514dfc840 100644 --- a/src/app/project-administration/project-edit/project-edit.component.ts +++ b/src/app/project-administration/project-edit/project-edit.component.ts @@ -15,7 +15,6 @@ import { ProjectInterface } from '../project/project.interface'; export class ProjectEditComponent implements OnInit, Resource { public data$!: Observable; public projectId!: string; - constructor(private route: ActivatedRoute, private service: BackendService) {} ngOnInit(): void { diff --git a/src/app/shared/atomic-components/BaseAtomicComponent.class.ts b/src/app/shared/atomic-components/BaseAtomicComponent.class.ts index b3c694cc7..63204de0f 100644 --- a/src/app/shared/atomic-components/BaseAtomicComponent.class.ts +++ b/src/app/shared/atomic-components/BaseAtomicComponent.class.ts @@ -1,4 +1,5 @@ import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; +import { Resource } from '../interfacing/resource.interface'; @Component({ template: '', @@ -8,6 +9,15 @@ export abstract class BaseAtomicComponent implements OnInit, OnChanges { // TODO Refactor to combination of parent-propertyName. We need a link to the parent anyway property: T | Array | null = null; + @Input() + // The type of the T for Resource is not relevant nor to be determined here; therefore unknown + // We require a Resource, that implements the required methods (like patch) + // Most likely this is a top-level component for a specific application interface (e.g. ProjectComponent) + resource!: Resource; + + @Input() + propertyName!: string; + public data: Array = []; private _isUni: boolean = false; diff --git a/src/app/shared/atomic-components/atomic-alphanumeric/atomic-alphanumeric.component.ts b/src/app/shared/atomic-components/atomic-alphanumeric/atomic-alphanumeric.component.ts index 74f0fc5e4..3ab131041 100644 --- a/src/app/shared/atomic-components/atomic-alphanumeric/atomic-alphanumeric.component.ts +++ b/src/app/shared/atomic-components/atomic-alphanumeric/atomic-alphanumeric.component.ts @@ -1,8 +1,6 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { BaseAtomicComponent } from '../BaseAtomicComponent.class'; import { FormControl } from '@angular/forms'; -import { debounceTime, distinctUntilChanged, map, tap } from 'rxjs'; -import { Resource } from '../../interfacing/resource.interface'; @Component({ selector: 'app-atomic-alphanumeric', @@ -10,38 +8,24 @@ import { Resource } from '../../interfacing/resource.interface'; styleUrls: ['./atomic-alphanumeric.component.css'], }) export class AtomicAlphanumericComponent extends BaseAtomicComponent implements OnInit { + // make generic and put in BaseAtomicComponent class formControl!: FormControl; newItemControl: FormControl = new FormControl('', { nonNullable: true, updateOn: 'blur' }); - @Input() - // The type of the T for Resource is not relevant nor to determine here; therefore unknow - // We require a Resource, that implements the required methods (like patch) - // Most likely this is a top-level component for a specific application interface (e.g. ProjectComponent) - resource!: Resource; // TODO move to the base class. It is needed for all atomic components - - @Input() - propertyName!: string; // TODO move to the base class. It is needed for all atomic components - override ngOnInit(): void { super.ngOnInit(); this.formControl = new FormControl(this.data[0], { nonNullable: false, updateOn: 'blur' }); - this.formControl.valueChanges - .pipe( - debounceTime(300), - distinctUntilChanged(), - map((x) => (x === '' ? null : x)), // transform empty string to null value - ) - .subscribe((x) => - this.resource - .patch([ - { - op: 'replace', - path: this.propertyName, // FIXME: this must be relative to path of this.resource - value: x, - }, - ]) - .subscribe(), - ); + this.formControl.valueChanges.subscribe((x) => + this.resource + .patch([ + { + op: 'replace', + path: this.propertyName, // FIXME: this must be relative to path of this.resource + value: x, + }, + ]) + .subscribe(), + ); } } diff --git a/src/app/shared/atomic-components/atomic-bigalphanumeric/atomic-bigalphanumeric.component.html b/src/app/shared/atomic-components/atomic-bigalphanumeric/atomic-bigalphanumeric.component.html index c5486e079..d9bc8b819 100644 --- a/src/app/shared/atomic-components/atomic-bigalphanumeric/atomic-bigalphanumeric.component.html +++ b/src/app/shared/atomic-components/atomic-bigalphanumeric/atomic-bigalphanumeric.component.html @@ -3,7 +3,7 @@