選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

75 行
1.3 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. simplifyTransfer: function () {
  25. return this.save();
  26. },
  27. unregisterEvent: function (event) {
  28. this.list.spliceWhere(l => (l === event));
  29. this.obj.syncer.setArray(true, 'events', 'removeList', {
  30. id: event.id
  31. });
  32. },
  33. syncList: function () {
  34. this.list.forEach(function (l) {
  35. this.obj.syncer.setArray(true, 'events', 'updateList', {
  36. id: l.id,
  37. name: l.config.name,
  38. description: l.config.description
  39. });
  40. }, this);
  41. },
  42. events: {
  43. afterMove: function () {
  44. let events = this.obj.instance.events;
  45. let closeEvents = events.getCloseEvents(this.obj);
  46. if (!closeEvents)
  47. return;
  48. closeEvents.forEach(function (c) {
  49. if (this.list.some(l => (l === c)))
  50. return;
  51. this.list.push(c);
  52. this.obj.syncer.setArray(true, 'events', 'updateList', {
  53. id: c.id,
  54. name: c.config.name,
  55. description: c.config.description
  56. });
  57. }, this);
  58. }
  59. }
  60. };