Open and Close ScriptAccounts in Editor
All checks were successful
E2E Testing / test (push) Successful in 1m20s
All checks were successful
E2E Testing / test (push) Successful in 1m20s
This commit is contained in:
parent
89fe9e1282
commit
89e430c179
@ -19,11 +19,11 @@
|
|||||||
<button mat-menu-item (click)="openScriptAccountsOverview()">{{ModelComponentTypeUtillities.toString(ModelComponentType.SCRIPTACCOUNT)}}</button>
|
<button mat-menu-item (click)="openScriptAccountsOverview()">{{ModelComponentTypeUtillities.toString(ModelComponentType.SCRIPTACCOUNT)}}</button>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
</div>
|
</div>
|
||||||
<app-script-account-overview [gameModel]="gameModel"></app-script-account-overview>
|
<app-script-account-overview [gameModel]="gameModel" (onOpenScriptAccount)="openModelComponent($event)"></app-script-account-overview>
|
||||||
</mat-drawer>
|
</mat-drawer>
|
||||||
|
|
||||||
<div class="example-sidenav-content">
|
<div class="example-sidenav-content">
|
||||||
<app-editor></app-editor>
|
<app-editor #editor></app-editor>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</mat-drawer-container>
|
</mat-drawer-container>
|
||||||
|
@ -6,6 +6,8 @@ import {MatDrawerContainer} from "@angular/material/sidenav";
|
|||||||
import {ModelComponentTypeUtillities} from "./game-model/ModelComponentTypeUtillities";
|
import {ModelComponentTypeUtillities} from "./game-model/ModelComponentTypeUtillities";
|
||||||
import {GameModel} from "./game-model/GameModel";
|
import {GameModel} from "./game-model/GameModel";
|
||||||
import {ScriptAccount} from "./game-model/scriptAccounts/ScriptAccount";
|
import {ScriptAccount} from "./game-model/scriptAccounts/ScriptAccount";
|
||||||
|
import {EditorComponent} from "./editor/editor.component";
|
||||||
|
import {ModelComponent} from "./game-model/ModelComponent";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@ -16,6 +18,7 @@ export class AppComponent implements OnInit{
|
|||||||
|
|
||||||
openContent : ModelComponentType | undefined = undefined;
|
openContent : ModelComponentType | undefined = undefined;
|
||||||
@ViewChild('drawer') drawer: MatDrawerContainer|undefined
|
@ViewChild('drawer') drawer: MatDrawerContainer|undefined
|
||||||
|
@ViewChild('editor') editor: EditorComponent|undefined
|
||||||
|
|
||||||
gameModel: GameModel | undefined
|
gameModel: GameModel | undefined
|
||||||
|
|
||||||
@ -53,4 +56,13 @@ export class AppComponent implements OnInit{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected readonly ModelComponentTypeUtillities = ModelComponentTypeUtillities;
|
protected readonly ModelComponentTypeUtillities = ModelComponentTypeUtillities;
|
||||||
|
|
||||||
|
openModelComponent(modelComponent: ModelComponent) {
|
||||||
|
if(this.editor != undefined) {
|
||||||
|
this.editor.openGameModelComponent(modelComponent);
|
||||||
|
} else {
|
||||||
|
console.log("[WARN] [App.Component] Editor is undefined")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import {
|
|||||||
} from "./side-overviews/script-account-overview/script-account-overview.component";
|
} from "./side-overviews/script-account-overview/script-account-overview.component";
|
||||||
import {MatActionList, MatListItem} from "@angular/material/list";
|
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";
|
||||||
|
|
||||||
// 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');
|
||||||
@ -60,6 +61,9 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl
|
|||||||
MatMenuItem,
|
MatMenuItem,
|
||||||
MatListItem,
|
MatListItem,
|
||||||
MatActionList,
|
MatActionList,
|
||||||
|
MatTabGroup,
|
||||||
|
MatTab,
|
||||||
|
MatTabLabel,
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
|
@ -1 +1,9 @@
|
|||||||
<p>editor works!</p>
|
<mat-tab-group>
|
||||||
|
<mat-tab *ngFor="let modelComponent of gameModelComponents">
|
||||||
|
<ng-template mat-tab-label>
|
||||||
|
<mat-icon class="example-tab-icon">inventory_2</mat-icon>
|
||||||
|
<span>{{modelComponent.componentName}}</span>
|
||||||
|
<button class="content-label" mat-icon-button (click)="closeGameModelComponent(modelComponent)"><mat-icon>close</mat-icon></button>
|
||||||
|
</ng-template>
|
||||||
|
</mat-tab>
|
||||||
|
</mat-tab-group>
|
||||||
|
@ -1,23 +1,53 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
|
||||||
|
|
||||||
import { EditorComponent } from './editor.component';
|
import { EditorComponent } from './editor.component';
|
||||||
|
import {ScriptAccount} from "../game-model/scriptAccounts/ScriptAccount";
|
||||||
|
import {TranslateModule} from "@ngx-translate/core";
|
||||||
|
import {RouterTestingModule} from "@angular/router/testing";
|
||||||
|
|
||||||
describe('EditorComponent', () => {
|
describe('EditorComponent', () => {
|
||||||
let component: EditorComponent;
|
let component: EditorComponent;
|
||||||
let fixture: ComponentFixture<EditorComponent>;
|
let fixture: ComponentFixture<EditorComponent>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(waitForAsync(() => {
|
||||||
await TestBed.configureTestingModule({
|
void TestBed.configureTestingModule({
|
||||||
imports: [EditorComponent]
|
declarations: [EditorComponent],
|
||||||
})
|
imports: [TranslateModule.forRoot(), RouterTestingModule]
|
||||||
.compileComponents();
|
}).compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(EditorComponent);
|
fixture = TestBed.createComponent(EditorComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
}));
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it("Test open ScriptAccount", waitForAsync (() => {
|
||||||
|
const scriptAccount = new ScriptAccount("ScriptAccount", "");
|
||||||
|
component.openGameModelComponent(scriptAccount);
|
||||||
|
|
||||||
|
expect(component.gameModelComponents.includes(scriptAccount));
|
||||||
|
expect(component.gameModelComponents.length).toEqual(1);
|
||||||
|
|
||||||
|
component.openGameModelComponent(scriptAccount);
|
||||||
|
expect(component.gameModelComponents.length).toEqual(1);
|
||||||
|
}));
|
||||||
|
|
||||||
|
it("Test close ScriptAccount", waitForAsync(() => {
|
||||||
|
const scriptAccount = new ScriptAccount("ScriptAccount", "");
|
||||||
|
const scriptAccount2 = new ScriptAccount("ScriptAccount 2", "");
|
||||||
|
component.openGameModelComponent(scriptAccount);
|
||||||
|
|
||||||
|
component.closeGameModelComponent(scriptAccount);
|
||||||
|
expect(component.gameModelComponents.length).toEqual(0);
|
||||||
|
|
||||||
|
component.openGameModelComponent(scriptAccount);
|
||||||
|
component.openGameModelComponent(scriptAccount2);
|
||||||
|
component.closeGameModelComponent(scriptAccount);
|
||||||
|
expect(component.gameModelComponents.length).toEqual(1);
|
||||||
|
expect(component.gameModelComponents.includes(scriptAccount2));
|
||||||
|
}))
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { Component } from '@angular/core';
|
import {Component, Input} from '@angular/core';
|
||||||
|
import {GameModel} from "../game-model/GameModel";
|
||||||
|
import {ModelComponent} from "../game-model/ModelComponent";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-editor',
|
selector: 'app-editor',
|
||||||
@ -6,5 +8,16 @@ import { Component } from '@angular/core';
|
|||||||
styleUrl: './editor.component.scss'
|
styleUrl: './editor.component.scss'
|
||||||
})
|
})
|
||||||
export class EditorComponent {
|
export class EditorComponent {
|
||||||
|
gameModelComponents: ModelComponent[] = [];
|
||||||
|
|
||||||
|
openGameModelComponent(gameModelComponent: ModelComponent) {
|
||||||
|
if(!this.gameModelComponents.includes(gameModelComponent)) {
|
||||||
|
this.gameModelComponents.push(gameModelComponent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closeGameModelComponent(gameModelComponent: ModelComponent) {
|
||||||
|
this.gameModelComponents = this.gameModelComponents.filter(modelComponent => modelComponent !== gameModelComponent);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user