mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
ref
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -26,183 +26,182 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('crm:views/record/panels/history', ['crm:views/record/panels/activities'], function (Dep) {
|
||||
import ActivitiesPanelView from 'crm:views/record/panels/activities';
|
||||
import EmailHelper from 'email-helper';
|
||||
|
||||
return Dep.extend({
|
||||
class HistoryPanelView extends ActivitiesPanelView {
|
||||
|
||||
name: 'history',
|
||||
name = 'history'
|
||||
orderBy = 'dateStart'
|
||||
orderDirection = 'desc'
|
||||
rowActionsView = 'crm:views/record/row-actions/history'
|
||||
|
||||
orderBy: 'dateStart',
|
||||
actionList = []
|
||||
|
||||
orderDirection: 'desc',
|
||||
|
||||
rowActionsView: 'crm:views/record/row-actions/history',
|
||||
|
||||
actionList: [],
|
||||
|
||||
listLayout: {
|
||||
'Email': {
|
||||
rows: [
|
||||
[
|
||||
{name: 'ico', view: 'crm:views/fields/ico'},
|
||||
{
|
||||
name: 'name',
|
||||
link: true,
|
||||
},
|
||||
],
|
||||
[
|
||||
{name: 'status'},
|
||||
{name: 'dateSent'},
|
||||
{name: 'hasAttachment', view: 'views/email/fields/has-attachment'},
|
||||
],
|
||||
]
|
||||
},
|
||||
listLayout = {
|
||||
'Email': {
|
||||
rows: [
|
||||
[
|
||||
{name: 'ico', view: 'crm:views/fields/ico'},
|
||||
{
|
||||
name: 'name',
|
||||
link: true,
|
||||
},
|
||||
],
|
||||
[
|
||||
{name: 'status'},
|
||||
{name: 'dateSent'},
|
||||
{name: 'hasAttachment', view: 'views/email/fields/has-attachment'},
|
||||
],
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
where: {
|
||||
scope: false,
|
||||
},
|
||||
where = {
|
||||
scope: false,
|
||||
}
|
||||
|
||||
setupActionList: function () {
|
||||
Dep.prototype.setupActionList.call(this);
|
||||
setupActionList() {
|
||||
super.setupActionList();
|
||||
|
||||
this.actionList.push({
|
||||
action: 'archiveEmail',
|
||||
label: 'Archive Email',
|
||||
acl: 'create',
|
||||
aclScope: 'Email',
|
||||
});
|
||||
},
|
||||
this.actionList.push({
|
||||
action: 'archiveEmail',
|
||||
label: 'Archive Email',
|
||||
acl: 'create',
|
||||
aclScope: 'Email',
|
||||
});
|
||||
}
|
||||
|
||||
getArchiveEmailAttributes: function (scope, data, callback) {
|
||||
data = data || {};
|
||||
getArchiveEmailAttributes(scope, data, callback) {
|
||||
let attributes = {
|
||||
dateSent: this.getDateTime().getNow(15),
|
||||
status: 'Archived',
|
||||
from: this.model.get('emailAddress'),
|
||||
to: this.getUser().get('emailAddress'),
|
||||
};
|
||||
|
||||
let attributes = {
|
||||
dateSent: this.getDateTime().getNow(15),
|
||||
status: 'Archived',
|
||||
from: this.model.get('emailAddress'),
|
||||
to: this.getUser().get('emailAddress'),
|
||||
};
|
||||
|
||||
if (this.model.entityType === 'Contact') {
|
||||
if (this.getConfig().get('b2cMode')) {
|
||||
attributes.parentType = 'Contact';
|
||||
attributes.parentName = this.model.get('name');
|
||||
attributes.parentId = this.model.id;
|
||||
} else {
|
||||
if (this.model.get('accountId')) {
|
||||
attributes.parentType = 'Account',
|
||||
attributes.parentId = this.model.get('accountId');
|
||||
attributes.parentName = this.model.get('accountName');
|
||||
}
|
||||
}
|
||||
} else if (this.model.entityType === 'Lead') {
|
||||
attributes.parentType = 'Lead';
|
||||
attributes.parentId = this.model.id
|
||||
if (this.model.entityType === 'Contact') {
|
||||
if (this.getConfig().get('b2cMode')) {
|
||||
attributes.parentType = 'Contact';
|
||||
attributes.parentName = this.model.get('name');
|
||||
}
|
||||
|
||||
attributes.nameHash = {};
|
||||
attributes.nameHash[this.model.get('emailAddress')] = this.model.get('name');
|
||||
|
||||
if (scope) {
|
||||
if (!attributes.parentId) {
|
||||
if (this.checkParentTypeAvailability(scope, this.model.entityType)) {
|
||||
attributes.parentType = this.model.entityType;
|
||||
attributes.parentId = this.model.id;
|
||||
attributes.parentName = this.model.get('name');
|
||||
}
|
||||
} else {
|
||||
if (attributes.parentType && !this.checkParentTypeAvailability(scope, attributes.parentType)) {
|
||||
attributes.parentType = null;
|
||||
attributes.parentId = null;
|
||||
attributes.parentName = null;
|
||||
}
|
||||
attributes.parentId = this.model.id;
|
||||
} else {
|
||||
if (this.model.get('accountId')) {
|
||||
attributes.parentType = 'Account';
|
||||
attributes.parentId = this.model.get('accountId');
|
||||
attributes.parentName = this.model.get('accountName');
|
||||
}
|
||||
}
|
||||
} else if (this.model.entityType === 'Lead') {
|
||||
attributes.parentType = 'Lead';
|
||||
attributes.parentId = this.model.id
|
||||
attributes.parentName = this.model.get('name');
|
||||
}
|
||||
|
||||
callback.call(this, attributes);
|
||||
},
|
||||
attributes.nameHash = {};
|
||||
attributes.nameHash[this.model.get('emailAddress')] = this.model.get('name');
|
||||
|
||||
actionArchiveEmail: function (data) {
|
||||
let self = this;
|
||||
let link = 'emails';
|
||||
let scope = 'Email';
|
||||
|
||||
let relate = null;
|
||||
|
||||
if ('emails' in this.model.defs['links']) {
|
||||
relate = {
|
||||
model: this.model,
|
||||
link: this.model.defs['links']['emails'].foreign,
|
||||
};
|
||||
if (scope) {
|
||||
if (!attributes.parentId) {
|
||||
if (this.checkParentTypeAvailability(scope, this.model.entityType)) {
|
||||
attributes.parentType = this.model.entityType;
|
||||
attributes.parentId = this.model.id;
|
||||
attributes.parentName = this.model.get('name');
|
||||
}
|
||||
} else {
|
||||
if (attributes.parentType && !this.checkParentTypeAvailability(scope, attributes.parentType)) {
|
||||
attributes.parentType = null;
|
||||
attributes.parentId = null;
|
||||
attributes.parentName = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Espo.Ui.notify(' ... ');
|
||||
callback.call(this, attributes);
|
||||
}
|
||||
|
||||
let viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') ||
|
||||
'views/modals/edit';
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
actionArchiveEmail(data) {
|
||||
let scope = 'Email';
|
||||
|
||||
this.getArchiveEmailAttributes(scope, data, (attributes) => {
|
||||
this.createView('quickCreate', viewName, {
|
||||
scope: scope,
|
||||
relate: relate,
|
||||
attributes: attributes,
|
||||
}, (view) => {
|
||||
view.render();
|
||||
view.notify(false);
|
||||
let relate = null;
|
||||
|
||||
this.listenToOnce(view, 'after:save', () => {
|
||||
this.collection.fetch();
|
||||
this.model.trigger('after:relate');
|
||||
});
|
||||
if ('emails' in this.model.defs['links']) {
|
||||
relate = {
|
||||
model: this.model,
|
||||
link: this.model.defs['links']['emails'].foreign,
|
||||
};
|
||||
}
|
||||
|
||||
Espo.Ui.notify(' ... ');
|
||||
|
||||
let viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') ||
|
||||
'views/modals/edit';
|
||||
|
||||
this.getArchiveEmailAttributes(scope, data, attributes => {
|
||||
this.createView('quickCreate', viewName, {
|
||||
scope: scope,
|
||||
relate: relate,
|
||||
attributes: attributes,
|
||||
}, (view) => {
|
||||
view.render();
|
||||
view.notify(false);
|
||||
|
||||
this.listenToOnce(view, 'after:save', () => {
|
||||
this.collection.fetch();
|
||||
this.model.trigger('after:relate');
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
actionReply: function (data) {
|
||||
let id = data.id;
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
actionReply(data) {
|
||||
let id = data.id;
|
||||
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
|
||||
Espo.loader.require('email-helper', EmailHelper => {
|
||||
let emailHelper =
|
||||
new EmailHelper(this.getLanguage(), this.getUser(), this.getDateTime(), this.getAcl());
|
||||
let emailHelper = new EmailHelper(
|
||||
this.getLanguage(),
|
||||
this.getUser(),
|
||||
this.getDateTime(),
|
||||
this.getAcl()
|
||||
);
|
||||
|
||||
Espo.Ui.notify(' ... ');
|
||||
Espo.Ui.notify(' ... ');
|
||||
|
||||
this.getModelFactory().create('Email')
|
||||
.then(model => {
|
||||
model.id = id;
|
||||
this.getModelFactory().create('Email')
|
||||
.then(model => {
|
||||
model.id = id;
|
||||
|
||||
model.fetch()
|
||||
.then(() => {
|
||||
let attributes = emailHelper
|
||||
.getReplyAttributes(model, data,
|
||||
this.getPreferences().get('emailReplyToAllByDefault'));
|
||||
model.fetch()
|
||||
.then(() => {
|
||||
let attributes = emailHelper
|
||||
.getReplyAttributes(model, data,
|
||||
this.getPreferences().get('emailReplyToAllByDefault'));
|
||||
|
||||
let viewName = this.getMetadata().get('clientDefs.Email.modalViews.compose') ||
|
||||
'views/modals/compose-email';
|
||||
let viewName = this.getMetadata().get('clientDefs.Email.modalViews.compose') ||
|
||||
'views/modals/compose-email';
|
||||
|
||||
return this.createView('quickCreate', viewName, {
|
||||
attributes: attributes,
|
||||
focusForCreate: true,
|
||||
});
|
||||
})
|
||||
.then(view => {
|
||||
view.render();
|
||||
return this.createView('quickCreate', viewName, {
|
||||
attributes: attributes,
|
||||
focusForCreate: true,
|
||||
});
|
||||
})
|
||||
.then(view => {
|
||||
view.render();
|
||||
|
||||
this.listenToOnce(view, 'after:save', () => {
|
||||
this.collection.fetch();
|
||||
this.model.trigger('after:relate');
|
||||
});
|
||||
this.listenToOnce(view, 'after:save', () => {
|
||||
this.collection.fetch();
|
||||
this.model.trigger('after:relate');
|
||||
});
|
||||
|
||||
view.notify(false);
|
||||
});
|
||||
Espo.Ui.notify(false);
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default HistoryPanelView;
|
||||
|
||||
@@ -171,7 +171,7 @@ class ModalView extends View {
|
||||
* Dropdown action items.
|
||||
*
|
||||
* @protected
|
||||
* @type {module:views/modal~Button[]|false}
|
||||
* @type {Array<module:views/modal~Button|false>}
|
||||
*/
|
||||
dropdownItemList = []
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class BottomPanelView extends View {
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {module:views/record/panels-container~action[]}
|
||||
* @type {Array<module:views/record/panels-container~action|false>}
|
||||
*/
|
||||
actionList = null
|
||||
|
||||
@@ -342,6 +342,7 @@ class BottomPanelView extends View {
|
||||
this.createView(viewKey, viewName, o);
|
||||
}
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
/**
|
||||
* Is tab-hidden.
|
||||
*
|
||||
|
||||
@@ -195,7 +195,8 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
|
||||
this.setupActions();
|
||||
|
||||
var layoutName = 'listSmall';
|
||||
let layoutName = 'listSmall';
|
||||
|
||||
this.setupListLayout();
|
||||
|
||||
if (this.listLayoutName) {
|
||||
@@ -311,7 +312,7 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
setupTitle() {
|
||||
this.title = this.title || this.translate(this.link, 'links', this.model.entityType);
|
||||
|
||||
var iconHtml = '';
|
||||
let iconHtml = '';
|
||||
|
||||
if (!this.getConfig().get('scopeColorsDisabled')) {
|
||||
iconHtml = this.getHelper().getScopeColorIconHtml(this.scope);
|
||||
@@ -336,10 +337,10 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
* @protected
|
||||
*/
|
||||
setupSorting() {
|
||||
var orderBy = this.defs.orderBy || this.defs.sortBy || this.orderBy;
|
||||
var order = this.defs.orderDirection || this.orderDirection || this.order;
|
||||
let orderBy = this.defs.orderBy || this.defs.sortBy || this.orderBy;
|
||||
let order = this.defs.orderDirection || this.orderDirection || this.order;
|
||||
|
||||
if ('asc' in this.defs) { // TODO remove in 5.8
|
||||
if ('asc' in this.defs) { // @todo Remove.
|
||||
order = this.defs.asc ? 'asc' : 'desc';
|
||||
}
|
||||
|
||||
@@ -424,10 +425,10 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
getStoredFilter() {
|
||||
var key = 'panelFilter' + this.model.entityType + '-' + (this.panelName || this.name);
|
||||
let key = 'panelFilter' + this.model.entityType + '-' + (this.panelName || this.name);
|
||||
|
||||
return this.getStorage().get('state', key) || null;
|
||||
}
|
||||
@@ -436,7 +437,7 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
* @private
|
||||
*/
|
||||
storeFilter(filter) {
|
||||
var key = 'panelFilter' + this.model.entityType + '-' + (this.panelName || this.name);
|
||||
let key = 'panelFilter' + this.model.entityType + '-' + (this.panelName || this.name);
|
||||
|
||||
if (filter) {
|
||||
this.getStorage().set('state', key, filter);
|
||||
@@ -459,14 +460,15 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
}
|
||||
}
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
/**
|
||||
* A `select-filter` action.
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
actionSelectFilter(data) {
|
||||
var filter = data.name;
|
||||
var filterInternal = filter;
|
||||
let filter = data.name;
|
||||
let filterInternal = filter;
|
||||
|
||||
if (filter === 'all') {
|
||||
filterInternal = false;
|
||||
@@ -476,7 +478,7 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
this.setFilter(filterInternal);
|
||||
|
||||
this.filterList.forEach(item => {
|
||||
var $el = this.$el.closest('.panel').find('[data-name="'+item+'"] span');
|
||||
let $el = this.$el.closest('.panel').find('[data-name="'+item+'"] span');
|
||||
|
||||
if (item === filter) {
|
||||
$el.removeClass('hidden');
|
||||
@@ -487,10 +489,10 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
|
||||
this.collection.reset();
|
||||
|
||||
var listView = this.getView('list');
|
||||
let listView = this.getView('list');
|
||||
|
||||
if (listView && listView.$el) {
|
||||
var height = listView.$el.parent().get(0).clientHeight;
|
||||
let height = listView.$el.parent().get(0).clientHeight;
|
||||
|
||||
listView.$el.empty();
|
||||
|
||||
@@ -527,7 +529,7 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
* @protected
|
||||
*/
|
||||
actionViewRelatedList(data) {
|
||||
var viewName =
|
||||
let viewName =
|
||||
this.getMetadata().get(
|
||||
['clientDefs', this.model.entityType, 'relationshipPanels', this.name, 'viewModalView']
|
||||
) ||
|
||||
@@ -535,15 +537,15 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
this.viewModalView ||
|
||||
'views/modals/related-list';
|
||||
|
||||
var scope = data.scope || this.scope;
|
||||
let scope = data.scope || this.scope;
|
||||
|
||||
var filter = this.filter;
|
||||
let filter = this.filter;
|
||||
|
||||
if (this.relatedListFiltersDisabled) {
|
||||
filter = null;
|
||||
}
|
||||
|
||||
var options = {
|
||||
let options = {
|
||||
model: this.model,
|
||||
panelName: this.panelName,
|
||||
link: this.link,
|
||||
@@ -565,7 +567,7 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
};
|
||||
|
||||
if (data.viewOptions) {
|
||||
for (var item in data.viewOptions) {
|
||||
for (let item in data.viewOptions) {
|
||||
options[item] = data.viewOptions[item];
|
||||
}
|
||||
}
|
||||
@@ -578,7 +580,7 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
view.render();
|
||||
|
||||
this.listenTo(view, 'action', (action, data, e) => {
|
||||
var method = 'action' + Espo.Utils.upperCaseFirst(action);
|
||||
let method = 'action' + Espo.Utils.upperCaseFirst(action);
|
||||
|
||||
if (typeof this[method] === 'function') {
|
||||
this[method](data, e);
|
||||
@@ -604,6 +606,7 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
return !!this.defs.create;
|
||||
}
|
||||
|
||||
// noinspection JSUnusedLocalSymbols
|
||||
/**
|
||||
* Is select available.
|
||||
*
|
||||
@@ -615,6 +618,7 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
return !!this.defs.select;
|
||||
}
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
/**
|
||||
* A `view-related` action.
|
||||
*
|
||||
@@ -645,16 +649,17 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
});
|
||||
}
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
/**
|
||||
* An `edit-related` action.
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
actionEditRelated(data) {
|
||||
var id = data.id;
|
||||
var scope = this.collection.get(id).name;
|
||||
let id = data.id;
|
||||
let scope = this.collection.get(id).name;
|
||||
|
||||
var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') ||
|
||||
let viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') ||
|
||||
'views/modals/edit';
|
||||
|
||||
Espo.Ui.notify(' ... ');
|
||||
@@ -675,13 +680,14 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
});
|
||||
}
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
/**
|
||||
* An `unlink-related` action.
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
actionUnlinkRelated(data) {
|
||||
var id = data.id;
|
||||
let id = data.id;
|
||||
|
||||
this.confirm({
|
||||
message: this.translate('unlinkRecordConfirmation', 'messages'),
|
||||
@@ -702,13 +708,14 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
});
|
||||
}
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
/**
|
||||
* A `remove-related` action.
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
actionRemoveRelated(data) {
|
||||
var id = data.id;
|
||||
let id = data.id;
|
||||
|
||||
this.confirm({
|
||||
message: this.translate('removeRecordConfirmation', 'messages'),
|
||||
@@ -731,6 +738,7 @@ class RelationshipPanelView extends BottomPanelView {
|
||||
});
|
||||
}
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
/**
|
||||
* An `unlink-all-related` action.
|
||||
*
|
||||
|
||||
@@ -74,7 +74,7 @@ class SidePanelView extends View {
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {module:views/record/panels-container~button[]}
|
||||
* @type {Array<module:views/record/panels-container~action|false>}
|
||||
*/
|
||||
buttonList = null
|
||||
|
||||
@@ -159,6 +159,7 @@ class SidePanelView extends View {
|
||||
}
|
||||
|
||||
item = Espo.Utils.clone(item);
|
||||
|
||||
item.viewKey = item.name + 'Field';
|
||||
item.label = item.label || item.name;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user