email actions

This commit is contained in:
yuri
2016-07-07 17:08:05 +03:00
parent 9111bce47a
commit f1cffcae38
3 changed files with 78 additions and 4 deletions
@@ -46,7 +46,12 @@ Espo.define('views/email-folder/modals/select-folder', 'views/modal', function (
events: {
'click a[data-action="selectFolder"]': function (e) {
var id = $(e.currentTarget).data('id');
this.trigger('select', id);
var model = this.collection.get(id);
var name = this.translate('inbox', 'presetFilters', 'Email');
if (model) {
name = model.get('name');
}
this.trigger('select', id, name);
this.close();
},
},
+71 -2
View File
@@ -43,7 +43,7 @@ Espo.define('views/email/record/detail', 'views/record/detail', function (Dep) {
}
if (this.model.get('status') == 'Archived') {
if (this.model.get('createdById') == 'system' || !this.model.get('createdById')) {
if (this.model.get('createdById') == 'system' || !this.model.get('createdById') || this.model.get('isImported')) {
isRestricted = true;
}
}
@@ -90,6 +90,20 @@ Espo.define('views/email/record/detail', 'views/record/detail', function (Dep) {
'name': 'markAsNotImportant',
'hidden': !this.model.get('isImportant')
});
this.dropdownItemList.push({
'label': 'Move to Trash',
'name': 'moveToTrash',
'hidden': this.model.get('inTrash')
});
this.dropdownItemList.push({
'label': 'Retrieve from Trash',
'name': 'retrieveFromTrash',
'hidden': !this.model.get('inTrash')
});
this.dropdownItemList.push({
'label': 'Move to Folder',
'name': 'moveToFolder'
});
}
this.listenTo(this.model, 'change:isImportant', function () {
@@ -102,6 +116,16 @@ Espo.define('views/email/record/detail', 'views/record/detail', function (Dep) {
}
}, this);
this.listenTo(this.model, 'change:inTrash', function () {
if (this.model.get('inTrash')) {
this.hideActionItem('moveToTrash');
this.showActionItem('retrieveFromTrash');
} else {
this.hideActionItem('retrieveFromTrash');
this.showActionItem('moveToTrash');
}
}, this);
this.listenTo(this.model, 'reply', function () {
this.showField('replies');
this.model.fetch();
@@ -130,8 +154,53 @@ Espo.define('views/email/record/detail', 'views/record/detail', function (Dep) {
this.model.set('isImportant', false);
},
actionMoveToTrash: function () {
$.ajax({
url: 'Email/action/moveToTrash',
type: 'POST',
data: JSON.stringify({
id: this.model.id
})
}).then(function () {
Espo.Ui.warning(this.translate('Moved to Trash', 'labels', 'Email'));
}.bind(this));
this.model.set('inTrash', true);
},
actionRetrieveFromTrash: function () {
$.ajax({
url: 'Email/action/retrieveFromTrash',
type: 'POST',
data: JSON.stringify({
id: this.model.id
})
}).then(function () {
Espo.Ui.warning(this.translate('Retrieved from Trash', 'labels', 'Email'));
}.bind(this));
this.model.set('inTrash', false);
},
actionMoveToFolder: function () {
this.createView('dialog', 'views/email-folder/modals/select-folder', {}, function (view) {
view.render();
this.listenToOnce(view, 'select', function (folderId, folderName) {
this.clearView('dialog');
this.ajaxPostRequest('Email/action/moveToFolder', {
id: this.model.id,
folderId: folderId
}).then(function () {
if (folderId === 'inbox') {
folderId = null;
}
this.model.set('folderId', folderId);
Espo.Ui.success(this.translate('Done'));
}.bind(this));
}, this);
}, this);
},
actionShowBodyPlain: function () {
this.createView('bodyPlain', 'Email.Modals.BodyPlain', {
this.createView('bodyPlain', 'views/email/modals/body-plain', {
model: this.model
}, function (view) {
view.render();
+1 -1
View File
@@ -257,7 +257,7 @@ Espo.define('views/email/record/list', 'views/record/list', function (Dep) {
id: id,
folderId: folderId
}).then(function () {
Espo.Ui.warning(this.translate('Done'));
Espo.Ui.success(this.translate('Done'));
this.collection.fetch();
}.bind(this));
}, this);