From 525e465f5dbffe59565c563269e8b42be6830847 Mon Sep 17 00:00:00 2001 From: diemarfe64635 Date: Mon, 29 Jun 2020 20:08:48 +0200 Subject: [PATCH] add products --- app/adapters/application.js | 9 +--- app/components/hinzufuegen.hbs | 23 ++++++++ app/components/hinzufuegen.js | 42 +++++++++++++++ app/components/produkt.hbs | 2 +- app/components/produkt.js | 17 +++--- app/components/rezept.hbs | 2 +- app/components/rezept.js | 8 +-- app/models/produkt.js | 4 +- app/models/rezept.js | 2 +- app/routes/rezepte.js | 14 ----- app/styles/app.css | 2 + app/templates/neues-produkt.hbs | 8 ++- public/api/produkts.json | 54 +------------------ public/api/rezepts.json | 4 +- .../components/hinzufuegen-test.js | 26 +++++++++ 15 files changed, 120 insertions(+), 97 deletions(-) create mode 100644 app/components/hinzufuegen.hbs create mode 100644 app/components/hinzufuegen.js create mode 100644 tests/integration/components/hinzufuegen-test.js diff --git a/app/adapters/application.js b/app/adapters/application.js index bb87e0f..aaa0d95 100644 --- a/app/adapters/application.js +++ b/app/adapters/application.js @@ -7,13 +7,6 @@ export default class ApplicationAdapter extends JSONAPIAdapter { urlForUpdateRecord(id, modelName, snapshot) { return `api/${modelName}s`; - } - - createRecord(store, type, snapshot) { - let data = this.serialize(snapshot, { includeId: true }); - //let url = `/${type.modelName}`; - - // ... - } + } } diff --git a/app/components/hinzufuegen.hbs b/app/components/hinzufuegen.hbs new file mode 100644 index 0000000..5d3a2ad --- /dev/null +++ b/app/components/hinzufuegen.hbs @@ -0,0 +1,23 @@ +
+ + + + + +
\ No newline at end of file diff --git a/app/components/hinzufuegen.js b/app/components/hinzufuegen.js new file mode 100644 index 0000000..5fbac50 --- /dev/null +++ b/app/components/hinzufuegen.js @@ -0,0 +1,42 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; +import { inject as service } from '@ember/service'; + +export default class HinzufuegenController extends Component { + + @tracked titel; + @tracked kategorie; + @tracked menge; + @tracked einheit; + @tracked bild; + @tracked id; + @tracked isselected; + + @service store; + + + + @action speichern() + { + 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(); + + this.titel = null; + this.kategorie = null; + this.menge = null; + this.einheit = null; + this.bild = null; + this.id = null; + } +} \ No newline at end of file diff --git a/app/components/produkt.hbs b/app/components/produkt.hbs index c50ee42..aa706e7 100644 --- a/app/components/produkt.hbs +++ b/app/components/produkt.hbs @@ -1,4 +1,4 @@ -