1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 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.save().catch(failure);
- }
- });
- });
- }
- }
|