This commit is contained in:
Yuri Kuznetsov
2022-08-17 20:33:54 +03:00
parent f7d0723516
commit 66c3aa2011
2 changed files with 46 additions and 39 deletions
@@ -391,42 +391,50 @@ function (Dep, From, EmailAddress) {
return '';
}
var name = this.nameHash[address] || null;
var entityType = this.typeHash[address] || null;
var id = this.idHash[address] || null;
var addressHtml = this.getHelper().escapeString(address);
if (name) {
name = this.getHelper().escapeString(name);
}
var lineHtml;
let name = this.nameHash[address] || null;
let entityType = this.typeHash[address] || null;
let id = this.idHash[address] || null;
if (id) {
lineHtml = '<div>' + '<a href="#' + entityType + '/view/' + id + '">' +
name + '</a> <span class="text-muted chevron-right"></span> ' + addressHtml + '</div>';
return $('<div>')
.append(
$('<a>')
.attr('href', '#' + entityType + '/view/' + id)
.text(name),
' <span class="text-muted chevron-right"></span> ',
$('<span>').text(address)
)
.get(0).outerHTML;
}
let $div = $('<div>');
if (name) {
$div.append(
$('<span>')
.addClass('email-address-line')
.text(name)
.append(' <span class="text-muted chevron-right"></span> ')
.append(
$('<span>').text(address)
)
);
}
else {
if (name) {
lineHtml = '<span class="email-address-line">' + name +
' <span class="text-muted chevron-right"></span> <span>' +
addressHtml + '</span></span>';
}
else {
lineHtml = '<span class="email-address-line">' + addressHtml + '</span>';
}
$div.append(
$('<span>')
.addClass('email-address-line')
.text(address)
);
}
if (!id) {
if (this.getAcl().check('Contact', 'edit')) {
lineHtml = From.prototype.getCreateHtml.call(this, address) + lineHtml;
}
if (this.getAcl().check('Contact', 'create') || this.getAcl().check('Lead', 'create')) {
$div.prepend(
From.prototype.getCreateHtml.call(this, address)
);
}
lineHtml = '<div>' + lineHtml + '</div>';
return lineHtml;
return $div.get(0).outerHTML;
},
validateRequired: function () {
@@ -288,8 +288,6 @@ define(
},
createPerson: function (scope, address) {
address = address;
var fromString = this.model.get('fromString') || this.model.get('fromName');
var name = this.nameHash[address] || null;
@@ -360,8 +358,6 @@ define(
},
addToPerson: function (scope, address) {
var address = address;
var fromString = this.model.get('fromString') || this.model.get('fromName');
var name = this.nameHash[address] || null;
@@ -395,7 +391,7 @@ define(
filters['name'] = {
type: 'equals',
field: 'name',
value: name
value: name,
};
}
@@ -466,31 +462,34 @@ define(
var value = this.$element.val().trim();
if (value) {
var data = {
return {
type: 'equals',
value: value,
}
return data;
}
return false;
return null;
},
validateEmail: function () {
var address = this.model.get(this.name);
if (!address) return;
if (!address) {
return;
}
var addressLowerCase = String(address).toLowerCase();
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (!re.test(addressLowerCase) && address.indexOf(this.erasedPlaceholder) !== 0) {
var msg = this.translate('fieldShouldBeEmail', 'messages').replace('{field}', this.getLabelText());
var msg = this.translate('fieldShouldBeEmail', 'messages')
.replace('{field}', this.getLabelText());
this.showValidationMessage(msg);
return true;
}
},
});
});