ConceptCreator/src/app/editor/model-component-editor/model-component-editor.component.ts
Sebastian Böckelmann b09e9351e0
All checks were successful
E2E Testing / test (push) Successful in 1m25s
Edit Name of ModelComponent in Overview (Gamesystems did not apply updated name bcs of Datasource outdated)
2024-02-09 20:46:00 +01:00

35 lines
1.2 KiB
TypeScript

import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {ModelComponent} from "../../game-model/ModelComponent";
import {FormControl, Validators} from "@angular/forms";
@Component({
selector: 'app-model-component-editor',
templateUrl: './model-component-editor.component.html',
styleUrl: './model-component-editor.component.scss'
})
export class ModelComponentEditorComponent implements OnInit{
@Input('modelComponent') modelComponent: ModelComponent | undefined
@Output("onModelNameUpdated") onModelNameUpdateEmitter = new EventEmitter<boolean>();
nameCtrl: FormControl = new FormControl('', [Validators.required]);
descriptionCtrl: FormControl = new FormControl('' );
ngOnInit() {
this.nameCtrl.setValue(this.modelComponent!.componentName);
this.descriptionCtrl.setValue(this.modelComponent!.componentDescription);
}
onUpdateName() {
this.modelComponent!.componentName = this.nameCtrl.value;
this.modelComponent!.onModifyContent();
this.onModelNameUpdateEmitter.emit(true);
}
onUpdateDescription() {
this.modelComponent!.componentDescription = this.descriptionCtrl.value;
this.modelComponent!.onModifyContent();
}
protected readonly name = name;
}