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.

produkt.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. import ApplicationAdapter from '../adapters/application';
  6. export default class ProduktController extends Component {
  7. @tracked isLarge = false;
  8. @tracked isselected;
  9. @service store;
  10. @action toggleSize()
  11. {
  12. this.isLarge = !this.isLarge;
  13. }
  14. @action toggleSelection(produktname)
  15. {
  16. this.isselected = !this.isselected;
  17. this.setStatus(produktname, this.isselected);
  18. }
  19. @action getStatus(produktname)
  20. {
  21. //sucht Produkt im Store
  22. this.store.findAll('produkt')
  23. .then(function(suchergebnis)
  24. {
  25. suchergebnis.forEach(element => {
  26. if(element.titel==produktname)
  27. {
  28. this.isselected = element.isselected;
  29. }
  30. });
  31. });
  32. }
  33. setStatus(produktname, selection)
  34. {
  35. function failure(reason) {
  36. // handle the error
  37. if(reason != null)
  38. {
  39. ;
  40. }
  41. }
  42. //schreibt den aktuellen Zustand in den Store
  43. this.store.findAll('produkt')
  44. .then(function(suchergebnis)
  45. {
  46. suchergebnis.forEach(element => {
  47. if(element.titel==produktname)
  48. {
  49. element.isselected = selection;
  50. element.save().catch(failure);
  51. }
  52. });
  53. });
  54. }
  55. }