From b41736386af4fdfbb24d8ee3035a38a062144daa Mon Sep 17 00:00:00 2001 From: diemarfe64635 Date: Mon, 29 Jun 2020 23:11:59 +0200 Subject: [PATCH] Produkte der Rezepte auf Zettel anzeigen --- app/components/hinzufuegen.js | 37 ++++++++++++++++-------- app/components/produkt.js | 1 + app/components/rezept.js | 1 + app/models/produkt.js | 5 ---- app/models/rezept.js | 6 ---- app/routes/zettel.js | 5 +++- app/templates/zettel.hbs | 11 ++++++-- jsconfig.json | 7 ++++- public/api/produkts.json | 53 +++++++++++++++++++++++++++++++++-- 9 files changed, 97 insertions(+), 29 deletions(-) diff --git a/app/components/hinzufuegen.js b/app/components/hinzufuegen.js index 5fbac50..279f176 100644 --- a/app/components/hinzufuegen.js +++ b/app/components/hinzufuegen.js @@ -15,22 +15,32 @@ export default class HinzufuegenController extends Component { @service store; - - @action speichern() { - this.store.createRecord('produkt', { + let produkt = this.store.createRecord('produkt', { type: 'produkt', id: this.titel.split(' ').join(''), - attributes: { - titel: this.titel, - kategorie: this.kategorie, - menge: this.menge, - einheit: this.einheit, - bild: this.bild, - isselected: false - } - }).save(); + //attributes: { + titel: this.titel, + kategorie: this.kategorie, + menge: this.menge, + einheit: this.einheit, + bild: this.bild, + isselected: false + //} + }) + + //produkt._promiseProxy = true; + produkt.save(); + + this.store.findAll('produkt').then(function (suchergebnis) { + suchergebnis.forEach(element => { + if (element.titel != undefined) { + + } + }); + }); + this.titel = null; this.kategorie = null; @@ -38,5 +48,8 @@ export default class HinzufuegenController extends Component { this.einheit = null; this.bild = null; this.id = null; + + + } } \ No newline at end of file diff --git a/app/components/produkt.js b/app/components/produkt.js index 52188e2..cd55cc2 100644 --- a/app/components/produkt.js +++ b/app/components/produkt.js @@ -54,6 +54,7 @@ export default class ProduktController extends Component { if(element.titel==produktname) { element.isselected = selection; + element._promiseProxy = true; element.save().catch(failure); } }); diff --git a/app/components/rezept.js b/app/components/rezept.js index 94da86a..47d907a 100644 --- a/app/components/rezept.js +++ b/app/components/rezept.js @@ -30,6 +30,7 @@ export default class RezeptController extends Component { if(element.titel==rezeptname) { element.isselected = selection; + element._promiseProxy = true; element.save().catch(failure); function failure(reason) diff --git a/app/models/produkt.js b/app/models/produkt.js index bab15dd..1a2eaf7 100644 --- a/app/models/produkt.js +++ b/app/models/produkt.js @@ -7,9 +7,4 @@ export default class ProduktModel extends Model { @attr ('number') menge; @attr ('string') einheit; @attr ('string') bild; - - get status() - { - return `${this.titel} ${this.isselected}` - } } diff --git a/app/models/rezept.js b/app/models/rezept.js index 3c97489..0b24edc 100644 --- a/app/models/rezept.js +++ b/app/models/rezept.js @@ -10,11 +10,5 @@ export default class RezeptModel extends Model { @attr ('number') personen; @attr ('string') bild; @attr gewuerze; - - - get status() - { - return `${this.titel} ${this.IsSelected}` - } } diff --git a/app/routes/zettel.js b/app/routes/zettel.js index 5d60329..7f06762 100644 --- a/app/routes/zettel.js +++ b/app/routes/zettel.js @@ -6,6 +6,9 @@ export default class ProduktRoute extends Route { @service store; async model() { - return this.store.findAll('produkt'); + let produkte = this.store.findAll('produkt'); + let rezepte = this.store.findAll('rezept'); + + return {produkte, rezepte}; } } \ No newline at end of file diff --git a/app/templates/zettel.hbs b/app/templates/zettel.hbs index b2b9718..8240aa5 100644 --- a/app/templates/zettel.hbs +++ b/app/templates/zettel.hbs @@ -7,11 +7,18 @@
    - {{#each @model as |produkt|}} - {{#if produkt.isSelected}} + {{#each @model.produkte as |produkt|}} + {{#if produkt.isselected}} {{/if}} {{/each}} + {{#each @model.rezepte as |rezept|}} + {{#if rezept.isselected}} + {{#each rezept.produkte as |produkt|}} + + {{/each}} + {{/if}} + {{/each}}
\ No newline at end of file diff --git a/jsconfig.json b/jsconfig.json index ab4ff72..55428b8 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,6 +1,11 @@ { "compilerOptions": { "experimentalDecorators": true, - "allowJs": true + "allowJs": true, + "strictBindCallApply": true, + "strict": false, + "alwaysStrict": false, + "resolveJsonModule": true, + "strictFunctionTypes": false } } \ No newline at end of file diff --git a/public/api/produkts.json b/public/api/produkts.json index 3a4b0de..14740ad 100644 --- a/public/api/produkts.json +++ b/public/api/produkts.json @@ -1,3 +1,52 @@ { - "data": [] -} \ No newline at end of file + "data": [ + { + "type": "produkt", + "id": "spaghetti", + "attributes": { + "titel": "Spaghetti", + "kategorie": "Pasta", + "menge": 500, + "einheit": "Gramm", + "bild": "https://www.pastaweb.de/wp-content/uploads/2016/02/spaghetti.jpg", + "isselected": false + } + }, + { + "type": "produkt", + "id": "salat", + "attributes": { + "titel": "Salat", + "kategorie": "Gemüse", + "menge": 1, + "einheit": "Kopf", + "bild": "https://napolipizza-spiez.ch/WebRoot/Store2/Shops/178389/5BD1/5BA4/85F2/ACB6/97E9/D91A/30FA/F35F/gruener-salat-2464087.jpg", + "isselected": false + } + }, + { + "type": "produkt", + "id": "milch", + "attributes": { + "titel": "Milch", + "kategorie": "Milchprodukte", + "menge": 1, + "einheit": "Liter", + "bild": "https://lebensmittel-warenkunde.de/assets/images/milch-milchprodukte.jpg", + "isselected": false + } + }, + { + "type": "produkt", + "id": "kaese", + "attributes": { + "titel": "Käse", + "kategorie": "Milchprodukte", + "menge": 200, + "einheit": "Gramm", + "bild": "https://www.der-bank-blog.de/wp-content/uploads/2016/04/banking-schweizer-kaese.jpg", + "isselected": false + } + } + ] +}