From 4b1519367f239cf8b4e9c299f80304599e1e623d Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 19 Jul 2023 14:07:43 +0300 Subject: [PATCH] ref --- client/src/views/fields/user.js | 10 ++++---- client/src/views/fields/users.js | 41 +++++++++++++++++--------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/client/src/views/fields/user.js b/client/src/views/fields/user.js index 8835c95bd1..2805ab230a 100644 --- a/client/src/views/fields/user.js +++ b/client/src/views/fields/user.js @@ -100,6 +100,7 @@ class UserFieldView extends LinkFieldView { if (this.mode === this.MODE_SEARCH) { let $elementTeams = this.$el.find('input.element-teams'); + $elementTeams.autocomplete({ serviceUrl: () => { return 'Team?&maxSize=' + this.getAutocompleteMaxCount() + '&select=id,name'; @@ -109,6 +110,7 @@ class UserFieldView extends LinkFieldView { paramName: 'q', noCache: true, formatResult: suggestion => { + // noinspection JSUnresolvedReference return this.getHelper().escapeString(suggestion.name); }, transformResult: response => { @@ -126,7 +128,7 @@ class UserFieldView extends LinkFieldView { return {suggestions: list}; }, - onSelect: s => { + onSelect: /** {id: string, name: string } */s => { this.addLinkTeams(s.id, s.name); $elementTeams.val(''); @@ -185,11 +187,11 @@ class UserFieldView extends LinkFieldView { } addLinkTeamsHtml(id, name) { - id = Handlebars.Utils.escapeExpression(id); - name = Handlebars.Utils.escapeExpression(name); + id = this.getHelper().escapeString(id); + name = this.getHelper().escapeString(name); let $container = this.$el.find('.link-teams-container'); - + let $el = $('
') .addClass('link-' + id) .addClass('list-group-item'); diff --git a/client/src/views/fields/users.js b/client/src/views/fields/users.js index f16993da8a..54b86c0f57 100644 --- a/client/src/views/fields/users.js +++ b/client/src/views/fields/users.js @@ -26,28 +26,31 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/fields/users', ['views/fields/link-multiple'], function (Dep) { +import LinkMultipleFieldView from 'views/fields/link-multiple'; - return Dep.extend({ +class UsersFieldView extends LinkMultipleFieldView { - init: function () { - this.assignmentPermission = this.getAcl().get('assignmentPermission'); + init() { + this.assignmentPermission = this.getAcl().getPermissionLevel('assignmentPermission'); - if (this.assignmentPermission === 'no') { - this.readOnly = true; - } + if (this.assignmentPermission === 'no') { + this.readOnly = true; + } - Dep.prototype.init.call(this); - }, + super.init(); + } + + getSelectBoolFilterList() { + if (this.assignmentPermission === 'team' || this.assignmentPermission === 'no') { + return ['onlyMyTeam']; + } + } + + getSelectPrimaryFilterName() { + return 'active'; + } +} + +export default UsersFieldView; - getSelectBoolFilterList: function () { - if (this.assignmentPermission === 'team' || this.assignmentPermission === 'no') { - return ['onlyMyTeam']; - } - }, - getSelectPrimaryFilterName: function () { - return 'active'; - }, - }); -});