Visualize Save/Unsaved Status in Tabs (Editor)
All checks were successful
E2E Testing / test (push) Successful in 1m24s

This commit is contained in:
Sebastian Böckelmann 2024-02-05 17:59:20 +01:00
parent 36391326ea
commit 4bf897e85b
7 changed files with 38 additions and 4 deletions

View File

@ -1,9 +1,9 @@
<mat-tab-group> <mat-tab-group>
<mat-tab *ngFor="let modelComponent of gameModelComponents"> <mat-tab *ngFor="let modelComponent of gameModelComponents">
<ng-template mat-tab-label> <ng-template mat-tab-label>
<mat-icon class="example-tab-icon">inventory_2</mat-icon> <mat-icon class="example-tab-icon unsaved" [ngClass]="modelComponent.unsaved? 'unsaved':'saved'">inventory_2</mat-icon>
<span>{{modelComponent.componentName}}</span> <span [ngClass]="modelComponent.unsaved? 'unsaved':'saved'">{{modelComponent.componentName}}</span>
<button class="content-label" mat-icon-button (click)="closeGameModelComponent(modelComponent)"><mat-icon>close</mat-icon></button> <button class="content-label close-btn" 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-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"

View File

@ -0,0 +1,11 @@
.unsaved {
color: red;
}
.saved {
color: #3c95f8;
}
.close-btn {
color: white
}

View File

@ -20,10 +20,12 @@ export class ModelComponentEditorComponent implements OnInit{
onUpdateName() { onUpdateName() {
this.modelComponent!.componentName = this.nameCtrl.value; this.modelComponent!.componentName = this.nameCtrl.value;
this.modelComponent!.onModifyContent();
} }
onUpdateDescription() { onUpdateDescription() {
this.modelComponent!.componentDescription = this.descriptionCtrl.value; this.modelComponent!.componentDescription = this.descriptionCtrl.value;
this.modelComponent!.onModifyContent();
} }
protected readonly name = name; protected readonly name = name;

View File

@ -39,9 +39,11 @@ export class ScriptAccountEditorComponent implements OnInit{
onUpdateMinValue() { onUpdateMinValue() {
this.scriptAccount!.minValue = Number(this.minCtrl.value); this.scriptAccount!.minValue = Number(this.minCtrl.value);
this.scriptAccount!.onModifyContent();
} }
onUpdateMaxValue() { onUpdateMaxValue() {
this.scriptAccount!.maxValue = Number(this.maxCtrl.value); this.scriptAccount!.maxValue = Number(this.maxCtrl.value);
this.scriptAccount!.onModifyContent();
} }
} }

View File

@ -1,10 +1,12 @@
import {ModelComponentType} from "./ModelComponentType"; import {ModelComponentType} from "./ModelComponentType";
import {SaveComponent} from "./SaveComponent";
export abstract class ModelComponent { export abstract class ModelComponent extends SaveComponent{
componentName: string componentName: string
componentDescription: string componentDescription: string
type: ModelComponentType type: ModelComponentType
constructor(componentName: string, componentDescription: string, type: ModelComponentType) { constructor(componentName: string, componentDescription: string, type: ModelComponentType) {
super();
this.componentName = componentName; this.componentName = componentName;
this.componentDescription = componentDescription; this.componentDescription = componentDescription;
this.type = type; this.type = type;

View File

@ -0,0 +1,13 @@
export abstract class SaveComponent {
unsaved: boolean = false;
onModifyContent() {
this.unsaved = true;
}
onSaveContent() {
this.unsaved = false;
}
abstract save(): void;
}

View File

@ -7,4 +7,8 @@ export class ScriptAccount extends ModelComponent{
constructor(componentName: string, componentDescription: string) { constructor(componentName: string, componentDescription: string) {
super(componentName, componentDescription, ModelComponentType.SCRIPTACCOUNT); super(componentName, componentDescription, ModelComponentType.SCRIPTACCOUNT);
} }
save(): void {
}
} }