EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
ref
Yuri Kuznetsov3ae31f63415f
diff --git a/client/modules/crm/src/views/contact/modals/select-for-portal-user.js b/client/modules/crm/src/views/contact/modals/select-for-portal-user.jsindex 2642de2208..9d0099814c 100644--- a/client/modules/crm/src/views/contact/modals/select-for-portal-user.js+++ b/client/modules/crm/src/views/contact/modals/select-for-portal-user.js@@ -26,22 +26,35 @@* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.************************************************************************/-define('crm:views/contact/modals/select-for-portal-user', ['views/modals/select-records'], function (Dep) {+import SelectRecordsModalView from 'views/modals/select-records';- return Dep.extend({+export default class SelectForPortalUserModalView extends SelectRecordsModalView {- setup: function () {- Dep.prototype.setup.call(this);+ /**+ * @param {+ * module:views/modals/select-records~Options &+ * {onSkip: function()}+ * } options+ */+ constructor(options) {+ super(options);- this.buttonList.unshift({- name: 'skip',- text: this.translate('Proceed w/o Contact', 'labels', 'User')- });- },+ this.options = options;+ }- actionSkip: function () {- this.trigger('skip');- this.remove();- },- });-});+ setup() {+ super.setup();++ this.buttonList.unshift({+ name: 'skip',+ text: this.translate('Proceed w/o Contact', 'labels', 'User'),+ onClick: () => this.actionSkip(),+ });+ }++ actionSkip() {+ this.options.onSkip();++ this.close();+ }+}diff --git a/client/src/views/portal-user/list.js b/client/src/views/portal-user/list.jsindex 9b6c97f88e..188c5a046e 100644--- a/client/src/views/portal-user/list.js+++ b/client/src/views/portal-user/list.js@@ -27,17 +27,22 @@************************************************************************/import ListView from 'views/list';+import SelectForPortalUserModalView from 'modules/crm/views/contact/modals/select-for-portal-user';class PortalUserListView extends ListView {defaultOrderBy = 'createdAt'defaultOrder = 'desc'- actionCreate() {- const viewName = 'crm:views/contact/modals/select-for-portal-user';-- this.createView('modal', viewName, {- scope: 'Contact',+ async actionCreate(data) {+ /**+ * @type {+ * module:views/modals/select-records~Options &+ * {onSkip: function()}+ * }+ */+ const options = {+ entityType: 'Contact',primaryFilterName: 'notPortalUsers',createButton: false,mandatorySelectAttributeList: [@@ -50,21 +55,20 @@ class PortalUserListView extends ListView {'emailAddressData','phoneNumber','phoneNumberData',- ]- }, view => {- view.render();+ ],+ onSelect: models => {+ const model = models[0];- this.listenToOnce(view, 'select', model => {const attributes = {};attributes.contactId = model.id;- attributes.contactName = model.get('name');+ attributes.contactName = model.attributes.name;- if (model.get('accountId')) {+ if (model.attributes.accountId) {const names = {};- names[model.get('accountId')] = model.get('accountName');+ names[model.attributes.accountId] = model.attributes.accountName;- attributes.accountsIds = [model.get('accountId')];+ attributes.accountsIds = [model.attributes.accountId];attributes.accountsNames = names;}@@ -86,32 +90,28 @@ class PortalUserListView extends ListView {attributes.type = 'portal';- const router = this.getRouter();-const url = `#${this.scope}/create`;- router.dispatch(this.scope, 'create', {- attributes: attributes- });-- router.navigate(url, {trigger: false});- });-- this.listenToOnce(view, 'skip', () => {+ this.getRouter().dispatch(this.scope, 'create', {attributes: attributes});+ this.getRouter().navigate(url, {trigger: false});+ },+ onSkip: () => {const attributes = {type: 'portal',};- const router = this.getRouter();const url = `#${this.scope}/create`;- router.dispatch(this.scope, 'create', {- attributes: attributes- });+ this.getRouter().dispatch(this.scope, 'create', {attributes: attributes});+ this.getRouter().navigate(url, {trigger: false});+ },+ };++ const view = new SelectForPortalUserModalView(options);++ await this.assignView('modal', view);- router.navigate(url, {trigger: false});- });- });+ await view.render();}}