Produkte der Rezepte auf Zettel anzeigen
This commit is contained in:
parent
525e465f5d
commit
b41736386a
@ -15,22 +15,32 @@ export default class HinzufuegenController extends Component {
|
|||||||
|
|
||||||
@service store;
|
@service store;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@action speichern()
|
@action speichern()
|
||||||
{
|
{
|
||||||
this.store.createRecord('produkt', {
|
let produkt = this.store.createRecord('produkt', {
|
||||||
type: 'produkt',
|
type: 'produkt',
|
||||||
id: this.titel.split(' ').join(''),
|
id: this.titel.split(' ').join(''),
|
||||||
attributes: {
|
//attributes: {
|
||||||
titel: this.titel,
|
titel: this.titel,
|
||||||
kategorie: this.kategorie,
|
kategorie: this.kategorie,
|
||||||
menge: this.menge,
|
menge: this.menge,
|
||||||
einheit: this.einheit,
|
einheit: this.einheit,
|
||||||
bild: this.bild,
|
bild: this.bild,
|
||||||
isselected: false
|
isselected: false
|
||||||
}
|
//}
|
||||||
}).save();
|
})
|
||||||
|
|
||||||
|
//produkt._promiseProxy = true;
|
||||||
|
produkt.save();
|
||||||
|
|
||||||
|
this.store.findAll('produkt').then(function (suchergebnis) {
|
||||||
|
suchergebnis.forEach(element => {
|
||||||
|
if (element.titel != undefined) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
this.titel = null;
|
this.titel = null;
|
||||||
this.kategorie = null;
|
this.kategorie = null;
|
||||||
@ -38,5 +48,8 @@ export default class HinzufuegenController extends Component {
|
|||||||
this.einheit = null;
|
this.einheit = null;
|
||||||
this.bild = null;
|
this.bild = null;
|
||||||
this.id = null;
|
this.id = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -54,6 +54,7 @@ export default class ProduktController extends Component {
|
|||||||
if(element.titel==produktname)
|
if(element.titel==produktname)
|
||||||
{
|
{
|
||||||
element.isselected = selection;
|
element.isselected = selection;
|
||||||
|
element._promiseProxy = true;
|
||||||
element.save().catch(failure);
|
element.save().catch(failure);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -30,6 +30,7 @@ export default class RezeptController extends Component {
|
|||||||
if(element.titel==rezeptname)
|
if(element.titel==rezeptname)
|
||||||
{
|
{
|
||||||
element.isselected = selection;
|
element.isselected = selection;
|
||||||
|
element._promiseProxy = true;
|
||||||
element.save().catch(failure);
|
element.save().catch(failure);
|
||||||
|
|
||||||
function failure(reason)
|
function failure(reason)
|
||||||
|
@ -7,9 +7,4 @@ export default class ProduktModel extends Model {
|
|||||||
@attr ('number') menge;
|
@attr ('number') menge;
|
||||||
@attr ('string') einheit;
|
@attr ('string') einheit;
|
||||||
@attr ('string') bild;
|
@attr ('string') bild;
|
||||||
|
|
||||||
get status()
|
|
||||||
{
|
|
||||||
return `${this.titel} ${this.isselected}`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,5 @@ export default class RezeptModel extends Model {
|
|||||||
@attr ('number') personen;
|
@attr ('number') personen;
|
||||||
@attr ('string') bild;
|
@attr ('string') bild;
|
||||||
@attr gewuerze;
|
@attr gewuerze;
|
||||||
|
|
||||||
|
|
||||||
get status()
|
|
||||||
{
|
|
||||||
return `${this.titel} ${this.IsSelected}`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ export default class ProduktRoute extends Route {
|
|||||||
@service store;
|
@service store;
|
||||||
|
|
||||||
async model() {
|
async model() {
|
||||||
return this.store.findAll('produkt');
|
let produkte = this.store.findAll('produkt');
|
||||||
|
let rezepte = this.store.findAll('rezept');
|
||||||
|
|
||||||
|
return {produkte, rezepte};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,11 +7,18 @@
|
|||||||
<Kategorie @titel={{"mein Zettel"}}>
|
<Kategorie @titel={{"mein Zettel"}}>
|
||||||
<div class="rentals">
|
<div class="rentals">
|
||||||
<ul class="resultsProdukt">
|
<ul class="resultsProdukt">
|
||||||
{{#each @model as |produkt|}}
|
{{#each @model.produkte as |produkt|}}
|
||||||
{{#if produkt.isSelected}}
|
{{#if produkt.isselected}}
|
||||||
<Produkt @produkt={{produkt}}/>
|
<Produkt @produkt={{produkt}}/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
{{#each @model.rezepte as |rezept|}}
|
||||||
|
{{#if rezept.isselected}}
|
||||||
|
{{#each rezept.produkte as |produkt|}}
|
||||||
|
<Produkt @produkt={{produkt.attributes}}/>
|
||||||
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</Kategorie>
|
</Kategorie>
|
@ -1,6 +1,11 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"allowJs": true
|
"allowJs": true,
|
||||||
|
"strictBindCallApply": true,
|
||||||
|
"strict": false,
|
||||||
|
"alwaysStrict": false,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"strictFunctionTypes": false
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,3 +1,52 @@
|
|||||||
{
|
{
|
||||||
"data": []
|
"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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user