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.
 
 
 

71 lines
1.2 KiB

  1. module.exports = {
  2. type: 'events',
  3. list: [],
  4. simplify: function (self) {
  5. if (!self)
  6. return;
  7. let result = {
  8. type: 'events'
  9. };
  10. if (this.list.length > 0) {
  11. result.list = this.list.map(l => ({
  12. id: l.id,
  13. name: l.config.name,
  14. description: l.config.description
  15. }));
  16. }
  17. return result;
  18. },
  19. save: function () {
  20. return {
  21. type: 'events'
  22. };
  23. },
  24. unregisterEvent: function (event) {
  25. this.list.spliceWhere(l => (l === event));
  26. this.obj.syncer.setArray(true, 'events', 'removeList', {
  27. id: event.id
  28. });
  29. },
  30. syncList: function () {
  31. this.list.forEach(function (l) {
  32. this.obj.syncer.setArray(true, 'events', 'updateList', {
  33. id: l.id,
  34. name: l.config.name,
  35. description: l.config.description
  36. });
  37. }, this);
  38. },
  39. events: {
  40. afterMove: function () {
  41. let events = this.obj.instance.events;
  42. let closeEvents = events.getCloseEvents(this.obj);
  43. if (!closeEvents)
  44. return;
  45. closeEvents.forEach(function (c) {
  46. if (this.list.some(l => (l === c)))
  47. return;
  48. this.list.push(c);
  49. this.obj.syncer.setArray(true, 'events', 'updateList', {
  50. id: c.id,
  51. name: c.config.name,
  52. description: c.config.description
  53. });
  54. }, this);
  55. }
  56. }
  57. };