email address autocomplete max size
This commit is contained in:
@@ -42,11 +42,10 @@ class EmailAddress extends \Espo\Core\Controllers\Record
|
||||
throw new Forbidden();
|
||||
}
|
||||
$q = $request->get('q');
|
||||
$limit = intval($request->get('limit'));
|
||||
if (empty($limit) || $limit > 30) {
|
||||
$limit = 5;
|
||||
$maxSize = intval($request->get('maxSize'));
|
||||
if (empty($maxSize) || $maxSize > 50) {
|
||||
$maxSize = $this->getConfig()->get('recordsPerPage', 20);
|
||||
}
|
||||
return $this->getRecordService()->searchInAddressBook($q, $limit);
|
||||
return $this->getRecordService()->searchInAddressBook($q, $maxSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,13 @@ Espo.define('views/email/fields/email-address-varchar', ['views/fields/varchar',
|
||||
}
|
||||
},
|
||||
|
||||
getAutocompleteMaxCount: function () {
|
||||
if (this.autocompleteMaxCount) {
|
||||
return this.autocompleteMaxCount;
|
||||
}
|
||||
return this.getConfig().get('recordsPerPage');
|
||||
},
|
||||
|
||||
parseNameFromStringAddress: function (s) {
|
||||
return From.prototype.parseNameFromStringAddress.call(this, s);
|
||||
},
|
||||
@@ -143,7 +150,7 @@ Espo.define('views/email/fields/email-address-varchar', ['views/fields/varchar',
|
||||
|
||||
this.$input.autocomplete({
|
||||
serviceUrl: function (q) {
|
||||
return 'EmailAddress/action/searchInAddressBook?limit=5';
|
||||
return 'EmailAddress/action/searchInAddressBook?maxSize=' + this.getAutocompleteMaxCount();
|
||||
}.bind(this),
|
||||
paramName: 'q',
|
||||
minChars: 1,
|
||||
|
||||
@@ -29,6 +29,13 @@ Espo.define('views/email/fields/email-address', ['views/fields/base'], function
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
getAutocompleteMaxCount: function () {
|
||||
if (this.autocompleteMaxCount) {
|
||||
return this.autocompleteMaxCount;
|
||||
}
|
||||
return this.getConfig().get('recordsPerPage');
|
||||
},
|
||||
|
||||
afterRender: function () {
|
||||
Dep.prototype.afterRender.call(this);
|
||||
|
||||
@@ -37,7 +44,7 @@ Espo.define('views/email/fields/email-address', ['views/fields/base'], function
|
||||
if (this.mode == 'search') {
|
||||
this.$input.autocomplete({
|
||||
serviceUrl: function (q) {
|
||||
return 'EmailAddress/action/searchInAddressBook?limit=5';
|
||||
return 'EmailAddress/action/searchInAddressBook?maxSize=' + this.getAutocompleteMaxCount();
|
||||
}.bind(this),
|
||||
paramName: 'q',
|
||||
minChars: 1,
|
||||
|
||||
@@ -126,6 +126,13 @@ Espo.define('views/fields/email', 'views/fields/varchar', function (Dep) {
|
||||
return data;
|
||||
},
|
||||
|
||||
getAutocompleteMaxCount: function () {
|
||||
if (this.autocompleteMaxCount) {
|
||||
return this.autocompleteMaxCount;
|
||||
}
|
||||
return this.getConfig().get('recordsPerPage');
|
||||
},
|
||||
|
||||
events: {
|
||||
'click [data-action="mailTo"]': function (e) {
|
||||
this.mailTo($(e.currentTarget).data('email-address'));
|
||||
@@ -230,7 +237,7 @@ Espo.define('views/fields/email', 'views/fields/varchar', function (Dep) {
|
||||
if (this.mode == 'search') {
|
||||
this.$element.autocomplete({
|
||||
serviceUrl: function (q) {
|
||||
return 'EmailAddress/action/searchInAddressBook?limit=5';
|
||||
return 'EmailAddress/action/searchInAddressBook?maxSize=' + this.getAutocompleteMaxCount();
|
||||
}.bind(this),
|
||||
paramName: 'q',
|
||||
minChars: 1,
|
||||
|
||||
Reference in New Issue
Block a user