<div class=foodcardeditor>
-
-<input type="file"
- name="fileupload"
- (change)="fileEvent($event)" />
-
-<button class="button"
- type="button"
- id="exportJson"
- (click)="exportJson()">Export</button>
-<a [href]="downloadJsonHref"
- id="exportLink"
- [hidden]="downloadJsonHref === ''"
- download="speisekarte.json">Download</a>
-
-<button class="button"
- type="button"
- id="addTitle"
- (click)="addTitle()">Titel Hinzufügen</button>
-
-<div *ngFor="let title of foodcard.Titles; let i = index">
- <app-title [title]="title"></app-title>
+ <input type="file"
+ name="fileupload"
+ (change)="fileEvent($event)" />
<button class="button"
type="button"
- (click)="insertMainSection(i)">Einfügen Hauptteil</button>
+ id="exportJson"
+ (click)="exportJson()">Export</button>
+ <a [href]="downloadJsonHref"
+ id="exportLink"
+ [hidden]="downloadJsonHref === ''"
+ download="speisekarte.json">Download</a>
<button class="button"
type="button"
- (click)="removeMainSection(i)">Lösche Hauptteil</button>
- <button class="button"
- type="button"
- id="buttonSubtitle"
- (click)="addNewSubtitle(i)">Untertitel hinzufügen</button>
-</div>
-
+ id="addTitle"
+ (click)="addTitle()">Titel Hinzufügen</button>
+ <app-foodcard [foodcard]="foodcard"></app-foodcard>
</div>
export class AppComponent
{
public foodcard: IFoodCard = { Titles: [] };
- public formTitleVisible: boolean = false;
public downloadJsonHref: SafeUrl = "";
constructor(private sanitizer: DomSanitizer) {}
- public changeFormTitleVisible(): void
- {
- this.formTitleVisible = !this.formTitleVisible;
- }
-
- public addNewSubtitle(index: number): void
- {
- let title = this.foodcard.Titles[index];
- title.Subtitles.splice(index, 0,
- { Subtitle: "", Foods: [] });
- }
-
public exportJson(): void
{
let json = JSON.stringify(this.foodcard);
public addTitle(): void
{
this.foodcard.Titles.push({ Title: "", Subtitles: [] });
- this.formTitleVisible = false;
}
- public insertMainSection(index: number): void
- {
- this.foodcard.Titles.splice(index + 1, 0,
- { Title: "", Subtitles: [] });
- }
- public removeMainSection(index: number): void
- {
- this.foodcard.Titles.splice(index, 1);
- }
}
import { FoodComponent } from './food/food.component';
import { SubtitleComponent } from './subtitle/subtitle.component';
import { TitleComponent } from './title/title.component';
+import { FoodcardComponent } from './foodcard/foodcard.component';
@NgModule({
declarations: [
AppComponent,
FoodComponent,
SubtitleComponent,
- TitleComponent
+ TitleComponent,
+ FoodcardComponent
],
imports: [
BrowserModule,
--- /dev/null
+@media only screen and (min-width: 60.625em) {
+ .foodcard {
+ max-width: 60em;
+ margin: 0 auto;
+ }
+}
--- /dev/null
+<div class="foodcard">
+ <div *ngFor="let title of foodcard.Titles; let i = index">
+ <app-title [title]="title"></app-title>
+ <button class="button"
+ type="button"
+ (click)="insertMainSection(i)">Einfügen Hauptteil</button>
+ <button class="button"
+ type="button"
+ (click)="removeMainSection(i)">Lösche Hauptteil</button>
+ <button class="button"
+ type="button"
+ id="buttonSubtitle"
+ (click)="addNewSubtitle(i)">Untertitel hinzufügen</button>
+ </div>
+</div>
--- /dev/null
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { FoodcardComponent } from './foodcard.component';
+
+describe('FoodcardComponent', () => {
+ let component: FoodcardComponent;
+ let fixture: ComponentFixture<FoodcardComponent>;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ FoodcardComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(FoodcardComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
--- /dev/null
+import { Component, Input } from '@angular/core';
+import { IFoodCard } from '../ifood-card';
+
+@Component({
+ selector: 'app-foodcard',
+ templateUrl: './foodcard.component.html',
+ styleUrls: ['./foodcard.component.css']
+})
+
+export class FoodcardComponent
+{
+ @Input() foodcard: IFoodCard = { Titles: [] };
+
+ constructor() {}
+
+ public insertMainSection(index: number): void
+ {
+ this.foodcard.Titles.splice(index + 1, 0,
+ { Title: "", Subtitles: [] });
+ }
+
+ public removeMainSection(index: number): void
+ {
+ this.foodcard.Titles.splice(index, 1);
+ }
+
+ public addNewSubtitle(index: number): void
+ {
+ let title = this.foodcard.Titles[index];
+ title.Subtitles.splice(index, 0,
+ { Subtitle: "", Foods: [] });
+ }
+}