12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- 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;
- }
- });
-
- if(!this.exists)
- {
- this.isSelected = false;
- }
- });
- }
-
- 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);
- }
- });
- });
- }
- }
|