email draft improvements

This commit is contained in:
Yuri Kuznetsov
2022-01-31 17:24:07 +02:00
parent a7b959a1d9
commit d1effdae81
3 changed files with 74 additions and 10 deletions
+7 -2
View File
@@ -36,7 +36,12 @@
{{#if navigateButtonsEnabled}}
<div class="pull-right">
<div class="btn-group" role="group">
<button type="button" class="btn btn-text btn-icon action {{#unless previousButtonEnabled}} disabled{{/unless}}" data-action="previous" title="{{translate 'Previous Entry'}}">
<button
type="button"
class="btn btn-text btn-icon action {{#unless previousButtonEnabled}} disabled{{/unless}}"
data-action="previous"
title="{{translate 'Previous Entry'}}"
>
<span class="fas fa-chevron-left"></span>
</button>
<button type="button" class="btn btn-text btn-icon action {{#unless nextButtonEnabled}} disabled{{/unless}}" data-action="next" title="{{translate 'Next Entry'}}">
@@ -54,7 +59,7 @@
{{#if dropdownEditItemList}}
<button
type="button"
class="btn btn-default dropdown-toggle"
class="btn btn-default dropdown-toggle dropdown-edit-item-list-button{{#if dropdownEditItemListEmpty}} hidden{{/if}}"
data-toggle="dropdown"
><span class="fas fa-ellipsis-h"></span></button>
<ul class="dropdown-menu pull-left">
+18 -2
View File
@@ -68,12 +68,18 @@ define('views/email/record/detail', 'views/record/detail', function (Dep) {
setup: function () {
Dep.prototype.setup.call(this);
this.addButtonEdit({
name: 'saveDraft',
action: 'save',
label: 'Save Draft',
}, true);
this.addButtonEdit({
name: 'send',
action: 'send',
label: 'Send',
style: 'danger',
});
style: 'primary',
}, true);
this.controlSendButton();
@@ -172,11 +178,21 @@ define('views/email/record/detail', 'views/record/detail', function (Dep) {
if (status === 'Draft') {
this.showActionItem('send');
this.showActionItem('saveDraft');
this.hideActionItem('save');
this.hideActionItem('saveAndContinueEditing');
return;
}
this.hideActionItem('send');
this.hideActionItem('saveDraft');
this.showActionItem('save');
this.showActionItem('saveAndContinueEditing');
},
actionSaveDraft: function () {
this.actionSaveAndContinueEditing();
},
actionMarkAsImportant: function () {
+49 -6
View File
@@ -457,6 +457,14 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct
}
}
for (var i in this.dropdownEditItemList) {
if (this.dropdownEditItemList[i].name === name) {
this.dropdownEditItemList[i].hidden = true;
break;
}
}
for (var i in this.buttonEditList) {
if (this.buttonEditList[i].name === name) {
this.buttonEditList[i].hidden = true;
@@ -478,6 +486,10 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct
if (this.isDropdownItemListEmpty()) {
this.$dropdownItemListButton.addClass('hidden');
}
if (this.isDropdownEditItemListEmpty()) {
this.$dropdownEditItemListButton.addClass('hidden');
}
}
},
@@ -498,6 +510,14 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct
}
}
for (var i in this.dropdownEditItemList) {
if (this.dropdownEditItemList[i].name === name) {
this.dropdownEditItemList[i].hidden = false;
break;
}
}
for (var i in this.buttonEditList) {
if (this.buttonEditList[i].name === name) {
this.buttonEditList[i].hidden = false;
@@ -519,6 +539,10 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct
if (!this.isDropdownItemListEmpty()) {
this.$dropdownItemListButton.removeClass('hidden');
}
if (!this.isDropdownEditItemListEmpty()) {
this.$dropdownItemListButton.removeClass('hidden');
}
}
},
@@ -996,6 +1020,7 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct
dropdownItemList: this.dropdownItemList,
dropdownEditItemList: this.dropdownEditItemList,
dropdownItemListEmpty: this.isDropdownItemListEmpty(),
dropdownEditItemListEmpty: this.isDropdownEditItemListEmpty(),
buttonsDisabled: this.buttonsDisabled,
name: this.name,
id: this.id,
@@ -1021,10 +1046,10 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct
this.buttonList = this.options.buttonList || this.buttonList;
this.dropdownItemList = this.options.dropdownItemList || this.dropdownItemList;
this.buttonList = _.clone(this.buttonList);
this.buttonEditList = _.clone(this.buttonEditList);
this.dropdownItemList = _.clone(this.dropdownItemList);
this.dropdownEditItemList = _.clone(this.dropdownEditItemList);
this.buttonList = Espo.Utils.cloneDeep(this.buttonList);
this.buttonEditList = Espo.Utils.cloneDeep(this.buttonEditList);
this.dropdownItemList = Espo.Utils.cloneDeep(this.dropdownItemList);
this.dropdownEditItemList = Espo.Utils.cloneDeep(this.dropdownEditItemList);
this.returnUrl = this.options.returnUrl || this.returnUrl;
this.returnDispatchParams = this.options.returnDispatchParams || this.returnDispatchParams;
@@ -1040,11 +1065,28 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct
}
var isEmpty = true;
this.dropdownItemList.forEach(function (item) {
this.dropdownItemList.forEach(item => {
if (!item.hidden) {
isEmpty = false;
}
}, this);
});
return isEmpty;
},
isDropdownEditItemListEmpty: function () {
if (this.dropdownEditItemList.length === 0) {
return true;
}
var isEmpty = true;
this.dropdownEditItemList.forEach(item => {
if (!item.hidden) {
isEmpty = false;
}
});
return isEmpty;
},
@@ -1157,6 +1199,7 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct
this.on('after:render', () => {
this.$detailButtonContainer = this.$el.find('.detail-button-container');
this.$dropdownItemListButton = this.$detailButtonContainer.find('.dropdown-item-list-button');
this.$dropdownEditItemListButton = this.$detailButtonContainer.find('.dropdown-edit-item-list-button');
});
if (