diff --git a/app/adapters/application.js b/app/adapters/application.js index 9861420..bb87e0f 100644 --- a/app/adapters/application.js +++ b/app/adapters/application.js @@ -3,7 +3,17 @@ import JSONAPIAdapter from '@ember-data/adapter/json-api'; export default class ApplicationAdapter extends JSONAPIAdapter { namespace = 'api'; - buildURL(...args) { - return `${super.buildURL(...args)}.json`; + buildURL(...args) {return `${super.buildURL(...args)}.json`;} + + 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/produkt.hbs b/app/components/produkt.hbs index 0324918..c50ee42 100644 --- a/app/components/produkt.hbs +++ b/app/components/produkt.hbs @@ -1,13 +1,7 @@ - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/components/produkt.js b/app/components/produkt.js index c3dea8f..ce1f786 100644 --- a/app/components/produkt.js +++ b/app/components/produkt.js @@ -2,6 +2,7 @@ import Component from '@glimmer/component'; import { action } from '@ember/object'; import { tracked } from '@glimmer/tracking'; import { inject as service } from '@ember/service'; +import ApplicationAdapter from '../adapters/application'; export default class ProduktController extends Component { @tracked isLarge = false; @@ -42,6 +43,14 @@ export default class ProduktController extends Component { setStatus(produktname, selection) { + function failure(reason) { + // handle the error + if(reason != null) + { + ; + } + } + //schreibt den aktuellen Zustand in den Store this.store.findAll('produkt') .then(function(suchergebnis) @@ -50,8 +59,7 @@ export default class ProduktController extends Component { if(element.titel==produktname) { element.isSelected = selection; - element.save(); - this.store.updateRelationships(); + element.save().catch(failure); } }); }); diff --git a/app/components/rezept.hbs b/app/components/rezept.hbs index be2ec4c..d328b1a 100644 --- a/app/components/rezept.hbs +++ b/app/components/rezept.hbs @@ -1,30 +1,12 @@ -{{#if @isSelected}} - -{{else}} - -{{/if}} - diff --git a/app/components/rezept.js b/app/components/rezept.js index a1eb35b..ddc6300 100644 --- a/app/components/rezept.js +++ b/app/components/rezept.js @@ -30,7 +30,16 @@ export default class RezeptController extends Component { if(element.titel==rezeptname) { element.isSelected = selection; - element.save(); + element.save().catch(failure); + + function failure(reason) + { + // handle the error + if(reason != null) + { + ; + } + } } }); }); diff --git a/app/models/produkt.js b/app/models/produkt.js index 93f8bf4..8a1a9b4 100644 --- a/app/models/produkt.js +++ b/app/models/produkt.js @@ -1,12 +1,12 @@ import Model, { attr } from '@ember-data/model'; export default class ProduktModel extends Model { - @attr titel; + @attr ('string') titel; @attr ('boolean') isSelected; - @attr kategorie; - @attr menge; - @attr einheit; - @attr bild; + @attr ('string') kategorie; + @attr ('number') menge; + @attr ('string') einheit; + @attr ('string') bild; get status() { diff --git a/app/models/rezept.js b/app/models/rezept.js index e29f94a..1dd3332 100644 --- a/app/models/rezept.js +++ b/app/models/rezept.js @@ -1,15 +1,16 @@ import Model, { attr, hasMany } from '@ember-data/model'; export default class RezeptModel extends Model { - @attr titel; + @attr ('string') titel; @attr ('boolean') isSelected; @attr ('string') beschreibung; - @attr kategorie; + @attr ('string') kategorie; @attr produkte; - @attr gewuerze; - @attr ('number') personen; @attr ('number') dauer; + @attr ('number') personen; @attr ('string') bild; + @attr gewuerze; + get status() { diff --git a/app/styles/app.css b/app/styles/app.css index 8ef7619..1b6104b 100644 --- a/app/styles/app.css +++ b/app/styles/app.css @@ -293,6 +293,7 @@ p { .rezept img { border-radius: 5px; + width: 100%; } .rezept .image { diff --git a/app/templates/produkte.hbs b/app/templates/produkte.hbs index 75a9124..33126dd 100644 --- a/app/templates/produkte.hbs +++ b/app/templates/produkte.hbs @@ -9,7 +9,7 @@ @@ -21,7 +21,7 @@ @@ -33,7 +33,7 @@ @@ -45,7 +45,7 @@ diff --git a/app/templates/rezepte.hbs b/app/templates/rezepte.hbs index ad0e8df..a88828f 100644 --- a/app/templates/rezepte.hbs +++ b/app/templates/rezepte.hbs @@ -9,7 +9,7 @@ diff --git a/app/templates/zettel.hbs b/app/templates/zettel.hbs index 3c536e7..b2b9718 100644 --- a/app/templates/zettel.hbs +++ b/app/templates/zettel.hbs @@ -6,10 +6,10 @@
-