Browse Source

V0.1e Überarbeitung des Layouts

master
Christian Greif 4 years ago
parent
commit
10d2fcf3b3
3 changed files with 83 additions and 53 deletions
  1. 74
    45
      src/app/app.component.html
  2. 4
    3
      src/app/app.component.ts
  3. 5
    5
      src/styles.css

+ 74
- 45
src/app/app.component.html View File

<h1>Einkaufszettel</h1> <h1>Einkaufszettel</h1>
<app-blog-entry *ngFor="let entry of entries" [entry]="entry"></app-blog-entry> <app-blog-entry *ngFor="let entry of entries" [entry]="entry"></app-blog-entry>
<h2>Neuen Einkaufszettel Eintrag anlegen:</h2> <h2>Neuen Einkaufszettel Eintrag anlegen:</h2>
<div>
<form (ngSubmit)="saveTask(form.value)" #form="ngForm">
<div class="form-group">
<div><label for="title">Titel* </label></div>


<div class="form">
<form novalidate (ngSubmit)="saveTask(form.value)" #form="ngForm">
<div class="form-group">
<label for="title">Titel*</label>
<input type="text" class="form-control" name="title" id="title" #title ngModel required/>
<div>
<input type="text" class="form-control" name="title" id="title" #title ngModel required/>
</div>
</div>


<label for="image">Bild-URL*</label>
<input type="text" class="form-control" name="title" id="image" #image ngModel required/>
<div class="form-group">
<div><label for="image">Bild-URL* </label></div>

<div>
<input type="text" class="form-control" name="title" id="image" #image ngModel required/>
</div>
</div>


<label>Kategorie*</label>
<input type="text" class="form-control" id="kategorie" #kategorie ngModel required/>
<div class="form-group">
<div><label>Kategorie* </label></div>
<div>
<input type="text" class="form-control" id="kategorie" #kategorie ngModel required/>
</div>
</div>


<label for="menge">Menge*</label>
<input type="text" class="form-control" name="title" id="menge" #menge ngModel required/>
<div class="form-group">
<div><label for="menge">Menge* </label></div>
<div>
<input type="text" class="form-control" name="title" id="menge" #menge ngModel required/>
</div>
</div>


<label for="kommentar">Kommentar: </label>
<textarea id="kommentar" #kommentar cols="20" rows="3" #text>
<div class="form-group">
<div><label for="kommentar">Kommentar: </label></div>
<textarea id="kommentar" #kommentar cols="20" rows="3" #text>
</textarea> </textarea>
</div>
<button (click)="createBlogEntry(title.value, image.value, kategorie.value,menge.value, kommentar.value)">
Eintrag anlegen
</button>
<button (click)="deleteAllEntries()">
Alle Einträge löschen
</button>
<button (click)="deleteLastEntry()">
Letzten Eintrag Löschen
</button>

</form>
<div class="container">
<div class="row custom-wrapper">
<div class="col-md-12">
<!-- Form starts -->
<form [formGroup]="registrationForm" (ngSubmit)="onSubmit()">
<div class="group-gap">
<div class="d-block my-3">
<div class="mb-3">
<select class="custom-select" (change)="changeKategorie($event)" formControlName="kategorieName">
<option value="">Wählen sie eine Kategorie</option>
<option *ngFor="let kategorie of Kategorien" [ngValue]="kategorie">{{kategorie}}</option>
</select>
<!-- error block -->
<div class="invalid-feedback" *ngIf="isSubmitted && kategorieName.errors?.required">
<sup>*</sup>Bitte geben sie eine Kategorie ein!
</div>
</div>

<div class="form-group">
<button (click)="createBlogEntry(title.value, image.value, kategorie.value,menge.value, kommentar.value)">
Eintrag anlegen
</button>
</div>

<div>
<button (click)="deleteAllEntries()">
Alle Einträge löschen
</button>
</div>
<div>
<button (click)="deleteLastEntry()">
Letzten Eintrag Löschen
</button>
</div>

</form>
</div>

<div class="container">
<div class="row custom-wrapper">
<div class="col-md-12">
<!-- Form starts -->
<form [formGroup]="registrationForm" (ngSubmit)="onSubmit()">
<div class="group-gap">
<div class="d-block my-3">
<div class="mb-3">
<select class="custom-select" (change)="changeKategorie($event)" formControlName="kategorieName">
<option value="">Wählen sie eine Kategorie</option>
<option *ngFor="let kategorie of Kategorien" [ngValue]="kategorie">{{kategorie}}</option>
</select>
<!-- error block -->
<div class="invalid-feedback" *ngIf="isSubmitted && kategorieName.errors?.required">
<sup>*</sup>Bitte geben sie eine Kategorie ein!
</div> </div>
</div> </div>
</div> </div>
<!-- Submit Button -->
<button type="submit" class="btn btn-danger btn-lg btn-block">Speichern</button>
</form><!-- Form ends -->
</div>
</div>
<!-- Submit Button -->
<button type="submit" class="btn btn-danger btn-lg btn-block">Speichern</button>
</form><!-- Form ends -->
</div> </div>
</div> </div>
</div> </div>



+ 4
- 3
src/app/app.component.ts View File

} }


createBlogEntry(title: string, image: string, kategorie: string, menge: string, kommentar: string, ) { createBlogEntry(title: string, image: string, kategorie: string, menge: string, kommentar: string, ) {
if (title && image && kommentar && kategorie) {
//if (title && image && kommentar && kategorie) {
const entry = new BlogEntry(); const entry = new BlogEntry();
entry.title = title; entry.title = title;
entry.image = image; entry.image = image;
entry.menge = menge; entry.menge = menge;
entry.kommentar = kommentar; entry.kommentar = kommentar;
this.entries.push(entry); this.entries.push(entry);
}
//}
} }
deleteAllEntries() { deleteAllEntries() {
console.log(this.entries.length); console.log(this.entries.length);
this.entries.splice(index-1, 1); this.entries.splice(index-1, 1);
} }
} }
// Kategorie mit Drop Down Menu wählen

// Kategorie mit Drop Down Menu wählen
changeKategorie(e) { changeKategorie(e) {
console.log(e.value); console.log(e.value);
this.kategorieName.setValue(e.target.value, { this.kategorieName.setValue(e.target.value, {

+ 5
- 5
src/styles.css View File



.form { .form {
background-color: #eee; background-color: #eee;
width: 580px; /* Breite des Formulars */
width: 500px; /* Breite des Formulars */
padding: 20px; padding: 20px;
border: 1px solid #8c8c8c; border: 1px solid #8c8c8c;
position: absolute; position: absolute;


input, input,
textarea { textarea {
width: 550px;
width: 500px;
border: 1px solid #8c8c8c; border: 1px solid #8c8c8c;
margin-bottom: 1em; margin-bottom: 1em;
} }
} }


.blog-entry { .blog-entry {
width: 600px;
width: 500px;
display: flex; display: flex;
padding-bottom: 30px; padding-bottom: 30px;
} }


button { button {
float: right;
padding-right: 20px;
float: left;
padding-right: 10px;
} }


.blog-image { .blog-image {

Loading…
Cancel
Save