Edit abstract ModelComponent Information
All checks were successful
E2E Testing / test (push) Successful in 1m21s

This commit is contained in:
Sebastian Böckelmann 2024-01-27 12:17:43 +01:00
parent 7a490d4c88
commit 7680cd7edd
6 changed files with 71 additions and 2 deletions

View File

@ -25,6 +25,7 @@ import {MatActionList, MatListItem} from "@angular/material/list";
import {EditorComponent} from "./editor/editor.component"; import {EditorComponent} from "./editor/editor.component";
import {MatTab, MatTabGroup, MatTabLabel} from "@angular/material/tabs"; import {MatTab, MatTabGroup, MatTabLabel} from "@angular/material/tabs";
import {ScriptAccountEditorComponent} from "./editor/script-account-editor/script-account-editor.component"; import {ScriptAccountEditorComponent} from "./editor/script-account-editor/script-account-editor.component";
import {ModelComponentEditorComponent} from "./editor/model-component-editor/model-component-editor.component";
// AoT requires an exported function for factories // AoT requires an exported function for factories
const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json'); const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json');
@ -34,7 +35,8 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl
AppComponent, AppComponent,
ScriptAccountOverviewComponent, ScriptAccountOverviewComponent,
EditorComponent, EditorComponent,
ScriptAccountEditorComponent ScriptAccountEditorComponent,
ModelComponentEditorComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
@ -69,7 +71,8 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl
MatLabel, MatLabel,
MatFormField, MatFormField,
ReactiveFormsModule, ReactiveFormsModule,
MatError MatError,
], ],
providers: [], providers: [],
bootstrap: [AppComponent] bootstrap: [AppComponent]

View File

@ -5,6 +5,7 @@
<span>{{modelComponent.componentName}}</span> <span>{{modelComponent.componentName}}</span>
<button class="content-label" mat-icon-button (click)="closeGameModelComponent(modelComponent)"><mat-icon>close</mat-icon></button> <button class="content-label" mat-icon-button (click)="closeGameModelComponent(modelComponent)"><mat-icon>close</mat-icon></button>
</ng-template> </ng-template>
<app-model-component-editor [modelComponent]="modelComponent"></app-model-component-editor>
<app-script-account-editor *ngIf="modelComponent.type === ModelComponentType.SCRIPTACCOUNT" <app-script-account-editor *ngIf="modelComponent.type === ModelComponentType.SCRIPTACCOUNT"
[scriptAccount]="convertModelComponentToScriptAccount(modelComponent)"></app-script-account-editor> [scriptAccount]="convertModelComponentToScriptAccount(modelComponent)"></app-script-account-editor>

View File

@ -0,0 +1,9 @@
<mat-form-field appearance="fill" class="long-form">
<mat-label>Name</mat-label>
<input matInput [formControl]="nameCtrl" (change)="onUpdateName()">
<mat-error *ngIf="nameCtrl.hasError('required')">Please enter a valid number!</mat-error>
</mat-form-field>
<mat-form-field appearance="fill" class="long-form">
<mat-label>Description</mat-label>
<textarea matInput [formControl]="descriptionCtrl" (change)="onUpdateDescription()" rows="3"></textarea>
</mat-form-field>

View File

@ -0,0 +1,3 @@
.long-form {
width: 100%;
}

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ModelComponentEditorComponent } from './model-component-editor.component';
describe('ModelComponentEditorComponent', () => {
let component: ModelComponentEditorComponent;
let fixture: ComponentFixture<ModelComponentEditorComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ModelComponentEditorComponent]
})
.compileComponents();
fixture = TestBed.createComponent(ModelComponentEditorComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,30 @@
import {Component, Input, OnInit} 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
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;
}
onUpdateDescription() {
this.modelComponent!.componentDescription = this.descriptionCtrl.value;
}
protected readonly name = name;
}