adapt store actions

This commit is contained in:
Felix Diemar 2020-06-23 17:20:34 +02:00
parent 7dacf0441c
commit e75e22316e
5 changed files with 19 additions and 43 deletions

View File

@ -4,9 +4,12 @@
<h3>{{@produkt.titel}}</h3> <h3>{{@produkt.titel}}</h3>
<ul class="details"> <ul class="details">
<li class="detail"><h4>Menge:</h4> {{@produkt.menge}}{{@produkt.einheit}}</li> <li class="detail"><h4>Menge:</h4> {{@produkt.menge}}{{@produkt.einheit}}</li>
<!--<li class="detail"><h4>this.ex:</h4> {{this.ex}}</li>
<li class="detail"><h4>this.prodn:</h4> {{this.prodn}}</li>
<li class="detail"><h4>produkt count:</h4> {{this.count}}</li>-->
</ul> </ul>
</div> </div>
</button> </button>
<!--<li class="detail"><h4>this.ex:</h4> {{this.ex}}</li>
<li class="detail"><h4>this.prodn:</h4> {{this.prodn}}</li>
<li class="detail"><h4>produkt count:</h4> {{this.count}}</li>-->

View File

@ -6,10 +6,6 @@ import { inject as service } from '@ember/service';
export default class ProduktController extends Component { export default class ProduktController extends Component {
@tracked isLarge = false; @tracked isLarge = false;
@tracked isSelected = false; @tracked isSelected = false;
@tracked ex = false;
@tracked isSet = false;
@tracked prodn = "test";
@tracked count = 0;
@service store; @service store;
@ -26,18 +22,13 @@ export default class ProduktController extends Component {
@action getStatus(produktname) @action getStatus(produktname)
{ {
this.prodn = produktname;
this.store.findAll('produkt') this.store.findAll('produkt')
.then(function(suchergebnis) .then(function(suchergebnis)
{ {
suchergebnis.forEach(element => { suchergebnis.forEach(element => {
if(element.titel==produktname) if(element.titel==produktname)
{ {
this.exists = true;
this.isSelected = element.getStatus().isSelected; this.isSelected = element.getStatus().isSelected;
this.ex = true;
} }
}); });
@ -52,26 +43,13 @@ export default class ProduktController extends Component {
{ {
//schreibt den aktuellen Zustand in den store //schreibt den aktuellen Zustand in den store
let suchergebnis = this.get('store').query('produkt', { let suchergebnis = this.store.query('produkt', {
filter: { filter:
titel: produktname {
}}); titel: produktname
}}).then(function(element)
this.prodn = suchergebnis.titel;
count = suchergebnisse.titel;
this.prodn = element.titel;
suchergebnisse.forEach(element => {
this.prodn = element.titel;
count++;
if(element.titel === produktname)
{ {
this.prodn = produktname;
element.isSelected = this.isSelected; element.isSelected = this.isSelected;
this.isSet = !this.isSet; });;
}
});
} }
} }

View File

@ -8,7 +8,6 @@ export default class ProduktModel extends Model {
@attr einheit; @attr einheit;
@attr bild; @attr bild;
get status() get status()
{ {
return `${this.titel} ${this.IsSelected}` return `${this.titel} ${this.IsSelected}`

View File

@ -1,13 +1,6 @@
import Route from '@ember/routing/route'; import Route from '@ember/routing/route';
import { inject as service } from '@ember/service'; import { inject as service } from '@ember/service';
const PRODUKT_KATEGORIEN = [
'Pasta',
'Gemüse',
'Milchprodukte',
'Fleisch'
];
export default class ProduktRoute extends Route { export default class ProduktRoute extends Route {
@service store; @service store;
@ -16,6 +9,9 @@ export default class ProduktRoute extends Route {
return this.store.findAll('produkt'); return this.store.findAll('produkt');
} }
} }
/*async model() { /*async model() {
let response = await fetch('/api/produkte.json'); let response = await fetch('/api/produkte.json');
let { data } = await response.json(); let { data } = await response.json();

View File

@ -5,7 +5,7 @@
</Jumbo> </Jumbo>
<Kategorie @titel={{"Pasta"}}> <Kategorie @titel={{"Pasta"}}>
<div class="rentals"> <div class="rezepte">
<ul class="resultsRezept"> <ul class="resultsRezept">
{{#each @model as |rezept|}} {{#each @model as |rezept|}}
{{#if (compare rezept.kategorie '===' 'Pasta')}} {{#if (compare rezept.kategorie '===' 'Pasta')}}