ref
This commit is contained in:
@@ -26,14 +26,12 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('views/stream/fields/attachment-multiple', 'views/fields/attachment-multiple', function (Dep) {
|
||||
define('views/stream/fields/attachment-multiple', ['views/fields/attachment-multiple'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
showPreviews: true,
|
||||
|
||||
showPreviewsInListMode: true,
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -26,27 +26,29 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/stream/fields/post', 'views/fields/text', function (Dep) {
|
||||
define('views/stream/fields/post', ['views/fields/text'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
getValueForDisplay: function () {
|
||||
var text = Dep.prototype.getValueForDisplay.call(this);
|
||||
let text = Dep.prototype.getValueForDisplay.call(this);
|
||||
|
||||
if (this.mode === 'detail' || this.mode === 'list') {
|
||||
var mentionData = (this.model.get('data') || {}).mentions || {};
|
||||
if (this.isDetailMode() || this.isListMode()) {
|
||||
let mentionData = (this.model.get('data') || {}).mentions || {};
|
||||
|
||||
Object.keys(mentionData).sort((a, b) => {
|
||||
return a.length < b.length;
|
||||
}).forEach((item) => {
|
||||
var part = '[' + mentionData[item].name + '](#User/view/'+mentionData[item].id + ')';
|
||||
Object
|
||||
.keys(mentionData)
|
||||
.sort((a, b) => {
|
||||
return a.length < b.length;
|
||||
})
|
||||
.forEach(item => {
|
||||
var part = '[' + mentionData[item].name + '](#User/view/'+mentionData[item].id + ')';
|
||||
|
||||
text = text.replace(new RegExp(item, 'g'), part);
|
||||
});
|
||||
text = text.replace(new RegExp(item, 'g'), part);
|
||||
});
|
||||
}
|
||||
|
||||
return text;
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('views/stream/message', 'view', function (Dep) {
|
||||
define('views/stream/message', ['view'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
@@ -47,11 +47,12 @@ Espo.define('views/stream/message', 'view', function (Dep) {
|
||||
}
|
||||
}
|
||||
|
||||
this._template = template;
|
||||
this.templateContent = template;
|
||||
},
|
||||
|
||||
createField: function (key, name, type, params) {
|
||||
type = type || this.model.getFieldType(name) || 'base';
|
||||
|
||||
this.createView(key, this.getFieldManager().getViewName(type), {
|
||||
model: this.model,
|
||||
defs: {
|
||||
@@ -59,10 +60,9 @@ Espo.define('views/stream/message', 'view', function (Dep) {
|
||||
params: params || {}
|
||||
},
|
||||
mode: 'detail',
|
||||
readOnly: true
|
||||
readOnly: true,
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/stream/modals/create-post', 'views/modal', function (Dep) {
|
||||
define('views/stream/modals/create-post', ['views/modal'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
_template: '<div class="record">{{{record}}}</div>',
|
||||
templateContent: '<div class="record">{{{record}}}</div>',
|
||||
|
||||
setup: function () {
|
||||
this.headerHtml = this.translate('Create Post');
|
||||
@@ -56,7 +56,7 @@ define('views/stream/modals/create-post', 'views/modal', function (Dep) {
|
||||
this.createView('record', 'views/stream/record/edit', {
|
||||
model: model,
|
||||
el: this.options.el + ' .record',
|
||||
}, (view) => {
|
||||
}, view => {
|
||||
this.listenTo(view, 'after:save', () => {
|
||||
this.trigger('after:save');
|
||||
});
|
||||
@@ -72,6 +72,5 @@ define('views/stream/modals/create-post', 'views/modal', function (Dep) {
|
||||
actionPost: function () {
|
||||
this.getView('record').save();
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('views/stream/note', 'view', function (Dep) {
|
||||
define('views/stream/note', ['view'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
@@ -62,8 +62,8 @@ Espo.define('views/stream/note', 'view', function (Dep) {
|
||||
if (!this.isUserStream) {
|
||||
if (this.parentModel) {
|
||||
if (
|
||||
this.parentModel.name != this.model.get('parentType') ||
|
||||
this.parentModel.id != this.model.get('parentId')
|
||||
this.parentModel.name !== this.model.get('parentType') ||
|
||||
this.parentModel.id !== this.model.get('parentId')
|
||||
) {
|
||||
this.isThis = false;
|
||||
}
|
||||
@@ -115,25 +115,29 @@ Espo.define('views/stream/note', 'view', function (Dep) {
|
||||
if (~['de_DE', 'nl_NL'].indexOf(language)) {
|
||||
string = Espo.Utils.upperCaseFirst(string);
|
||||
}
|
||||
|
||||
return string;
|
||||
},
|
||||
|
||||
createField: function (name, type, params, view, options) {
|
||||
type = type || this.model.getFieldType(name) || 'base';
|
||||
var o = {
|
||||
|
||||
let o = {
|
||||
model: this.model,
|
||||
defs: {
|
||||
name: name,
|
||||
params: params || {}
|
||||
},
|
||||
el: this.options.el + ' .cell-' + name,
|
||||
mode: 'list'
|
||||
mode: 'list',
|
||||
};
|
||||
|
||||
if (options) {
|
||||
for (var i in options) {
|
||||
o[i] = options[i];
|
||||
}
|
||||
}
|
||||
|
||||
this.createView(name, view || this.getFieldManager().getViewName(type), o);
|
||||
},
|
||||
|
||||
@@ -147,23 +151,25 @@ Espo.define('views/stream/note', 'view', function (Dep) {
|
||||
|
||||
createMessage: function () {
|
||||
if (!this.messageTemplate) {
|
||||
var isTranslated = false;
|
||||
|
||||
var parentType = this.model.get('parentType');
|
||||
let isTranslated = false;
|
||||
let parentType = this.model.get('parentType') || null;
|
||||
|
||||
if (this.isMale()) {
|
||||
this.messageTemplate = this.translate(this.messageName, 'streamMessagesMale', parentType || null) || '';
|
||||
this.messageTemplate = this.translate(this.messageName, 'streamMessagesMale', parentType) || '';
|
||||
|
||||
if (this.messageTemplate !== this.messageName) {
|
||||
isTranslated = true;
|
||||
}
|
||||
} else if (this.isFemale()) {
|
||||
this.messageTemplate = this.translate(this.messageName, 'streamMessagesFemale', parentType || null) || '';
|
||||
this.messageTemplate = this.translate(this.messageName, 'streamMessagesFemale', parentType) || '';
|
||||
|
||||
if (this.messageTemplate !== this.messageName) {
|
||||
isTranslated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isTranslated) {
|
||||
this.messageTemplate = this.translate(this.messageName, 'streamMessages', parentType || null) || '';
|
||||
this.messageTemplate = this.translate(this.messageName, 'streamMessages', parentType) || '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,24 +177,40 @@ Espo.define('views/stream/note', 'view', function (Dep) {
|
||||
messageTemplate: this.messageTemplate,
|
||||
el: this.options.el + ' .message',
|
||||
model: this.model,
|
||||
messageData: this.messageData
|
||||
messageData: this.messageData,
|
||||
});
|
||||
},
|
||||
|
||||
getAvatarHtml: function () {
|
||||
var id = this.model.get('createdById');
|
||||
let id = this.model.get('createdById');
|
||||
|
||||
if (this.isSystemAvatar) {
|
||||
id = 'system';
|
||||
}
|
||||
|
||||
return this.getHelper().getAvatarHtml(id, 'small', 20);
|
||||
},
|
||||
|
||||
getIconHtml: function (scope, id) {
|
||||
if (this.isThis && scope === this.parentModel.name) return;
|
||||
var iconClass = this.getMetadata().get(['clientDefs', scope, 'iconClass']);
|
||||
if (!iconClass) return;
|
||||
return '<span class="'+iconClass+' action text-muted icon" style="cursor: pointer;" title="'+this.translate('View')+'" data-action="quickView" data-id="'+id+'" data-scope="'+scope+'"></span>';
|
||||
}
|
||||
if (this.isThis && scope === this.parentModel.name) {
|
||||
return;
|
||||
}
|
||||
|
||||
let iconClass = this.getMetadata().get(['clientDefs', scope, 'iconClass']);
|
||||
|
||||
if (!iconClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $('<span>')
|
||||
.addClass(iconClass)
|
||||
.addClass('action text-muted icon')
|
||||
.css('cursor', 'pointer')
|
||||
.attr('title', this.translate('View'))
|
||||
.attr('data-action', 'quickView')
|
||||
.attr('data-id', id)
|
||||
.attr('data-scope', scope)
|
||||
.get(0).outerHTML;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('views/stream/notes/assign', 'views/stream/note', function (Dep) {
|
||||
define('views/stream/notes/assign', ['views/stream/note'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
@@ -34,32 +34,31 @@ Espo.define('views/stream/notes/assign', 'views/stream/note', function (Dep) {
|
||||
|
||||
messageName: 'assign',
|
||||
|
||||
data: function () {
|
||||
return _.extend({
|
||||
}, Dep.prototype.data.call(this));
|
||||
},
|
||||
|
||||
init: function () {
|
||||
if (this.getUser().isAdmin()) {
|
||||
this.isRemovable = true;
|
||||
}
|
||||
|
||||
Dep.prototype.init.call(this);
|
||||
},
|
||||
|
||||
setup: function () {
|
||||
var data = this.model.get('data');
|
||||
let data = this.model.get('data');
|
||||
|
||||
this.assignedUserId = data.assignedUserId || null;
|
||||
this.assignedUserName = data.assignedUserName || null;
|
||||
|
||||
this.messageData['assignee'] = '<a href="#User/view/' + this.getHelper().escapeString(data.assignedUserId) + '">' + this.getHelper().escapeString(data.assignedUserName) + '</a>';
|
||||
this.messageData['assignee'] = $('<a>')
|
||||
.attr('href', '#User/view/' + data.assignedUserId)
|
||||
.text(data.assignedUserName)
|
||||
.get(0).outerHTML;
|
||||
|
||||
if (this.isUserStream) {
|
||||
if (this.assignedUserId) {
|
||||
if (this.assignedUserId == this.model.get('createdById')) {
|
||||
if (this.assignedUserId === this.model.get('createdById')) {
|
||||
this.messageName += 'Self';
|
||||
} else {
|
||||
if (this.assignedUserId == this.getUser().id) {
|
||||
if (this.assignedUserId === this.getUser().id) {
|
||||
this.messageName += 'You';
|
||||
}
|
||||
}
|
||||
@@ -68,7 +67,7 @@ Espo.define('views/stream/notes/assign', 'views/stream/note', function (Dep) {
|
||||
}
|
||||
} else {
|
||||
if (this.assignedUserId) {
|
||||
if (this.assignedUserId == this.model.get('createdById')) {
|
||||
if (this.assignedUserId === this.model.get('createdById')) {
|
||||
this.messageName += 'Self';
|
||||
}
|
||||
} else {
|
||||
@@ -78,7 +77,5 @@ Espo.define('views/stream/notes/assign', 'views/stream/note', function (Dep) {
|
||||
|
||||
this.createMessage();
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('views/stream/notes/create-related', 'views/stream/note', function (Dep) {
|
||||
define('views/stream/notes/create-related', ['views/stream/note'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
@@ -37,7 +37,7 @@ Espo.define('views/stream/notes/create-related', 'views/stream/note', function (
|
||||
data: function () {
|
||||
return _.extend({
|
||||
relatedTypeString: this.translateEntityType(this.entityType),
|
||||
iconHtml: this.getIconHtml(this.entityType, this.entityId)
|
||||
iconHtml: this.getIconHtml(this.entityType, this.entityId),
|
||||
}, Dep.prototype.data.call(this));
|
||||
},
|
||||
|
||||
@@ -45,21 +45,26 @@ Espo.define('views/stream/notes/create-related', 'views/stream/note', function (
|
||||
if (this.getUser().isAdmin()) {
|
||||
this.isRemovable = true;
|
||||
}
|
||||
|
||||
Dep.prototype.init.call(this);
|
||||
},
|
||||
|
||||
setup: function () {
|
||||
var data = this.model.get('data') || {};
|
||||
let data = this.model.get('data') || {};
|
||||
|
||||
this.entityType = this.model.get('relatedType') || data.entityType || null;
|
||||
this.entityId = this.model.get('relatedId') || data.entityId || null;
|
||||
this.entityName = this.model.get('relatedName') || data.entityName || null;
|
||||
|
||||
this.messageData['relatedEntityType'] = this.translateEntityType(this.entityType);
|
||||
this.messageData['relatedEntity'] = '<a href="#' + this.getHelper().escapeString(this.entityType) + '/view/' + this.getHelper().escapeString(this.entityId) + '">' + this.getHelper().escapeString(this.entityName) +'</a>';
|
||||
|
||||
this.messageData['relatedEntity'] = $('<a>')
|
||||
.attr('href', '#' + this.entityType + '/view/' + this.entityId)
|
||||
.text(this.entityName)
|
||||
.get(0).outerHTML;
|
||||
|
||||
this.createMessage();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('views/stream/notes/create', 'views/stream/note', function (Dep) {
|
||||
define('views/stream/notes/create', ['views/stream/note'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
@@ -47,16 +47,20 @@ Espo.define('views/stream/notes/create', 'views/stream/note', function (Dep) {
|
||||
|
||||
setup: function () {
|
||||
if (this.model.get('data')) {
|
||||
var data = this.model.get('data');
|
||||
let data = this.model.get('data');
|
||||
|
||||
this.assignedUserId = data.assignedUserId || null;
|
||||
this.assignedUserName = data.assignedUserName || null;
|
||||
|
||||
this.messageData['assignee'] = '<a href="#User/view/' + this.assignedUserId + '">' + this.getHelper().escapeString(this.assignedUserName) + '</a>';
|
||||
this.messageData['assignee'] = $('<a>')
|
||||
.attr('href', '#User/view/' + this.assignedUserId)
|
||||
.text(this.assignedUserName)
|
||||
.get(0).outerHTML;
|
||||
|
||||
let isYou = false;
|
||||
|
||||
var isYou = false;
|
||||
if (this.isUserStream) {
|
||||
if (this.assignedUserId == this.getUser().id) {
|
||||
if (this.assignedUserId === this.getUser().id) {
|
||||
isYou = true;
|
||||
}
|
||||
}
|
||||
@@ -67,11 +71,11 @@ Espo.define('views/stream/notes/create', 'views/stream/note', function (Dep) {
|
||||
if (this.isThis) {
|
||||
this.messageName += 'This';
|
||||
|
||||
if (this.assignedUserId == this.model.get('createdById')) {
|
||||
if (this.assignedUserId === this.model.get('createdById')) {
|
||||
this.messageName += 'Self';
|
||||
}
|
||||
} else {
|
||||
if (this.assignedUserId == this.model.get('createdById')) {
|
||||
if (this.assignedUserId === this.model.get('createdById')) {
|
||||
this.messageName += 'Self';
|
||||
} else {
|
||||
if (isYou) {
|
||||
@@ -82,10 +86,12 @@ Espo.define('views/stream/notes/create', 'views/stream/note', function (Dep) {
|
||||
}
|
||||
|
||||
if (data.statusField) {
|
||||
var statusField = this.statusField = data.statusField;
|
||||
var statusValue = data.statusValue;
|
||||
let statusField = this.statusField = data.statusField;
|
||||
let statusValue = data.statusValue;
|
||||
|
||||
this.statusStyle = data.statusStyle || 'default';
|
||||
this.statusText = this.getLanguage().translateOption(statusValue, statusField, this.model.get('parentType'));
|
||||
this.statusText = this.getLanguage()
|
||||
.translateOption(statusValue, statusField, this.model.get('parentType'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('views/stream/notes/email-received', 'views/stream/note', function (Dep) {
|
||||
define('views/stream/notes/email-received', ['views/stream/note'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
@@ -53,21 +53,33 @@ Espo.define('views/stream/notes/email-received', 'views/stream/note', function (
|
||||
this.emailName = data.emailName;
|
||||
|
||||
if (
|
||||
this.parentModel
|
||||
&&
|
||||
(this.model.get('parentType') == this.parentModel.name && this.model.get('parentId') == this.parentModel.id)
|
||||
this.parentModel &&
|
||||
(
|
||||
this.model.get('parentType') === this.parentModel.name &&
|
||||
this.model.get('parentId') === this.parentModel.id
|
||||
)
|
||||
) {
|
||||
if (this.model.get('post')) {
|
||||
this.createField('post', null, null, 'views/stream/fields/post');
|
||||
this.hasPost = true;
|
||||
}
|
||||
|
||||
if ((this.model.get('attachmentsIds') || []).length) {
|
||||
this.createField('attachments', 'attachmentMultiple', {}, 'views/stream/fields/attachment-multiple');
|
||||
this.createField(
|
||||
'attachments',
|
||||
'attachmentMultiple',
|
||||
{},
|
||||
'views/stream/fields/attachment-multiple'
|
||||
);
|
||||
|
||||
this.hasAttachments = true;
|
||||
}
|
||||
}
|
||||
|
||||
this.messageData['email'] = '<a href="#Email/view/' + this.getHelper().escapeString(data.emailId) + '">' + this.getHelper().escapeString(data.emailName) + '</a>';
|
||||
this.messageData['email'] = $('<a>')
|
||||
.attr('href', '#Email/view/' + data.emailId)
|
||||
.text(data.emailName)
|
||||
.get(0).outerHTML;
|
||||
|
||||
this.messageName = 'emailReceived';
|
||||
|
||||
@@ -77,10 +89,17 @@ Espo.define('views/stream/notes/email-received', 'views/stream/note', function (
|
||||
|
||||
if (data.personEntityId) {
|
||||
this.messageName += 'From';
|
||||
this.messageData['from'] = '<a href="#'+this.getHelper().escapeString(data.personEntityType)+'/view/' + this.getHelper().escapeString(data.personEntityId) + '">' + this.getHelper().escapeString(data.personEntityName) + '</a>';
|
||||
|
||||
this.messageData['from'] = $('<a>')
|
||||
.attr('href', '#' + data.personEntityType + '/view/' + data.personEntityId)
|
||||
.text(data.personEntityName)
|
||||
.get(0).outerHTML;
|
||||
}
|
||||
|
||||
if (this.model.get('parentType') === data.personEntityType && this.model.get('parentId') == data.personEntityId) {
|
||||
if (
|
||||
this.model.get('parentType') === data.personEntityType &&
|
||||
this.model.get('parentId') === data.personEntityId
|
||||
) {
|
||||
this.isThis = true;
|
||||
}
|
||||
|
||||
@@ -90,7 +109,6 @@ Espo.define('views/stream/notes/email-received', 'views/stream/note', function (
|
||||
|
||||
this.createMessage();
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('views/stream/notes/email-sent', 'views/stream/note', function (Dep) {
|
||||
define('views/stream/notes/email-sent', ['views/stream/note'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
@@ -51,26 +51,34 @@ Espo.define('views/stream/notes/email-sent', 'views/stream/note', function (Dep)
|
||||
this.emailName = data.emailName;
|
||||
|
||||
if (
|
||||
this.parentModel
|
||||
&&
|
||||
(this.model.get('parentType') == this.parentModel.name && this.model.get('parentId') == this.parentModel.id)
|
||||
this.parentModel &&
|
||||
(
|
||||
this.model.get('parentType') === this.parentModel.name &&
|
||||
this.model.get('parentId') === this.parentModel.id
|
||||
)
|
||||
) {
|
||||
if (this.model.get('post')) {
|
||||
this.createField('post', null, null, 'views/stream/fields/post');
|
||||
this.hasPost = true;
|
||||
}
|
||||
|
||||
if ((this.model.get('attachmentsIds') || []).length) {
|
||||
this.createField('attachments', 'attachmentMultiple', {}, 'views/stream/fields/attachment-multiple');
|
||||
this.hasAttachments = true;
|
||||
}
|
||||
}
|
||||
|
||||
this.messageData['email'] = '<a href="#Email/view/' + this.getHelper().escapeString(data.emailId) + '">' + this.getHelper().escapeString(data.emailName) + '</a>';
|
||||
this.messageData['email'] = $('<a>')
|
||||
.attr('href', '#Email/view/' + data.emailId)
|
||||
.text(data.emailName)
|
||||
.get(0).outerHTML;
|
||||
|
||||
this.messageName = 'emailSent';
|
||||
|
||||
this.messageData['by'] = '<a href="#'+this.getHelper().escapeString(data.personEntityType)+'/view/' + this.getHelper().escapeString(data.personEntityId) + '">' + this.getHelper().escapeString(data.personEntityName) + '</a>';
|
||||
|
||||
this.messageData['by'] = $('<a>')
|
||||
.attr('href', '#' + data.personEntityType + '/view/' + data.personEntityId)
|
||||
.text(data.personEntityName)
|
||||
.get(0).outerHTML;
|
||||
|
||||
if (this.isThis) {
|
||||
this.messageName += 'This';
|
||||
@@ -78,6 +86,5 @@ Espo.define('views/stream/notes/email-sent', 'views/stream/note', function (Dep)
|
||||
|
||||
this.createMessage();
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('views/stream/notes/mention-in-post', 'views/stream/note', function (Dep) {
|
||||
define('views/stream/notes/mention-in-post', ['views/stream/note'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
@@ -35,9 +35,11 @@ Espo.define('views/stream/notes/mention-in-post', 'views/stream/note', function
|
||||
messageName: 'mentionInPost',
|
||||
|
||||
data: function () {
|
||||
var data = Dep.prototype.data.call(this);
|
||||
let data = Dep.prototype.data.call(this);
|
||||
|
||||
data.showAttachments = !!(this.model.get('attachmentsIds') || []).length;
|
||||
data.showPost = !!this.model.get('post');
|
||||
|
||||
return data;
|
||||
},
|
||||
|
||||
@@ -45,71 +47,114 @@ Espo.define('views/stream/notes/mention-in-post', 'views/stream/note', function
|
||||
if (this.model.get('post')) {
|
||||
this.createField('post', null, null, 'views/stream/fields/post');
|
||||
}
|
||||
|
||||
if ((this.model.get('attachmentsIds') || []).length) {
|
||||
this.createField('attachments', 'attachmentMultiple', {}, 'views/stream/fields/attachment-multiple', {
|
||||
previewSize: this.options.isNotification ? 'small' : null
|
||||
});
|
||||
}
|
||||
|
||||
var data = this.model.get('data');
|
||||
|
||||
this.messageData['mentioned'] = this.options.userId;
|
||||
|
||||
if (!this.model.get('parentId')) {
|
||||
this.messageName = 'mentionInPostTarget';
|
||||
}
|
||||
|
||||
if (this.isUserStream) {
|
||||
if (this.options.userId == this.getUser().id) {
|
||||
if (!this.model.get('parentId')) {
|
||||
this.messageName = 'mentionYouInPostTarget';
|
||||
if (this.model.get('isGlobal')) {
|
||||
this.messageName = 'mentionYouInPostTargetAll';
|
||||
} else {
|
||||
this.messageName = 'mentionYouInPostTarget';
|
||||
if (this.model.has('teamsIds') && this.model.get('teamsIds').length) {
|
||||
var teamIdList = this.model.get('teamsIds');
|
||||
var teamNameHash = this.model.get('teamsNames') || {};
|
||||
if (!this.isUserStream || this.options.userId !== this.getUser().id) {
|
||||
this.createMessage();
|
||||
|
||||
var targetHtml = '';
|
||||
var teamHtmlList = [];
|
||||
teamIdList.forEach(function (teamId) {
|
||||
var teamName = teamNameHash[teamId];
|
||||
if (teamName) {
|
||||
teamHtmlList.push('<a href="#Team/view/' + this.getHelper().escapeString(teamId) + '">' + this.getHelper().escapeString(teamName) + '</a>');
|
||||
}
|
||||
}, this);
|
||||
return;
|
||||
}
|
||||
|
||||
this.messageData['target'] = teamHtmlList.join(', ');
|
||||
} else if (this.model.has('usersIds') && this.model.get('usersIds').length) {
|
||||
var userIdList = this.model.get('usersIds');
|
||||
var userNameHash = this.model.get('usersNames') || {};
|
||||
if (this.model.get('parentId')) {
|
||||
this.messageName = 'mentionYouInPost';
|
||||
|
||||
if (userIdList.length === 1 && userIdList[0] === this.model.get('createdById')) {
|
||||
this.messageName = 'mentionYouInPostTargetNoTarget';
|
||||
} else {
|
||||
var userHtml = '';
|
||||
var userHtmlList = [];
|
||||
userIdList.forEach(function (userId) {
|
||||
var userName = userNameHash[userId];
|
||||
if (userName) {
|
||||
userHtmlList.push('<a href="#User/view/' + this.getHelper().escapeString(userId) + '">' + this.getHelper().escapeString(userName) + '</a>');
|
||||
}
|
||||
}, this);
|
||||
this.messageData['target'] = userHtmlList.join(', ');
|
||||
}
|
||||
} else if (this.model.get('targetType') === 'self') {
|
||||
this.messageName = 'mentionYouInPostTargetNoTarget';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.messageName = 'mentionYouInPost';
|
||||
this.createMessage();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.messageName = 'mentionYouInPostTarget';
|
||||
|
||||
if (this.model.get('isGlobal')) {
|
||||
this.messageName = 'mentionYouInPostTargetAll';
|
||||
|
||||
this.createMessage();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.messageName = 'mentionYouInPostTarget';
|
||||
|
||||
if (this.model.has('teamsIds') && this.model.get('teamsIds').length) {
|
||||
let teamIdList = this.model.get('teamsIds');
|
||||
let teamNameHash = this.model.get('teamsNames') || {};
|
||||
|
||||
let teamHtmlList = [];
|
||||
|
||||
teamIdList.forEach(teamId => {
|
||||
let teamName = teamNameHash[teamId];
|
||||
|
||||
if (!teamName) {
|
||||
return;
|
||||
}
|
||||
|
||||
teamHtmlList.push(
|
||||
$('<a>')
|
||||
.attr('href', '#Team/view/' + teamId)
|
||||
.text(teamName)
|
||||
.get(0).outerHTML
|
||||
);
|
||||
});
|
||||
|
||||
this.messageData['target'] = teamHtmlList.join(', ');
|
||||
|
||||
this.createMessage();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.model.has('usersIds') && this.model.get('usersIds').length) {
|
||||
var userIdList = this.model.get('usersIds');
|
||||
var userNameHash = this.model.get('usersNames') || {};
|
||||
|
||||
if (userIdList.length === 1 && userIdList[0] === this.model.get('createdById')) {
|
||||
this.messageName = 'mentionYouInPostTargetNoTarget';
|
||||
|
||||
this.createMessage();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let userHtmlList = [];
|
||||
|
||||
userIdList.forEach(userId => {
|
||||
let userName = userNameHash[userId];
|
||||
|
||||
if (!userName) {
|
||||
return;
|
||||
}
|
||||
|
||||
userHtmlList.push(
|
||||
$('<a>')
|
||||
.attr('href', '#User/view/' + userId)
|
||||
.text(userName)
|
||||
.get(0).outerHTML
|
||||
);
|
||||
});
|
||||
|
||||
this.messageData['target'] = userHtmlList.join(', ');
|
||||
|
||||
this.createMessage();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.model.get('targetType') === 'self') {
|
||||
this.messageName = 'mentionYouInPostTargetNoTarget';
|
||||
}
|
||||
|
||||
this.createMessage();
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/stream/record/edit', 'views/record/base', function (Dep) {
|
||||
define('views/stream/record/edit', ['views/record/base'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/stream/record/list', 'views/record/list-expanded', function (Dep) {
|
||||
define('views/stream/record/list', ['views/record/list-expanded'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
|
||||
@@ -26,11 +26,10 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('views/stream/row-actions/default', 'views/record/row-actions/edit-and-remove', function (Dep) {
|
||||
define('views/stream/row-actions/default', ['views/record/row-actions/edit-and-remove'], function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
|
||||
getActionList: function () {
|
||||
var list = [];
|
||||
|
||||
@@ -39,8 +38,8 @@ Espo.define('views/stream/row-actions/default', 'views/record/row-actions/edit-a
|
||||
action: 'quickEdit',
|
||||
label: 'Edit',
|
||||
data: {
|
||||
id: this.model.id
|
||||
}
|
||||
id: this.model.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -49,14 +48,12 @@ Espo.define('views/stream/row-actions/default', 'views/record/row-actions/edit-a
|
||||
action: 'quickRemove',
|
||||
label: 'Remove',
|
||||
data: {
|
||||
id: this.model.id
|
||||
}
|
||||
id: this.model.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user