You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rezept.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import Component from '@glimmer/component';
  2. import { action } from '@ember/object';
  3. import { tracked } from '@glimmer/tracking';
  4. import { inject as service } from '@ember/service';
  5. export default class RezeptController extends Component {
  6. @tracked isLarge = false;
  7. @tracked isselected;
  8. @service store;
  9. @action toggleSize()
  10. {
  11. this.isLarge = !this.isLarge;
  12. }
  13. @action toggleSelection(rezeptname)
  14. {
  15. this.isselected = !this.isselected;
  16. this.setStatus(rezeptname, this.isselected);
  17. }
  18. setStatus(rezeptname, selection)
  19. {
  20. //schreibt den aktuellen Zustand in den Store
  21. this.store.findAll('rezept')
  22. .then(function(suchergebnis)
  23. {
  24. suchergebnis.forEach(element => {
  25. if(element.titel==rezeptname)
  26. {
  27. element.isselected = selection;
  28. element._promiseProxy = true;
  29. element.save().catch(failure);
  30. function failure(reason)
  31. {
  32. // handle the error
  33. if(reason != null)
  34. {
  35. ;
  36. }
  37. }
  38. }
  39. });
  40. });
  41. }
  42. }