Advertisement
Guest User

543

a guest
Jul 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. 'use strict';
  2. var Bluebird = require('../../_core/bluebird');
  3.  
  4. var view = require('../../services/view');
  5. // var eventHub = require('../../services/event-hub');
  6. var popup = require('../../services/popup');
  7. var modal = require('../../services/modal');
  8.  
  9. var MailSending = require('../../models/delivery-mail/mail-sending');
  10. var TenantInfo = require('../../models/delivery-mail/tenant-info');
  11. var MailSentList = require('../../models/delivery-mail/list-mail-sent');
  12.  
  13. module.exports = view({
  14. ractive: {
  15. template: require('./mail-sending-list-tab.mustache'),
  16. openPopupSendMail: function() {
  17. var appId = this.get('appId');
  18. var tenantInfo = new TenantInfo();
  19.  
  20. var mailSending = new MailSending();
  21. mailSending._appId = appId;
  22.  
  23. var mailSentList = new MailSentList();
  24. mailSentList._appId = appId;
  25.  
  26. var mailTemplates = this.get('mailTemplates');
  27. var settingSenders = this.get('settingSenders');
  28.  
  29. // FIXME: mailSending fetch
  30. Bluebird.all([
  31. tenantInfo.fetch(), //FIXME: wker
  32. ]).spread(function(tenantInfo) {
  33. popup.show({
  34. contentView: require('../../views/popup/popup-content-send-mail'),
  35. popupId: 'popup-content-send-mail',
  36. dataView: {
  37. appId: appId,
  38. popupClass: 'col-md-2',
  39. tenantInfo: tenantInfo,
  40. mailSending: mailSending,
  41. mailTemplates: mailTemplates,
  42. settingSenders: settingSenders,
  43. },
  44. });
  45. });
  46. },
  47. loadSendingMailList: function() {
  48. var mailSendingList = new MailSentList.Model();
  49. mailSendingList._appId = this.get('appId');
  50. var _self = this;
  51. mailSendingList.fetch().then(function(mailSendingList) {
  52. _self.set('mailSendingList', mailSendingList);
  53. });
  54. },
  55. deleteMailSendingList: function() {
  56. modal.confirm('Xoa').then(function(confirm) {
  57. if (!confirm) {
  58. return;
  59. }
  60. alert('ok');
  61. });
  62. },
  63. editMailSendingList: function(mail) {
  64. var mailSentList = new MailSentList();
  65. mailSentList._appId = this.get('appId');
  66. mailSentList.id = mail.id;
  67. mailSentList.fetch().then(function() {
  68. popup.show({
  69. contentView: require('../../views/popup/popup-content-send-mail'),
  70. popupId: 'popup-content-send-mail',
  71. // popupClass: 'col-md-12',
  72. dataView: {
  73. appId: mailSentList._appId,
  74. mailSentList: mailSentList,
  75. },
  76. });
  77. }).catch(function(error) {
  78. return modal.alert('record_history_back_to_previous_version_failed'); // FIXME
  79. });
  80. },
  81. previewMailSending: function(mail) {
  82. var mailSentList = new MailSentList();
  83. mailSentList._appId = this.get('appId');
  84. mailSentList.id = mail.id;
  85. mailSentList.fetch().then(function() {
  86. popup.show({
  87. contentView: require('../../views/popup/popup-preview-mail'),
  88. popupId: 'popup-content-preview-mail',
  89. popupClass: 'col-md-8',
  90. data: {
  91. appId: mailSentList._appId,
  92. mailSentList: mailSentList,
  93. currentStep: 0,
  94. name: 'rtyuio',
  95. age: '45678'
  96. },
  97. });
  98. }).catch(function(error) {
  99. return modal.alert('record_history_back_to_previous_version_failed'); // FIXME
  100. });
  101. },
  102. },
  103.  
  104. initialize: function(view, opt) {
  105. var data = [
  106. {
  107. name: '675432',
  108. send_date: '2345678',
  109. note: '3456789'
  110. },
  111. {
  112. name: 'kjhgfd',
  113. send_date: 'oiuytre',
  114. note: 'jhgtrf'
  115. },
  116. ];
  117. // var appId = opt.model.appId;
  118. var mailSentList = new MailSentList(data);
  119. view.set({
  120. appId: opt.model.appId,
  121. mailSendings: opt.model.mailSendings,
  122. mailTemplates: opt.model.mailTemplates,
  123. settingSenders: opt.model.settingSenders,
  124. // mailSentList: opt.model.mailSentList,
  125. // mailSentList: mailSentList,
  126.  
  127. });
  128. // mailSentList._appId = appId;
  129. // mailSentList.fetch().then(function() {
  130. view.set({
  131. mailSentList: mailSentList,
  132. });
  133. // });
  134. },
  135.  
  136. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement