Browse Source

adapt store actions

master
Felix Diemar 4 years ago
parent
commit
e75e22316e

+ 7
- 4
app/components/produkt.hbs View File

@@ -4,9 +4,12 @@
<h3>{{@produkt.titel}}</h3>
<ul class="details">
<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>
</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>-->

+ 7
- 29
app/components/produkt.js View File

@@ -6,10 +6,6 @@ import { inject as service } from '@ember/service';
export default class ProduktController extends Component {
@tracked isLarge = false;
@tracked isSelected = false;
@tracked ex = false;
@tracked isSet = false;
@tracked prodn = "test";
@tracked count = 0;
@service store;

@@ -26,18 +22,13 @@ export default class ProduktController extends Component {

@action getStatus(produktname)
{
this.prodn = produktname;

this.store.findAll('produkt')
.then(function(suchergebnis)
{

suchergebnis.forEach(element => {
if(element.titel==produktname)
{
this.exists = true;
this.isSelected = element.getStatus().isSelected;
this.ex = true;
this.isSelected = element.getStatus().isSelected;
}
});

@@ -52,26 +43,13 @@ export default class ProduktController extends Component {
{
//schreibt den aktuellen Zustand in den store
let suchergebnis = this.get('store').query('produkt', {
filter: {
let suchergebnis = this.store.query('produkt', {
filter:
{
titel: produktname
}});

this.prodn = suchergebnis.titel;


count = suchergebnisse.titel;
this.prodn = element.titel;
suchergebnisse.forEach(element => {
this.prodn = element.titel;
count++;
if(element.titel === produktname)
}}).then(function(element)
{
this.prodn = produktname;
element.isSelected = this.isSelected;
this.isSet = !this.isSet;
}
});
element.isSelected = this.isSelected;
});;
}
}

+ 0
- 1
app/models/produkt.js View File

@@ -8,7 +8,6 @@ export default class ProduktModel extends Model {
@attr einheit;
@attr bild;


get status()
{
return `${this.titel} ${this.IsSelected}`

+ 3
- 7
app/routes/produkte.js View File

@@ -1,13 +1,6 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

const PRODUKT_KATEGORIEN = [
'Pasta',
'Gemüse',
'Milchprodukte',
'Fleisch'
];

export default class ProduktRoute extends Route {

@service store;
@@ -16,6 +9,9 @@ export default class ProduktRoute extends Route {
return this.store.findAll('produkt');
}
}



/*async model() {
let response = await fetch('/api/produkte.json');
let { data } = await response.json();

+ 1
- 1
app/templates/rezepte.hbs View File

@@ -5,7 +5,7 @@
</Jumbo>

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

Loading…
Cancel
Save