Skip to content

Commit

Permalink
removed info-dialog-component
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHeckert committed Oct 2, 2024
1 parent afd168a commit dff6152
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 80 deletions.
21 changes: 0 additions & 21 deletions src/app/domain/entities/infoDialogData.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/app/domain/entities/shortcut-dialog-data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface ShortCut {
description: string,
shortCut: string
description: string;
shortCut: string;
}

export interface ShortcutDialogData {
Expand Down
6 changes: 2 additions & 4 deletions src/app/domain/presentation/domain.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {NgModule} from "@angular/core";
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MaterialModule } from '../../material.module';
import {
KeyboardShortcutsDialogComponent
} from "./keyboard-shortcuts-dialog/keyboard-shortcuts/keyboard-shortcuts-dialog.component";
import { KeyboardShortcutsDialogComponent } from './keyboard-shortcuts-dialog/keyboard-shortcuts/keyboard-shortcuts-dialog.component';

@NgModule({
declarations: [KeyboardShortcutsDialogComponent],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ <h2 id="info-dialog-title">{{ title }}</h2>

@for (shortCut of shortCuts; track shortCut.description) {
<div class="row">
<span class="description-width">{{shortCut.description}}:</span>
<span>{{shortCut.shortCut}}</span>
<span class="description-width">{{ shortCut.description }}:</span>
<span>{{ shortCut.shortCut }}</span>
</div>
}
</mat-dialog-content>
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { KeyboardShortcutsDialogComponent } from './keyboard-shortcuts-dialog.component';
import {MAT_DIALOG_DATA, MatDialogModule, MatDialogRef} from "@angular/material/dialog";
import {MockModule, MockProviders} from "ng-mocks";
import {ShortcutDialogData} from "../../../entities/shortcut-dialog-data";
import {
MAT_DIALOG_DATA,
MatDialogModule,
MatDialogRef,
} from '@angular/material/dialog';
import { MockModule, MockProviders } from 'ng-mocks';
import { ShortcutDialogData } from '../../../entities/shortcut-dialog-data';

describe('KeyboardShortcutsComponent', () => {
let component: KeyboardShortcutsDialogComponent;
let fixture: ComponentFixture<KeyboardShortcutsDialogComponent>;

const keyboardShortCutData: ShortcutDialogData = {
title: 'Keyboard Shortcuts',
shortCuts: [{description: 'Undo', shortCut: 'ctrl + Z'}]
}
shortCuts: [{ description: 'Undo', shortCut: 'ctrl + Z' }],
};

beforeEach(async () => {
await TestBed.configureTestingModule({
Expand All @@ -25,8 +29,7 @@ describe('KeyboardShortcutsComponent', () => {
useValue: keyboardShortCutData,
},
],
})
.compileComponents();
}).compileComponents();

fixture = TestBed.createComponent(KeyboardShortcutsDialogComponent);
component = fixture.componentInstance;
Expand All @@ -37,9 +40,9 @@ describe('KeyboardShortcutsComponent', () => {
expect(component).toBeTruthy();
});

it('it should have correct shortcut data', ()=> {
expect(component.shortCuts.length).toBe(1)
expect(component.shortCuts[0].shortCut).toBe('ctrl + Z')
expect(component.shortCuts[0].description).toBe('Undo')
})
it('it should have correct shortcut data', () => {
expect(component.shortCuts.length).toBe(1);
expect(component.shortCuts[0].shortCut).toBe('ctrl + Z');
expect(component.shortCuts[0].description).toBe('Undo');
});
});
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import {Component, Inject} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {ShortcutDialogData, ShortCut} from "../../../entities/shortcut-dialog-data";
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import {
ShortcutDialogData,
ShortCut,
} from '../../../entities/shortcut-dialog-data';

@Component({
selector: 'app-keyboard-shortcuts-dialog',
templateUrl: './keyboard-shortcuts-dialog.component.html',
styleUrl: './keyboard-shortcuts-dialog.component.scss'
styleUrl: './keyboard-shortcuts-dialog.component.scss',
})
export class KeyboardShortcutsDialogComponent {
title: string;
shortCuts: ShortCut[] = [];

constructor(
@Inject(MAT_DIALOG_DATA) data: ShortcutDialogData,
) {
constructor(@Inject(MAT_DIALOG_DATA) data: ShortcutDialogData) {
this.title = data.title;
this.shortCuts = data.shortCuts ?? []
this.shortCuts = data.shortCuts ?? [];
}

}
12 changes: 6 additions & 6 deletions src/app/domain/services/dialog.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {TestBed} from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';

import {DialogService} from 'src/app/domain/services/dialog.service';
import {MatDialog, MatDialogConfig} from '@angular/material/dialog';
import {MockProvider} from 'ng-mocks';
import {of} from 'rxjs';
import { DialogService } from 'src/app/domain/services/dialog.service';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { MockProvider } from 'ng-mocks';
import { of } from 'rxjs';

describe('DialogService', () => {
let service: DialogService;
Expand Down Expand Up @@ -32,7 +32,7 @@ describe('DialogService', () => {

config.data = {
title: 'Keyboard Shortcuts',
shortCuts: []
shortCuts: [],
};
service.openKeyboardShortcutsDialog();

Expand Down
46 changes: 25 additions & 21 deletions src/app/domain/services/dialog.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { Injectable } from '@angular/core';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { ComponentType } from '@angular/cdk/overlay';
import { InfoDialogData } from '../entities/infoDialogData';
import { KeyboardShortcutsDialogComponent } from "../presentation/keyboard-shortcuts-dialog/keyboard-shortcuts/keyboard-shortcuts-dialog.component";
import {ShortcutDialogData, ShortCut} from "../entities/shortcut-dialog-data";


import { KeyboardShortcutsDialogComponent } from '../presentation/keyboard-shortcuts-dialog/keyboard-shortcuts/keyboard-shortcuts-dialog.component';
import { ShortCut, ShortcutDialogData } from '../entities/shortcut-dialog-data';

@Injectable({
providedIn: 'root',
Expand All @@ -19,26 +16,33 @@ export class DialogService {

openKeyboardShortcutsDialog(): void {
const shortCuts: ShortCut[] = [];
shortCuts.push({description: 'Undo', shortCut: 'ctrl + Z'})
shortCuts.push({description: 'Redo', shortCut: 'ctrl + Y OR ctrl + shift + Z'})
shortCuts.push({description: 'Select All', shortCut: 'ctrl + A'})
shortCuts.push({description: 'Export as EGN', shortCut: 'ctrl + S'})
shortCuts.push({description: 'Export as SVG', shortCut: 'ctrl + alt + S'})
shortCuts.push({description: 'Import Domain Story', shortCut: 'ctrl + L'})
shortCuts.push({description: 'Search for text', shortCut: 'ctrl + F'})
shortCuts.push({description: 'Direct editing', shortCut: 'E'})
shortCuts.push({description: 'Hand tool', shortCut: 'H'})
shortCuts.push({description: 'Lasso tool', shortCut: 'L'})
shortCuts.push({description: 'Space tool', shortCut: 'S'})
shortCuts.push({ description: 'Undo', shortCut: 'ctrl + Z' });
shortCuts.push({
description: 'Redo',
shortCut: 'ctrl + Y OR ctrl + shift + Z',
});
shortCuts.push({ description: 'Select All', shortCut: 'ctrl + A' });
shortCuts.push({ description: 'Export as EGN', shortCut: 'ctrl + S' });
shortCuts.push({
description: 'Export as SVG',
shortCut: 'ctrl + alt + S',
});
shortCuts.push({
description: 'Import Domain Story',
shortCut: 'ctrl + L',
});
shortCuts.push({ description: 'Search for text', shortCut: 'ctrl + F' });
shortCuts.push({ description: 'Direct editing', shortCut: 'E' });
shortCuts.push({ description: 'Hand tool', shortCut: 'H' });
shortCuts.push({ description: 'Lasso tool', shortCut: 'L' });
shortCuts.push({ description: 'Space tool', shortCut: 'S' });

const config = new MatDialogConfig();

const shortCutDialog: ShortcutDialogData = {
config.data = {
title: 'Keyboard Shortcuts',
shortCuts: shortCuts
}

config.data = shortCutDialog;
shortCuts: shortCuts,
};

this.openDialog(KeyboardShortcutsDialogComponent, config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { MockModule, MockProvider } from 'ng-mocks';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { ExportDialogData } from '../../domain/dialog/exportDialogData';
import { MaterialModule } from 'src/app/material.module';
import {FormsModule} from "@angular/forms";
import { FormsModule } from '@angular/forms';

describe('ExportDialogComponent', () => {
let component: ExportDialogComponent;
Expand Down
4 changes: 2 additions & 2 deletions src/app/tools/export/services/export.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { TestBed } from '@angular/core/testing';

import { ExportService } from 'src/app/tools/export/services/export.service';
import { HtmlPresentationService } from './html-presentation.service';
import {MockModule, MockService} from 'ng-mocks';
import { MockModule, MockService } from 'ng-mocks';
import { IconSetConfigurationService } from '../../icon-set-config/services/icon-set-configuration.service';
import { PngService } from './png.service';
import { SvgService } from './svg.service';
import { RendererService } from '../../modeler/services/renderer.service';
import {MatDialogModule} from "@angular/material/dialog";
import { MatDialogModule } from '@angular/material/dialog';

describe('ExportService', () => {
let service: ExportService;
Expand Down

0 comments on commit dff6152

Please sign in to comment.