123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 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;
- @tracked isselected;
-
- @service store;
-
- @action toggleSize()
- {
- this.isLarge = !this.isLarge;
- }
-
- @action toggleSelection(produktname)
- {
- this.isselected = !this.isselected;
- this.setStatus(produktname, this.isselected);
- }
-
- @action getStatus(produktname)
- {
- //sucht Produkt im Store
- this.store.findAll('produkt')
- .then(function(suchergebnis)
- {
- suchergebnis.forEach(element => {
- if(element.titel==produktname)
- {
- this.isselected = element.isselected;
- }
- });
- });
- }
-
- 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)
- {
- suchergebnis.forEach(element => {
- if(element.titel==produktname)
- {
- element.isselected = selection;
- element._promiseProxy = true;
- element.save().catch(failure);
- }
- });
- });
- }
- }
|