Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- var Bluebird = require('../../_core/bluebird');
- var view = require('../../services/view');
- // var eventHub = require('../../services/event-hub');
- var popup = require('../../services/popup');
- var modal = require('../../services/modal');
- var MailSending = require('../../models/delivery-mail/mail-sending');
- var TenantInfo = require('../../models/delivery-mail/tenant-info');
- var MailSentList = require('../../models/delivery-mail/list-mail-sent');
- module.exports = view({
- ractive: {
- template: require('./mail-sending-list-tab.mustache'),
- openPopupSendMail: function() {
- var appId = this.get('appId');
- var tenantInfo = new TenantInfo();
- var mailSending = new MailSending();
- mailSending._appId = appId;
- var mailSentList = new MailSentList();
- mailSentList._appId = appId;
- var mailTemplates = this.get('mailTemplates');
- var settingSenders = this.get('settingSenders');
- // FIXME: mailSending fetch
- Bluebird.all([
- tenantInfo.fetch(), //FIXME: wker
- ]).spread(function(tenantInfo) {
- popup.show({
- contentView: require('../../views/popup/popup-content-send-mail'),
- popupId: 'popup-content-send-mail',
- dataView: {
- appId: appId,
- popupClass: 'col-md-2',
- tenantInfo: tenantInfo,
- mailSending: mailSending,
- mailTemplates: mailTemplates,
- settingSenders: settingSenders,
- },
- });
- });
- },
- loadSendingMailList: function() {
- var mailSendingList = new MailSentList.Model();
- mailSendingList._appId = this.get('appId');
- var _self = this;
- mailSendingList.fetch().then(function(mailSendingList) {
- _self.set('mailSendingList', mailSendingList);
- });
- },
- deleteMailSendingList: function() {
- modal.confirm('Xoa').then(function(confirm) {
- if (!confirm) {
- return;
- }
- alert('ok');
- });
- },
- editMailSendingList: function(mail) {
- var mailSentList = new MailSentList();
- mailSentList._appId = this.get('appId');
- mailSentList.id = mail.id;
- mailSentList.fetch().then(function() {
- popup.show({
- contentView: require('../../views/popup/popup-content-send-mail'),
- popupId: 'popup-content-send-mail',
- // popupClass: 'col-md-12',
- dataView: {
- appId: mailSentList._appId,
- mailSentList: mailSentList,
- },
- });
- }).catch(function(error) {
- return modal.alert('record_history_back_to_previous_version_failed'); // FIXME
- });
- },
- previewMailSending: function(mail) {
- var mailSentList = new MailSentList();
- mailSentList._appId = this.get('appId');
- mailSentList.id = mail.id;
- mailSentList.fetch().then(function() {
- popup.show({
- contentView: require('../../views/popup/popup-preview-mail'),
- popupId: 'popup-content-preview-mail',
- popupClass: 'col-md-8',
- data: {
- appId: mailSentList._appId,
- mailSentList: mailSentList,
- currentStep: 0,
- name: 'rtyuio',
- age: '45678'
- },
- });
- }).catch(function(error) {
- return modal.alert('record_history_back_to_previous_version_failed'); // FIXME
- });
- },
- },
- initialize: function(view, opt) {
- var data = [
- {
- name: '675432',
- send_date: '2345678',
- note: '3456789'
- },
- {
- name: 'kjhgfd',
- send_date: 'oiuytre',
- note: 'jhgtrf'
- },
- ];
- // var appId = opt.model.appId;
- var mailSentList = new MailSentList(data);
- view.set({
- appId: opt.model.appId,
- mailSendings: opt.model.mailSendings,
- mailTemplates: opt.model.mailTemplates,
- settingSenders: opt.model.settingSenders,
- // mailSentList: opt.model.mailSentList,
- // mailSentList: mailSentList,
- });
- // mailSentList._appId = appId;
- // mailSentList.fetch().then(function() {
- view.set({
- mailSentList: mailSentList,
- });
- // });
- },
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement