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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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.save().catch(failure);
  29. function failure(reason)
  30. {
  31. // handle the error
  32. if(reason != null)
  33. {
  34. ;
  35. }
  36. }
  37. }
  38. });
  39. });
  40. }
  41. }