From b11bfb0e92de7331baac47e26fd79968573c6f0d Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Sat, 8 Jul 2023 14:22:05 +0300 Subject: [PATCH] name => entityType --- .../crm/src/views/calendar/calendar.js | 8 ++-- .../views/call/record/row-actions/dashlet.js | 2 +- .../views/call/record/row-actions/default.js | 2 +- client/modules/crm/src/views/lead/convert.js | 2 +- client/modules/crm/src/views/lead/detail.js | 2 +- .../crm/src/views/meeting/fields/reminders.js | 2 +- .../meeting/record/row-actions/dashlet.js | 8 ++-- .../meeting/record/row-actions/default.js | 8 ++-- .../crm/src/views/record/panels/activities.js | 38 +++++++++---------- .../crm/src/views/record/panels/history.js | 8 ++-- .../src/views/record/panels/target-lists.js | 4 +- .../crm/src/views/record/panels/tasks.js | 4 +- .../record/row-actions/activities-dashlet.js | 10 ++--- .../views/record/row-actions/activities.js | 4 +- .../src/views/record/row-actions/history.js | 4 +- .../crm/src/views/record/row-actions/tasks.js | 4 +- .../target-list/record/panels/opted-out.js | 2 +- .../target-list/record/row-actions/default.js | 4 +- .../record/row-actions/opted-out.js | 2 +- .../views/task/record/row-actions/dashlet.js | 2 +- .../views/task/record/row-actions/default.js | 2 +- .../fields/name-for-history/list-link.tpl | 2 +- .../res/templates/record/list-tree-item.tpl | 2 +- client/res/templates/record/panels/side.tpl | 2 +- client/src/acl-manager.js | 6 +-- client/src/acl-portal-manager.js | 4 +- .../src/helpers/model/defaults-populator.js | 2 +- client/src/model.js | 4 +- client/src/views/detail.js | 13 ++++++- client/src/views/email/record/detail.js | 2 +- client/src/views/external-account/oauth2.js | 2 +- client/src/views/fields/address.js | 4 +- .../src/views/fields/attachment-multiple.js | 4 +- client/src/views/fields/base.js | 2 +- client/src/views/fields/date.js | 2 +- client/src/views/fields/email.js | 10 ++--- client/src/views/fields/file.js | 4 +- client/src/views/fields/followers.js | 4 +- client/src/views/fields/foreign-array.js | 2 +- client/src/views/fields/foreign-checklist.js | 2 +- client/src/views/fields/foreign-enum.js | 2 +- .../fields/link-multiple-with-columns.js | 6 +-- .../views/fields/link-multiple-with-role.js | 4 +- client/src/views/fields/person-name.js | 2 +- client/src/views/fields/phone.js | 4 +- client/src/views/fields/wysiwyg.js | 2 +- client/src/views/import/detail.js | 4 +- .../import/record/row-actions/duplicates.js | 2 +- client/src/views/merge.js | 2 +- client/src/views/modals/compose-email.js | 2 +- client/src/views/modals/detail.js | 6 +-- client/src/views/modals/edit.js | 4 +- client/src/views/modals/kanban-move-over.js | 2 +- .../personal-data/modals/personal-data.js | 2 +- .../src/views/personal-data/record/record.js | 2 +- client/src/views/record/base.js | 2 - client/src/views/record/detail-middle.js | 2 +- client/src/views/record/detail-side.js | 2 +- client/src/views/record/detail.js | 20 +++++----- client/src/views/record/list-tree-item.js | 2 +- client/src/views/record/list.js | 6 +-- .../src/views/record/panels/default-side.js | 10 ++--- .../src/views/record/panels/relationship.js | 14 +++---- .../record/row-actions/default-kanban.js | 4 +- .../src/views/record/row-actions/default.js | 6 +-- .../record/row-actions/edit-and-remove.js | 2 +- .../row-actions/relationship-no-remove.js | 4 +- .../row-actions/relationship-no-unlink.js | 5 +-- .../row-actions/relationship-view-and-edit.js | 4 +- .../relationship-view-and-unlink.js | 2 +- .../row-actions/relationship-view-only.js | 2 +- .../views/record/row-actions/relationship.js | 4 +- .../views/record/row-actions/view-and-edit.js | 4 +- .../record/row-actions/view-and-remove.js | 2 +- .../src/views/record/row-actions/view-only.js | 2 +- client/src/views/search/filter.js | 2 +- .../views/settings/fields/address-preview.js | 1 + client/src/views/stream/note.js | 4 +- .../src/views/stream/notes/email-received.js | 2 +- client/src/views/stream/notes/email-sent.js | 2 +- client/src/views/stream/notes/update.js | 4 +- client/src/views/stream/panel.js | 14 +++---- client/src/views/stream/record/list.js | 2 +- .../user-security/modals/two-factor-email.js | 3 +- .../src/views/user/password-change-request.js | 5 +-- client/src/views/user/record/detail.js | 2 +- client/src/views/user/record/edit.js | 23 +++++------ .../row-actions/relationship-followers.js | 2 +- 88 files changed, 206 insertions(+), 200 deletions(-) diff --git a/client/modules/crm/src/views/calendar/calendar.js b/client/modules/crm/src/views/calendar/calendar.js index 80075e14db..2b024871d0 100644 --- a/client/modules/crm/src/views/calendar/calendar.js +++ b/client/modules/crm/src/views/calendar/calendar.js @@ -1100,7 +1100,7 @@ class CalendarView extends View { addModel(model) { let d = model.getClonedAttributes(); - d.scope = model.name; + d.scope = model.entityType; let event = this.convertToFcEvent(d); @@ -1108,7 +1108,7 @@ class CalendarView extends View { } updateModel(model) { - let eventId = model.name + '-' + model.id; + let eventId = model.entityType + '-' + model.id; let event = this.calendar.getEventById(eventId); @@ -1118,7 +1118,7 @@ class CalendarView extends View { let attributes = model.getClonedAttributes(); - attributes.scope = model.name; + attributes.scope = model.entityType; let data = this.convertToFcEvent(attributes); @@ -1181,7 +1181,7 @@ class CalendarView extends View { } removeModel(model) { - let event = this.calendar.getEventById(model.name + '-' + model.id); + let event = this.calendar.getEventById(model.entityType + '-' + model.id); if (!event) { return; diff --git a/client/modules/crm/src/views/call/record/row-actions/dashlet.js b/client/modules/crm/src/views/call/record/row-actions/dashlet.js index b246143be6..58bebf6fb7 100644 --- a/client/modules/crm/src/views/call/record/row-actions/dashlet.js +++ b/client/modules/crm/src/views/call/record/row-actions/dashlet.js @@ -57,7 +57,7 @@ define('crm:views/call/record/row-actions/dashlet', ['views/record/row-actions/v label: 'Remove', data: { id: this.model.id, - scope: this.model.name + scope: this.model.entityType } }); } diff --git a/client/modules/crm/src/views/call/record/row-actions/default.js b/client/modules/crm/src/views/call/record/row-actions/default.js index 402cd74282..954d4bd09d 100644 --- a/client/modules/crm/src/views/call/record/row-actions/default.js +++ b/client/modules/crm/src/views/call/record/row-actions/default.js @@ -56,7 +56,7 @@ define('crm:views/call/record/row-actions/default', ['views/record/row-actions/v label: 'Remove', data: { id: this.model.id, - scope: this.model.name + scope: this.model.entityType } }); } diff --git a/client/modules/crm/src/views/lead/convert.js b/client/modules/crm/src/views/lead/convert.js index edbd7f0f83..e9610ca5ce 100644 --- a/client/modules/crm/src/views/lead/convert.js +++ b/client/modules/crm/src/views/lead/convert.js @@ -35,7 +35,7 @@ define('crm:views/lead/convert', ['view'], function (Dep) { data: function () { return { scopeList: this.scopeList, - scope: this.model.name, + scope: this.model.entityType, }; }, diff --git a/client/modules/crm/src/views/lead/detail.js b/client/modules/crm/src/views/lead/detail.js index 92d884b39c..d40dac29ce 100644 --- a/client/modules/crm/src/views/lead/detail.js +++ b/client/modules/crm/src/views/lead/detail.js @@ -56,7 +56,7 @@ define('crm:views/lead/detail', ['views/detail'], function (Dep) { }, actionConvert: function () { - this.getRouter().navigate(this.model.name + '/convert/' + this.model.id , {trigger: true}); + this.getRouter().navigate(this.model.entityType + '/convert/' + this.model.id , {trigger: true}); }, }); }); diff --git a/client/modules/crm/src/views/meeting/fields/reminders.js b/client/modules/crm/src/views/meeting/fields/reminders.js index e82bca187c..b8313c0620 100644 --- a/client/modules/crm/src/views/meeting/fields/reminders.js +++ b/client/modules/crm/src/views/meeting/fields/reminders.js @@ -71,7 +71,7 @@ function (Dep, /** module:ui/select*/Select, moment) { }, setup: function () { - if (this.model.isNew() && !this.model.get(this.name) && this.model.name !== 'Preferences') { + if (this.model.isNew() && !this.model.get(this.name) && this.model.entityType !== 'Preferences') { this.reminderList = this.getPreferences().get('defaultReminders') || []; } else { this.reminderList = this.model.get(this.name) || []; diff --git a/client/modules/crm/src/views/meeting/record/row-actions/dashlet.js b/client/modules/crm/src/views/meeting/record/row-actions/dashlet.js index aaece87105..a6f6f32e95 100644 --- a/client/modules/crm/src/views/meeting/record/row-actions/dashlet.js +++ b/client/modules/crm/src/views/meeting/record/row-actions/dashlet.js @@ -35,7 +35,7 @@ define('crm:views/meeting/record/row-actions/dashlet', ['views/record/row-action actionList.forEach(item => { item.data = item.data || {}; - item.data.scope = this.model.name; + item.data.scope = this.model.entityType; }); if (this.options.acl.edit && !~['Held', 'Not Held'].indexOf(this.model.get('status'))) { @@ -44,7 +44,7 @@ define('crm:views/meeting/record/row-actions/dashlet', ['views/record/row-action label: 'Set Held', data: { id: this.model.id, - scope: this.model.name, + scope: this.model.entityType, } }); @@ -53,7 +53,7 @@ define('crm:views/meeting/record/row-actions/dashlet', ['views/record/row-action label: 'Set Not Held', data: { id: this.model.id, - scope: this.model.name, + scope: this.model.entityType, } }); } @@ -64,7 +64,7 @@ define('crm:views/meeting/record/row-actions/dashlet', ['views/record/row-action label: 'Remove', data: { id: this.model.id, - scope: this.model.name, + scope: this.model.entityType, } }); } diff --git a/client/modules/crm/src/views/meeting/record/row-actions/default.js b/client/modules/crm/src/views/meeting/record/row-actions/default.js index 5d0c4069f8..5f6225b3e2 100644 --- a/client/modules/crm/src/views/meeting/record/row-actions/default.js +++ b/client/modules/crm/src/views/meeting/record/row-actions/default.js @@ -35,7 +35,7 @@ define('crm:views/meeting/record/row-actions/default', ['views/record/row-action actionList.forEach(item => { item.data = item.data || {}; - item.data.scope = this.model.name; + item.data.scope = this.model.entityType; }); if (this.options.acl.edit && !~['Held', 'Not Held'].indexOf(this.model.get('status'))) { @@ -44,7 +44,7 @@ define('crm:views/meeting/record/row-actions/default', ['views/record/row-action label: 'Set Held', data: { id: this.model.id, - scope: this.model.name, + scope: this.model.entityType, } }); @@ -53,7 +53,7 @@ define('crm:views/meeting/record/row-actions/default', ['views/record/row-action label: 'Set Not Held', data: { id: this.model.id, - scope: this.model.name, + scope: this.model.entityType, } }); } @@ -64,7 +64,7 @@ define('crm:views/meeting/record/row-actions/default', ['views/record/row-action label: 'Remove', data: { id: this.model.id, - scope: this.model.name, + scope: this.model.entityType, } }); } diff --git a/client/modules/crm/src/views/record/panels/activities.js b/client/modules/crm/src/views/record/panels/activities.js index 75a0b73081..d1d46831cd 100644 --- a/client/modules/crm/src/views/record/panels/activities.js +++ b/client/modules/crm/src/views/record/panels/activities.js @@ -98,7 +98,7 @@ define('crm:views/record/panels/activities', } }); - this.url = this.serviceName + '/' + this.model.name + '/' + this.model.id + '/' + this.name; + this.url = this.serviceName + '/' + this.model.entityType + '/' + this.model.id + '/' + this.name; this.seeds = {}; @@ -226,8 +226,8 @@ define('crm:views/record/panels/activities', o.data.scope = scope; if ( - this.model.name !== 'User' && - !this.checkParentTypeAvailability(scope, this.model.name) + this.model.entityType !== 'User' && + !this.checkParentTypeAvailability(scope, this.model.entityType) ) { return; } @@ -378,7 +378,7 @@ define('crm:views/record/panels/activities', status: data.status, }; - if (this.model.name === 'User') { + if (this.model.entityType === 'User') { if (this.model.isPortal()) { attributes.usersIds = [this.model.id]; @@ -392,7 +392,7 @@ define('crm:views/record/panels/activities', } } else { - if (this.model.name === 'Contact') { + if (this.model.entityType === 'Contact') { if (this.model.get('accountId') && !this.getConfig().get('b2cMode')) { attributes.parentType = 'Account'; attributes.parentId = this.model.get('accountId'); @@ -408,21 +408,21 @@ define('crm:views/record/panels/activities', } } } - else if (this.model.name === 'Lead') { + else if (this.model.entityType === 'Lead') { attributes.parentType = 'Lead'; attributes.parentId = this.model.id; attributes.parentName = this.model.get('name'); } - if (this.model.name !== 'Account' && this.model.has('contactsIds')) { + if (this.model.entityType !== 'Account' && this.model.has('contactsIds')) { attributes.contactsIds = this.model.get('contactsIds'); attributes.contactsNames = this.model.get('contactsNames'); } if (scope) { if (!attributes.parentId) { - if (this.checkParentTypeAvailability(scope, this.model.name)) { - attributes.parentType = this.model.name; + if (this.checkParentTypeAvailability(scope, this.model.entityType)) { + attributes.parentType = this.model.entityType; attributes.parentId = this.model.id; attributes.parentName = this.model.get('name'); } @@ -509,7 +509,7 @@ define('crm:views/record/panels/activities', to: this.model.get('emailAddress') }; - if (this.model.name === 'Contact') { + if (this.model.entityType === 'Contact') { if (this.getConfig().get('b2cMode')) { attributes.parentType = 'Contact'; attributes.parentName = this.model.get('name'); @@ -517,27 +517,27 @@ define('crm:views/record/panels/activities', } else { if (this.model.get('accountId')) { - attributes.parentType = 'Account', + attributes.parentType = 'Account'; attributes.parentId = this.model.get('accountId'); attributes.parentName = this.model.get('accountName'); } } } - else if (this.model.name === 'Lead') { - attributes.parentType = 'Lead', - attributes.parentId = this.model.id + else if (this.model.entityType === 'Lead') { + attributes.parentType = 'Lead'; + attributes.parentId = this.model.id; attributes.parentName = this.model.get('name'); } - if (~['Contact', 'Lead', 'Account'].indexOf(this.model.name) && this.model.get('emailAddress')) { + if (~['Contact', 'Lead', 'Account'].indexOf(this.model.entityType) && this.model.get('emailAddress')) { attributes.nameHash = {}; attributes.nameHash[this.model.get('emailAddress')] = this.model.get('name'); } if (scope) { if (!attributes.parentId) { - if (this.checkParentTypeAvailability(scope, this.model.name)) { - attributes.parentType = this.model.name; + if (this.checkParentTypeAvailability(scope, this.model.entityType)) { + attributes.parentType = this.model.entityType; attributes.parentId = this.model.id; attributes.parentName = this.model.get('name'); } @@ -555,7 +555,7 @@ define('crm:views/record/panels/activities', if ( attributes.parentType && - attributes.parentType === this.model.name && + attributes.parentType === this.model.entityType && ~emailKeepParentTeamsEntityList.indexOf(attributes.parentType) && this.model.get('teamsIds') && this.model.get('teamsIds').length @@ -649,7 +649,7 @@ define('crm:views/record/panels/activities', }, actionViewRelatedList: function (data) { - data.url = 'Activities/' + this.model.name + '/' + + data.url = 'Activities/' + this.model.entityType + '/' + this.model.id + '/' + this.name + '/list/' + data.scope; data.title = this.translate(this.defs.label) + diff --git a/client/modules/crm/src/views/record/panels/history.js b/client/modules/crm/src/views/record/panels/history.js index be2335f165..4e316fd2d8 100644 --- a/client/modules/crm/src/views/record/panels/history.js +++ b/client/modules/crm/src/views/record/panels/history.js @@ -84,7 +84,7 @@ define('crm:views/record/panels/history', ['crm:views/record/panels/activities'] to: this.getUser().get('emailAddress'), }; - if (this.model.name === 'Contact') { + if (this.model.entityType === 'Contact') { if (this.getConfig().get('b2cMode')) { attributes.parentType = 'Contact'; attributes.parentName = this.model.get('name'); @@ -96,7 +96,7 @@ define('crm:views/record/panels/history', ['crm:views/record/panels/activities'] attributes.parentName = this.model.get('accountName'); } } - } else if (this.model.name === 'Lead') { + } else if (this.model.entityType === 'Lead') { attributes.parentType = 'Lead'; attributes.parentId = this.model.id attributes.parentName = this.model.get('name'); @@ -107,8 +107,8 @@ define('crm:views/record/panels/history', ['crm:views/record/panels/activities'] if (scope) { if (!attributes.parentId) { - if (this.checkParentTypeAvailability(scope, this.model.name)) { - attributes.parentType = this.model.name; + if (this.checkParentTypeAvailability(scope, this.model.entityType)) { + attributes.parentType = this.model.entityType; attributes.parentId = this.model.id; attributes.parentName = this.model.get('name'); } diff --git a/client/modules/crm/src/views/record/panels/target-lists.js b/client/modules/crm/src/views/record/panels/target-lists.js index 4d8afbf3d6..c2f987a362 100644 --- a/client/modules/crm/src/views/record/panels/target-lists.js +++ b/client/modules/crm/src/views/record/panels/target-lists.js @@ -36,7 +36,7 @@ define('crm:views/record/panels/target-lists', ['views/record/panels/relationshi .postRequest('TargetList/action/optOut', { id: data.id, targetId: this.model.id, - targetType: this.model.name, + targetType: this.model.entityType, }) .then(() => { this.collection.fetch(); @@ -52,7 +52,7 @@ define('crm:views/record/panels/target-lists', ['views/record/panels/relationshi .postRequest('TargetList/action/cancelOptOut', { id: data.id, targetId: this.model.id, - targetType: this.model.name, + targetType: this.model.entityType, }) .then(() => { this.collection.fetch(); diff --git a/client/modules/crm/src/views/record/panels/tasks.js b/client/modules/crm/src/views/record/panels/tasks.js index 1ea01a7dcb..4b906a6e55 100644 --- a/client/modules/crm/src/views/record/panels/tasks.js +++ b/client/modules/crm/src/views/record/panels/tasks.js @@ -81,7 +81,7 @@ define('crm:views/record/panels/tasks', ['views/record/panels/relationship'], fu }, setup: function () { - this.parentScope = this.model.name; + this.parentScope = this.model.entityType; this.link = 'tasks'; this.panelName = 'tasksSide'; @@ -92,7 +92,7 @@ define('crm:views/record/panels/tasks', ['views/record/panels/relationship'], fu this.link = 'tasksPrimary'; } - this.url = this.model.name + '/' + this.model.id + '/' + this.link; + this.url = this.model.entityType + '/' + this.model.id + '/' + this.link; this.setupSorting(); diff --git a/client/modules/crm/src/views/record/row-actions/activities-dashlet.js b/client/modules/crm/src/views/record/row-actions/activities-dashlet.js index db0d88caa9..bfa1a395dc 100644 --- a/client/modules/crm/src/views/record/row-actions/activities-dashlet.js +++ b/client/modules/crm/src/views/record/row-actions/activities-dashlet.js @@ -33,11 +33,11 @@ define('crm:views/record/row-actions/activities-dashlet', ['views/record/row-act getActionList: function () { var actionList = Dep.prototype.getActionList.call(this); - var scope = this.model.name; + var scope = this.model.entityType; actionList.forEach(function (item) { item.data = item.data || {}; - item.data.scope = this.model.name; + item.data.scope = this.model.entityType; }, this); if (scope === 'Task') { @@ -57,7 +57,7 @@ define('crm:views/record/row-actions/activities-dashlet', ['views/record/row-act label: 'Set Held', data: { id: this.model.id, - scope: this.model.name + scope: this.model.entityType } }); actionList.push({ @@ -65,7 +65,7 @@ define('crm:views/record/row-actions/activities-dashlet', ['views/record/row-act label: 'Set Not Held', data: { id: this.model.id, - scope: this.model.name + scope: this.model.entityType } }); } @@ -77,7 +77,7 @@ define('crm:views/record/row-actions/activities-dashlet', ['views/record/row-act label: 'Remove', data: { id: this.model.id, - scope: this.model.name + scope: this.model.entityType } }); } diff --git a/client/modules/crm/src/views/record/row-actions/activities.js b/client/modules/crm/src/views/record/row-actions/activities.js index ae005961d9..159c485b76 100644 --- a/client/modules/crm/src/views/record/row-actions/activities.js +++ b/client/modules/crm/src/views/record/row-actions/activities.js @@ -37,7 +37,7 @@ define('crm:views/record/row-actions/activities', ['views/record/row-actions/rel data: { id: this.model.id, }, - link: '#' + this.model.name + '/view/' + this.model.id, + link: '#' + this.model.entityType + '/view/' + this.model.id, }]; if (this.options.acl.edit) { @@ -47,7 +47,7 @@ define('crm:views/record/row-actions/activities', ['views/record/row-actions/rel data: { id: this.model.id, }, - link: '#' + this.model.name + '/edit/' + this.model.id, + link: '#' + this.model.entityType + '/edit/' + this.model.id, }); if (this.model.entityType === 'Meeting' || this.model.entityType === 'Call') { diff --git a/client/modules/crm/src/views/record/row-actions/history.js b/client/modules/crm/src/views/record/row-actions/history.js index 9a94ca8f20..4c4e8fe3a7 100644 --- a/client/modules/crm/src/views/record/row-actions/history.js +++ b/client/modules/crm/src/views/record/row-actions/history.js @@ -37,7 +37,7 @@ define('crm:views/record/row-actions/history', ['views/record/row-actions/relati data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id + link: '#' + this.model.entityType + '/view/' + this.model.id }]; if (this.model.entityType === 'Email') { @@ -58,7 +58,7 @@ define('crm:views/record/row-actions/history', ['views/record/row-actions/relati data: { id: this.model.id }, - link: '#' + this.model.name + '/edit/' + this.model.id + link: '#' + this.model.entityType + '/edit/' + this.model.id } ]); } diff --git a/client/modules/crm/src/views/record/row-actions/tasks.js b/client/modules/crm/src/views/record/row-actions/tasks.js index c2a12d2ea4..4918bdc7ae 100644 --- a/client/modules/crm/src/views/record/row-actions/tasks.js +++ b/client/modules/crm/src/views/record/row-actions/tasks.js @@ -37,7 +37,7 @@ define('crm:views/record/row-actions/tasks', ['views/record/row-actions/relation data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id + link: '#' + this.model.entityType + '/view/' + this.model.id }]; if (this.options.acl.edit) { @@ -47,7 +47,7 @@ define('crm:views/record/row-actions/tasks', ['views/record/row-actions/relation data: { id: this.model.id }, - link: '#' + this.model.name + '/edit/' + this.model.id + link: '#' + this.model.entityType + '/edit/' + this.model.id }); if (!~['Completed', 'Canceled'].indexOf(this.model.get('status'))) { diff --git a/client/modules/crm/src/views/target-list/record/panels/opted-out.js b/client/modules/crm/src/views/target-list/record/panels/opted-out.js index d03f134d2c..7dfa73c7ab 100644 --- a/client/modules/crm/src/views/target-list/record/panels/opted-out.js +++ b/client/modules/crm/src/views/target-list/record/panels/opted-out.js @@ -45,7 +45,7 @@ function (Dep, MultiCollection) { }, getStorageKey: function () { - return 'target-list-opted-out-' + this.model.name + '-' + this.name; + return 'target-list-opted-out-' + this.model.entityType + '-' + this.name; }, setup: function () { diff --git a/client/modules/crm/src/views/target-list/record/row-actions/default.js b/client/modules/crm/src/views/target-list/record/row-actions/default.js index 2d7df24da8..3141d8af9c 100644 --- a/client/modules/crm/src/views/target-list/record/row-actions/default.js +++ b/client/modules/crm/src/views/target-list/record/row-actions/default.js @@ -40,7 +40,7 @@ define('crm:views/target-list/record/row-actions/default', ['views/record/row-ac label: 'Cancel Opt-Out', data: { id: this.model.id, - type: this.model.name, + type: this.model.entityType, }, }); } else { @@ -49,7 +49,7 @@ define('crm:views/target-list/record/row-actions/default', ['views/record/row-ac label: 'Opt-Out', data: { id: this.model.id, - type: this.model.name, + type: this.model.entityType, }, }); } diff --git a/client/modules/crm/src/views/target-list/record/row-actions/opted-out.js b/client/modules/crm/src/views/target-list/record/row-actions/opted-out.js index 70b7aeab24..2265e8ebb1 100644 --- a/client/modules/crm/src/views/target-list/record/row-actions/opted-out.js +++ b/client/modules/crm/src/views/target-list/record/row-actions/opted-out.js @@ -37,7 +37,7 @@ define('crm:views/target-list/record/row-actions/opted-out', ['views/record/row- label: 'Cancel Opt-Out', data: { id: this.model.id, - type: this.model.name + type: this.model.entityType, }, }, ]; diff --git a/client/modules/crm/src/views/task/record/row-actions/dashlet.js b/client/modules/crm/src/views/task/record/row-actions/dashlet.js index a7cb4d3e51..d3c21312f6 100644 --- a/client/modules/crm/src/views/task/record/row-actions/dashlet.js +++ b/client/modules/crm/src/views/task/record/row-actions/dashlet.js @@ -49,7 +49,7 @@ define('crm:views/task/record/row-actions/dashlet', ['views/record/row-actions/v label: 'Remove', data: { id: this.model.id, - scope: this.model.name + scope: this.model.entityType } }); } diff --git a/client/modules/crm/src/views/task/record/row-actions/default.js b/client/modules/crm/src/views/task/record/row-actions/default.js index 75bbfcddb8..69d7640075 100644 --- a/client/modules/crm/src/views/task/record/row-actions/default.js +++ b/client/modules/crm/src/views/task/record/row-actions/default.js @@ -49,7 +49,7 @@ define('crm:views/task/record/row-actions/default', ['views/record/row-actions/v label: 'Remove', data: { id: this.model.id, - scope: this.model.name + scope: this.model.entityType } }); } diff --git a/client/res/templates/event/fields/name-for-history/list-link.tpl b/client/res/templates/event/fields/name-for-history/list-link.tpl index d5f309571b..b69346fc42 100644 --- a/client/res/templates/event/fields/name-for-history/list-link.tpl +++ b/client/res/templates/event/fields/name-for-history/list-link.tpl @@ -1,5 +1,5 @@   - {{name}} diff --git a/client/res/templates/record/panels/side.tpl b/client/res/templates/record/panels/side.tpl index 21b3714bd6..ccf0a1ff79 100644 --- a/client/res/templates/record/panels/side.tpl +++ b/client/res/templates/record/panels/side.tpl @@ -9,7 +9,7 @@ > {{#if labelText}}{{labelText}}{{else}}{{translate label scope=../model.name category='fields'}}{{/if}} + >{{#if labelText}}{{labelText}}{{else}}{{translate label scope=../model.entityType category='fields'}}{{/if}} {{/unless}}
diff --git a/client/src/acl-manager.js b/client/src/acl-manager.js index b12925af34..050e54eb5b 100644 --- a/client/src/acl-manager.js +++ b/client/src/acl-manager.js @@ -223,7 +223,7 @@ class AclManager { * @returns {boolean|null} True if access allowed, null if not enough data to determine. */ checkModel(model, action, precise) { - var scope = model.name; + let scope = model.entityType; // todo move this to custom acl if (action === 'edit') { @@ -281,7 +281,7 @@ class AclManager { * @returns {boolean|null} True if owner, null if not clear. */ checkIsOwner(model) { - return this.getImplementation(model.name).checkIsOwner(model); + return this.getImplementation(model.entityType).checkIsOwner(model); } // noinspection JSUnusedGlobalSymbols @@ -292,7 +292,7 @@ class AclManager { * @returns {boolean|null} True if in a team, null if not clear. */ checkInTeam(model) { - return this.getImplementation(model.name).checkInTeam(model); + return this.getImplementation(model.entityType).checkInTeam(model); } /** diff --git a/client/src/acl-portal-manager.js b/client/src/acl-portal-manager.js index 0507d95ff5..ba3f618af2 100644 --- a/client/src/acl-portal-manager.js +++ b/client/src/acl-portal-manager.js @@ -46,7 +46,7 @@ class AclPortalManager extends AclManager { checkInAccount(model) { const impl = /** @type {module:acl-portal} */ - this.getImplementation(model.name); + this.getImplementation(model.entityType); return impl.checkInAccount(model); } @@ -61,7 +61,7 @@ class AclPortalManager extends AclManager { checkIsOwnContact(model) { const impl = /** @type {module:acl-portal} */ - this.getImplementation(model.name); + this.getImplementation(model.entityType); return impl.checkIsOwnContact(model); } diff --git a/client/src/helpers/model/defaults-populator.js b/client/src/helpers/model/defaults-populator.js index a7dfc307b4..9859e93c64 100644 --- a/client/src/helpers/model/defaults-populator.js +++ b/client/src/helpers/model/defaults-populator.js @@ -106,7 +106,7 @@ class DefaultsPopulator { fillAssignedUser = true; } else if ( - this.acl.getScopeForbiddenFieldList(model.name, 'edit').includes(assignedUserField) + this.acl.getScopeForbiddenFieldList(model.entityType, 'edit').includes(assignedUserField) ) { fillAssignedUser = true; } diff --git a/client/src/model.js b/client/src/model.js index 30e71bdf78..56bede9dec 100644 --- a/client/src/model.js +++ b/client/src/model.js @@ -781,7 +781,7 @@ class Model { setRelate(data) { let setRelate = options => { let link = options.link; - let model = options.model; + let model = /** @type {module:model} */options.model; if (!link || !model) { throw new Error('Bad related options'); @@ -792,7 +792,7 @@ class Model { switch (type) { case 'belongsToParent': this.set(link + 'Id', model.id); - this.set(link + 'Type', model.name); + this.set(link + 'Type', model.entityType); this.set(link + 'Name', model.get('name')); break; diff --git a/client/src/views/detail.js b/client/src/views/detail.js index 9de2eb486c..208f54804e 100644 --- a/client/src/views/detail.js +++ b/client/src/views/detail.js @@ -86,10 +86,19 @@ class DetailView extends MainView { /** @inheritDoc */ shortcutKeys = {} + /** + * An entity type. + * + * @type {string} + */ + entityType + /** @inheritDoc */ setup() { super.setup(); + this.entityType = this.model.entityType || this.model.name; + this.headerView = this.options.headerView || this.headerView; this.recordView = this.options.recordView || this.recordView; @@ -274,7 +283,7 @@ class DetailView extends MainView { this.disableMenuItem('follow'); Espo.Ajax - .putRequest(this.model.name + '/' + this.model.id + '/subscription') + .putRequest(this.entityType + '/' + this.model.id + '/subscription') .then(() => { this.hideHeaderActionItem('follow'); @@ -295,7 +304,7 @@ class DetailView extends MainView { this.disableMenuItem('unfollow'); Espo.Ajax - .deleteRequest(this.model.name + '/' + this.model.id + '/subscription') + .deleteRequest(this.entityType + '/' + this.model.id + '/subscription') .then(() => { this.hideHeaderActionItem('unfollow'); diff --git a/client/src/views/email/record/detail.js b/client/src/views/email/record/detail.js index 9ab4af4e41..33d3d641e7 100644 --- a/client/src/views/email/record/detail.js +++ b/client/src/views/email/record/detail.js @@ -423,7 +423,7 @@ define('views/email/record/detail', ['views/record/detail'], function (Dep) { actionViewUsers: function (data) { var viewName = this.getMetadata() - .get(['clientDefs', this.model.name, 'relationshipPanels', 'users', 'viewModalView']) || + .get(['clientDefs', this.model.entityType, 'relationshipPanels', 'users', 'viewModalView']) || this.getMetadata().get(['clientDefs', 'User', 'modalViews', 'relatedList']) || 'views/modals/related-list'; diff --git a/client/src/views/external-account/oauth2.js b/client/src/views/external-account/oauth2.js index 5a5351b50a..ca3dcde8e8 100644 --- a/client/src/views/external-account/oauth2.js +++ b/client/src/views/external-account/oauth2.js @@ -70,7 +70,7 @@ define('views/external-account/oauth2', ['view', 'model'], function (Dep, Model) this.model = new Model(); this.model.id = this.id; - this.model.name = 'ExternalAccount'; + this.model.entityType = this.model.name = 'ExternalAccount'; this.model.urlRoot = 'ExternalAccount'; this.model.defs = { diff --git a/client/src/views/fields/address.js b/client/src/views/fields/address.js index 9a92876927..39cb484fb1 100644 --- a/client/src/views/fields/address.js +++ b/client/src/views/fields/address.js @@ -578,7 +578,7 @@ class AddressFieldView extends BaseFieldView { this[item + 'Field'] = attribute; this[item + 'MaxLength'] = - this.getMetadata().get(['entityDefs', this.model.name, 'fields', attribute, 'maxLength']); + this.getMetadata().get(['entityDefs', this.entityType, 'fields', attribute, 'maxLength']); }); } @@ -587,7 +587,7 @@ class AddressFieldView extends BaseFieldView { if (this.model.isRequired(name)) { if (this.model.get(name) === '') { let msg = this.translate('fieldIsRequired', 'messages') - .replace('{field}', this.translate(name, 'fields', this.model.name)); + .replace('{field}', this.translate(name, 'fields', this.entityType)); this.showValidationMessage(msg, '[data-name="'+name+'"]'); diff --git a/client/src/views/fields/attachment-multiple.js b/client/src/views/fields/attachment-multiple.js index b3bcd5e9d4..082c924bac 100644 --- a/client/src/views/fields/attachment-multiple.js +++ b/client/src/views/fields/attachment-multiple.js @@ -535,7 +535,7 @@ class AttachmentMultipleFieldView extends BaseFieldView { let attachment = model.clone(); attachment.set('role', 'Attachment'); - attachment.set('parentType', this.model.name); + attachment.set('parentType', this.model.entityType); attachment.set('field', this.name); uploadHelper @@ -839,7 +839,7 @@ class AttachmentMultipleFieldView extends BaseFieldView { } modelList.forEach(model => { - if (model.name === 'Attachment') { + if (model.entityType === 'Attachment') { this.pushAttachment(model); return; diff --git a/client/src/views/fields/base.js b/client/src/views/fields/base.js index 137d5fb41e..32e11b8263 100644 --- a/client/src/views/fields/base.js +++ b/client/src/views/fields/base.js @@ -455,7 +455,7 @@ class BaseFieldView extends View { /** @inheritDoc */ data() { let data = { - scope: this.model.name, + scope: this.model.entityType || this.model.name, name: this.name, defs: this.defs, params: this.params, diff --git a/client/src/views/fields/date.js b/client/src/views/fields/date.js index f1e8462c43..1ea928ae5d 100644 --- a/client/src/views/fields/date.js +++ b/client/src/views/fields/date.js @@ -441,7 +441,7 @@ class DateFieldView extends BaseFieldView { if (moment(value).unix() <= moment(otherValue).unix()) { let msg = this.translate('fieldShouldAfter', 'messages') .replace('{field}', this.getLabelText()) - .replace('{otherField}', this.translate(field, 'fields', this.model.name)); + .replace('{otherField}', this.translate(field, 'fields', this.model.entityType)); this.showValidationMessage(msg); diff --git a/client/src/views/fields/email.js b/client/src/views/fields/email.js index 29ef6ec578..6010dd1be6 100644 --- a/client/src/views/fields/email.js +++ b/client/src/views/fields/email.js @@ -221,7 +221,7 @@ class EmailFieldView extends VarcharFieldView { let optOut; if (this.model.isNew()) { - optOut = this.emailAddressOptedOutByDefault && this.model.name !== 'User'; + optOut = this.emailAddressOptedOutByDefault && this.model.entityType !== 'User'; } else { optOut = this.model.get(this.isOptedOutFieldName) } @@ -436,7 +436,7 @@ class EmailFieldView extends VarcharFieldView { to: emailAddress }; - let scope = this.model.name; + let scope = this.model.entityType; switch (scope) { case 'Account': @@ -469,8 +469,8 @@ class EmailFieldView extends VarcharFieldView { } if (!attributes.parentId) { - if (this.checkParentTypeAvailability(this.model.name)) { - attributes.parentType = this.model.name; + if (this.checkParentTypeAvailability(this.model.entityType)) { + attributes.parentType = this.model.entityType; attributes.parentId = this.model.id; attributes.parentName = this.model.get('name'); } @@ -483,7 +483,7 @@ class EmailFieldView extends VarcharFieldView { } - if (~['Contact', 'Lead', 'Account'].indexOf(this.model.name)) { + if (~['Contact', 'Lead', 'Account'].indexOf(this.model.entityType)) { attributes.nameHash = {}; attributes.nameHash[emailAddress] = this.model.get('name'); } diff --git a/client/src/views/fields/file.js b/client/src/views/fields/file.js index 20aac26bd2..7dcaea9ce9 100644 --- a/client/src/views/fields/file.js +++ b/client/src/views/fields/file.js @@ -565,7 +565,7 @@ class FileFieldView extends LinkFieldView { }); attachment.set('role', 'Attachment'); - attachment.set('relatedType', this.model.name); + attachment.set('relatedType', this.model.entityType); attachment.set('field', this.name); this.handleUploadingFile(file).then(file => { @@ -771,7 +771,7 @@ class FileFieldView extends LinkFieldView { } modelList.forEach(model => { - if (model.name === 'Attachment') { + if (model.entityType === 'Attachment') { this.setAttachment(model); return; diff --git a/client/src/views/fields/followers.js b/client/src/views/fields/followers.js index d769f05ecb..ab50120538 100644 --- a/client/src/views/fields/followers.js +++ b/client/src/views/fields/followers.js @@ -80,7 +80,7 @@ define('views/fields/followers', ['views/fields/link-multiple'], function (Dep) reloadFollowers: function () { this.getCollectionFactory().create('User', (collection) => { - collection.url = this.model.name + '/' + this.model.id + '/followers'; + collection.url = this.model.entityType + '/' + this.model.id + '/followers'; collection.offset = 0; collection.maxSize = this.limit; @@ -105,7 +105,7 @@ define('views/fields/followers', ['views/fields/link-multiple'], function (Dep) showMoreFollowers: function () { this.getCollectionFactory().create('User', (collection) => { - collection.url = this.model.name + '/' + this.model.id + '/followers'; + collection.url = this.model.entityType + '/' + this.model.id + '/followers'; collection.offset = this.ids.length || 0; collection.maxSize = this.portionSize; collection.data.select = ['id', 'name'].join(','); diff --git a/client/src/views/fields/foreign-array.js b/client/src/views/fields/foreign-array.js index 6267963a71..d7d689de22 100644 --- a/client/src/views/fields/foreign-array.js +++ b/client/src/views/fields/foreign-array.js @@ -42,7 +42,7 @@ define('views/fields/foreign-array', ['views/fields/array'], function (Dep) { return; } - let scope = this.getMetadata().get(['entityDefs', this.model.name, 'links', link, 'entity']); + let scope = this.getMetadata().get(['entityDefs', this.model.entityType, 'links', link, 'entity']); if (!scope) { return; diff --git a/client/src/views/fields/foreign-checklist.js b/client/src/views/fields/foreign-checklist.js index 9a14ed24d1..9fb08649cd 100644 --- a/client/src/views/fields/foreign-checklist.js +++ b/client/src/views/fields/foreign-checklist.js @@ -40,7 +40,7 @@ define('views/fields/foreign-checklist', ['views/fields/checklist'], function (D } var scope = this.getMetadata() - .get(['entityDefs', this.model.name, 'links', this.params.link, 'entity']); + .get(['entityDefs', this.model.entityType, 'links', this.params.link, 'entity']); if (!scope) { return; diff --git a/client/src/views/fields/foreign-enum.js b/client/src/views/fields/foreign-enum.js index c7bb6792de..da96d2132f 100644 --- a/client/src/views/fields/foreign-enum.js +++ b/client/src/views/fields/foreign-enum.js @@ -42,7 +42,7 @@ define('views/fields/foreign-enum', ['views/fields/enum'], function (Dep) { return; } - let scope = this.getMetadata().get(['entityDefs', this.model.name, 'links', link, 'entity']); + let scope = this.getMetadata().get(['entityDefs', this.model.entityType, 'links', link, 'entity']); if (!scope) { return; diff --git a/client/src/views/fields/link-multiple-with-columns.js b/client/src/views/fields/link-multiple-with-columns.js index 51074b88b1..1e0e833ceb 100644 --- a/client/src/views/fields/link-multiple-with-columns.js +++ b/client/src/views/fields/link-multiple-with-columns.js @@ -77,7 +77,7 @@ function (Dep, RegExpPattern, /** module:ui/select*/Select) { }); let columns = this.getMetadata() - .get(['entityDefs', this.model.name, 'fields', this.name, 'columns']) || {}; + .get(['entityDefs', this.model.entityType, 'fields', this.name, 'columns']) || {}; /** @type {string[]} */ this.columnList = this.columnList || Object.keys(columns); @@ -99,9 +99,9 @@ function (Dep, RegExpPattern, /** module:ui/select*/Select) { if ( !this.getMetadata().get(['entityDefs', this.foreignScope, 'fields', field, 'type']) && - this.getMetadata().get(['entityDefs', this.model.name, 'fields', field, 'type']) + this.getMetadata().get(['entityDefs', this.model.entityType, 'fields', field, 'type']) ) { - o.scope = this.model.name; + o.scope = this.model.entityType; } let fieldDefs = this.getMetadata().get(['entityDefs', o.scope, 'fields', field]) || {}; diff --git a/client/src/views/fields/link-multiple-with-role.js b/client/src/views/fields/link-multiple-with-role.js index 02fcd47cfd..debdbb482a 100644 --- a/client/src/views/fields/link-multiple-with-role.js +++ b/client/src/views/fields/link-multiple-with-role.js @@ -95,12 +95,12 @@ function (Dep, /** module:ui/select*/Select) { }); this.roleField = this.getMetadata() - .get(['entityDefs', this.model.name, 'fields', this.name, 'columns', this.columnName]); + .get(['entityDefs', this.model.entityType, 'fields', this.name, 'columns', this.columnName]); this.displayRoleAsLabel = this.getMetadata() .get(['entityDefs', this.model.entityType, 'fields', this.roleField, 'displayAsLabel']); - this.roleFieldScope = this.roleFieldIsForeign ? this.foreignScope : this.model.name; + this.roleFieldScope = this.roleFieldIsForeign ? this.foreignScope : this.model.entityType; if (this.roleType === this.ROLE_TYPE_ENUM && !this.forceRoles) { this.roleList = this.getMetadata() diff --git a/client/src/views/fields/person-name.js b/client/src/views/fields/person-name.js index 3aecd572c7..fc04b40c13 100644 --- a/client/src/views/fields/person-name.js +++ b/client/src/views/fields/person-name.js @@ -175,7 +175,7 @@ class PersonNameFieldView extends VarcharFieldView { if (this.model.isRequired(name)) { if (!this.model.get(name)) { let msg = this.translate('fieldIsRequired', 'messages') - .replace('{field}', this.translate(name, 'fields', this.model.name)); + .replace('{field}', this.translate(name, 'fields', this.model.entityType)); this.showValidationMessage(msg, '[data-name="'+name+'"]'); return true; diff --git a/client/src/views/fields/phone.js b/client/src/views/fields/phone.js index 886c945795..04a79f3f50 100644 --- a/client/src/views/fields/phone.js +++ b/client/src/views/fields/phone.js @@ -216,7 +216,7 @@ class PhoneFieldView extends VarcharFieldView { let optOut; if (this.model.isNew()) { - optOut = this.phoneNumberOptedOutByDefault && this.model.name !== 'User'; + optOut = this.phoneNumberOptedOutByDefault && this.model.entityType !== 'User'; } else { optOut = this.model.get(this.isOptedOutFieldName) } @@ -411,7 +411,7 @@ class PhoneFieldView extends VarcharFieldView { this.dataFieldName = this.name + 'Data'; this.defaultType = this.defaultType || this.getMetadata() - .get('entityDefs.' + this.model.name + '.fields.' + this.name + '.defaultType'); + .get('entityDefs.' + this.model.entityType + '.fields.' + this.name + '.defaultType'); this.isOptedOutFieldName = this.name + 'IsOptedOut'; this.isInvalidFieldName = this.name + 'IsInvalid'; diff --git a/client/src/views/fields/wysiwyg.js b/client/src/views/fields/wysiwyg.js index ecf361d4fc..c74cb2ed6d 100644 --- a/client/src/views/fields/wysiwyg.js +++ b/client/src/views/fields/wysiwyg.js @@ -642,7 +642,7 @@ class WysiwygFieldView extends TextFieldView { attachment.set('relatedId', this.model.id); } - attachment.set('relatedType', this.model.name); + attachment.set('relatedType', this.model.entityType); attachment.set('file', e.target.result); attachment.set('field', this.name); diff --git a/client/src/views/import/detail.js b/client/src/views/import/detail.js index 8480a66613..4e695ac7bc 100644 --- a/client/src/views/import/detail.js +++ b/client/src/views/import/detail.js @@ -35,8 +35,8 @@ define('views/import/detail', ['views/detail'], function (Dep) { return this.buildHeaderHtml([ $('') - .attr('href', '#' + this.model.name + '/list') - .text(this.getLanguage().translate(this.model.name, 'scopeNamesPlural')), + .attr('href', '#' + this.model.entityType + '/list') + .text(this.getLanguage().translate(this.model.entityType, 'scopeNamesPlural')), $('') .text(name) ]); diff --git a/client/src/views/import/record/row-actions/duplicates.js b/client/src/views/import/record/row-actions/duplicates.js index 238d9c15fe..23d3e1d5c3 100644 --- a/client/src/views/import/record/row-actions/duplicates.js +++ b/client/src/views/import/record/row-actions/duplicates.js @@ -38,7 +38,7 @@ define('views/import/record/row-actions/duplicates', ['views/record/row-actions/ label: 'Set as Not Duplicate', data: { id: this.model.id, - type: this.model.name, + type: this.model.entityType, }, }); diff --git a/client/src/views/merge.js b/client/src/views/merge.js index eb96ea71b3..8a7f4e5816 100644 --- a/client/src/views/merge.js +++ b/client/src/views/merge.js @@ -63,7 +63,7 @@ class MergeView extends MainView { return this.buildHeaderHtml([ $('') .attr('href', '#' + this.models[0].entityType) - .text(this.getLanguage().translate(this.models[0].name, 'scopeNamesPlural')), + .text(this.getLanguage().translate(this.models[0].entityType, 'scopeNamesPlural')), $('') .text(this.getLanguage().translate('Merge')) ]); diff --git a/client/src/views/modals/compose-email.js b/client/src/views/modals/compose-email.js index c79eb3ab59..4728a832ef 100644 --- a/client/src/views/modals/compose-email.js +++ b/client/src/views/modals/compose-email.js @@ -141,7 +141,7 @@ class ComposeEmailModalView extends EditModalView { } createRecordView(model, callback) { - let viewName = this.getMetadata().get('clientDefs.' + model.name + '.recordViews.compose') || + let viewName = this.getMetadata().get('clientDefs.' + model.entityType + '.recordViews.compose') || 'views/email/record/compose'; let options = { diff --git a/client/src/views/modals/detail.js b/client/src/views/modals/detail.js index d195e24bea..37405fce3f 100644 --- a/client/src/views/modals/detail.js +++ b/client/src/views/modals/detail.js @@ -379,8 +379,8 @@ class DetailModalView extends ModalView { let viewName = this.detailViewName || this.detailView || - this.getMetadata().get(['clientDefs', model.name, 'recordViews', 'detailSmall']) || - this.getMetadata().get(['clientDefs', model.name, 'recordViews', 'detailQuick']) || + this.getMetadata().get(['clientDefs', model.entityType, 'recordViews', 'detailSmall']) || + this.getMetadata().get(['clientDefs', model.entityType, 'recordViews', 'detailQuick']) || 'views/record/detail-small'; let options = { @@ -475,7 +475,7 @@ class DetailModalView extends ModalView { this.indexOfRecord = indexOfRecord; this.id = this.sourceModel.id; - this.scope = this.sourceModel.name; + this.scope = this.sourceModel.entityType; this.model = this.sourceModel.clone(); this.model.collection = this.sourceModel.collection.clone(); diff --git a/client/src/views/modals/edit.js b/client/src/views/modals/edit.js index d9a9edebc5..0511381e41 100644 --- a/client/src/views/modals/edit.js +++ b/client/src/views/modals/edit.js @@ -193,8 +193,8 @@ class EditModalView extends ModalView { createRecordView(model, callback) { let viewName = this.editView || - this.getMetadata().get(['clientDefs', model.name, 'recordViews', 'editSmall']) || - this.getMetadata().get(['clientDefs', model.name, 'recordViews', 'editQuick']) || + this.getMetadata().get(['clientDefs', model.entityType, 'recordViews', 'editSmall']) || + this.getMetadata().get(['clientDefs', model.entityType, 'recordViews', 'editQuick']) || 'views/record/edit-small'; let options = { diff --git a/client/src/views/modals/kanban-move-over.js b/client/src/views/modals/kanban-move-over.js index ecb502ea5b..f772f2115d 100644 --- a/client/src/views/modals/kanban-move-over.js +++ b/client/src/views/modals/kanban-move-over.js @@ -51,7 +51,7 @@ class KanbanMoveOverModalView extends ModalView { } setup() { - this.scope = this.model.name; + this.scope = this.model.entityType; let iconHtml = this.getHelper().getScopeColorIconHtml(this.scope); diff --git a/client/src/views/personal-data/modals/personal-data.js b/client/src/views/personal-data/modals/personal-data.js index 7337ed36a9..05f608749e 100644 --- a/client/src/views/personal-data/modals/personal-data.js +++ b/client/src/views/personal-data/modals/personal-data.js @@ -60,7 +60,7 @@ define('views/personal-data/modals/personal-data', ['views/modal'], function (De this.fieldList = []; - this.scope = this.model.name; + this.scope = this.model.entityType; this.createView('record', 'views/personal-data/record/record', { selector: '.record', diff --git a/client/src/views/personal-data/record/record.js b/client/src/views/personal-data/record/record.js index fa013670a7..c2ca9fa6f3 100644 --- a/client/src/views/personal-data/record/record.js +++ b/client/src/views/personal-data/record/record.js @@ -92,7 +92,7 @@ define('views/personal-data/record/record', ['views/record/base'], function (Dep ...this.events, }; - this.scope = this.model.name; + this.scope = this.model.entityType; this.fieldList = []; this.checkedFieldList = []; diff --git a/client/src/views/record/base.js b/client/src/views/record/base.js index f90cdf4d76..da69c3df17 100644 --- a/client/src/views/record/base.js +++ b/client/src/views/record/base.js @@ -596,8 +596,6 @@ class BaseRecordView extends View { this.setIsNotChanged(); }); - this.events = this.events || {}; - this.entityType = this.model.entityType || this.model.name; this.scope = this.options.scope || this.entityType; diff --git a/client/src/views/record/detail-middle.js b/client/src/views/record/detail-middle.js index 230086eaf3..05904c576f 100644 --- a/client/src/views/record/detail-middle.js +++ b/client/src/views/record/detail-middle.js @@ -37,7 +37,7 @@ class DetailMiddleRecordView extends View { init() { this.recordHelper = this.options.recordHelper; - this.scope = this.model.name; + this.scope = this.model.entityType; } data() { diff --git a/client/src/views/record/detail-side.js b/client/src/views/record/detail-side.js index 18d2f43478..4523fa4c2b 100644 --- a/client/src/views/record/detail-side.js +++ b/client/src/views/record/detail-side.js @@ -77,7 +77,7 @@ class DetailSideRecordView extends PanelsContainerRecordView { init() { this.panelList = this.options.panelList || this.panelList; - this.scope = this.entityType = this.options.model.name; + this.scope = this.entityType = this.options.model.entityType; this.recordHelper = this.options.recordHelper; diff --git a/client/src/views/record/detail.js b/client/src/views/record/detail.js index 25181e1323..dfdd9c5fcf 100644 --- a/client/src/views/record/detail.js +++ b/client/src/views/record/detail.js @@ -1726,7 +1726,7 @@ class DetailRecordView extends BaseRecordView { } init() { - this.entityType = this.model.name; + this.entityType = this.model.entityType || this.model.name; this.scope = this.options.scope || this.entityType; this.layoutName = this.options.layoutName || this.layoutName; @@ -1973,7 +1973,7 @@ class DetailRecordView extends BaseRecordView { }); let dependencyDefs = Espo.Utils.clone( - this.getMetadata().get(['clientDefs', this.model.name, 'formDependency']) || {} + this.getMetadata().get(['clientDefs', this.entityType, 'formDependency']) || {} ); this.dependencyDefs = _.extend(dependencyDefs, this.dependencyDefs); @@ -1981,7 +1981,7 @@ class DetailRecordView extends BaseRecordView { this.initDependancy(); let dynamicLogic = Espo.Utils.clone( - this.getMetadata().get(['clientDefs', this.model.name, 'dynamicLogic']) || {} + this.getMetadata().get(['clientDefs', this.entityType, 'dynamicLogic']) || {} ); this.dynamicLogicDefs = _.extend(dynamicLogic, this.dynamicLogicDefs); @@ -2239,7 +2239,7 @@ class DetailRecordView extends BaseRecordView { } let id = model.id; - let scope = model.name || this.scope; + let scope = this.entityType || this.scope; let url; @@ -2353,7 +2353,7 @@ class DetailRecordView extends BaseRecordView { actionViewFollowers(data) { let viewName = this.getMetadata().get( - ['clientDefs', this.model.name, 'relationshipPanels', 'followers', 'viewModalView'] + ['clientDefs', this.entityType, 'relationshipPanels', 'followers', 'viewModalView'] ) || this.getMetadata().get(['clientDefs', 'User', 'modalViews', 'relatedList']) || 'views/modals/followers-list'; @@ -2369,7 +2369,7 @@ class DetailRecordView extends BaseRecordView { scope: 'User', title: this.translate('Followers'), filtersDisabled: true, - url: this.model.entityType + '/' + this.model.id + '/followers', + url: this.entityType + '/' + this.model.id + '/followers', createDisabled: true, selectDisabled: selectDisabled, rowActionsView: 'views/user/record/row-actions/relationship-followers', @@ -2414,7 +2414,7 @@ class DetailRecordView extends BaseRecordView { actionPrintPdf() { this.createView('pdfTemplate', 'views/modals/select-template', { - entityType: this.model.name, + entityType: this.entityType, }, (view) => { view.render(); @@ -2423,8 +2423,8 @@ class DetailRecordView extends BaseRecordView { window.open( '?entryPoint=pdf&entityType=' + - this.model.name+'&entityId=' + - this.model.id+'&templateId=' + model.id, '_blank' + this.entityType + '&entityId=' + + this.model.id + '&templateId=' + model.id, '_blank' ); }); }); @@ -3157,7 +3157,7 @@ class DetailRecordView extends BaseRecordView { return; } - this.getHelper().layoutManager.get(this.model.name, this.layoutName, detailLayout => { + this.getHelper().layoutManager.get(this.entityType, this.layoutName, detailLayout => { if (typeof this.modifyDetailLayout === 'function') { detailLayout = Espo.Utils.cloneDeep(detailLayout); diff --git a/client/src/views/record/list-tree-item.js b/client/src/views/record/list-tree-item.js index 1c1df0de6a..4a34b24b43 100644 --- a/client/src/views/record/list-tree-item.js +++ b/client/src/views/record/list-tree-item.js @@ -118,7 +118,7 @@ class ListTreeRecordItemView extends View { } this.rootView = this.options.rootView; - this.scope = this.model.name; + this.scope = this.model.entityType; this.isUnfolded = false; diff --git a/client/src/views/record/list.js b/client/src/views/record/list.js index c44b72249e..6de596aa97 100644 --- a/client/src/views/record/list.js +++ b/client/src/views/record/list.js @@ -2717,7 +2717,7 @@ class ListRecordView extends View { type: this._internalLayoutType, layout: internalLayout }, - name: this.type + '-' + model.name, + name: this.type + '-' + model.entityType, setViewBeforeCallback: this.options.skipBuildRows && !this.isRendered(), }, callback); }, model); @@ -2948,7 +2948,7 @@ class ListRecordView extends View { let scope = data.scope; if (!scope && model) { - scope = model.name; + scope = model.entityType; } if (!scope) { @@ -3009,7 +3009,7 @@ class ListRecordView extends View { let scope = data.scope; if (!scope && model) { - scope = model.name; + scope = model.entityType; } if (!scope) { diff --git a/client/src/views/record/panels/default-side.js b/client/src/views/record/panels/default-side.js index bc08a8b776..76141646ce 100644 --- a/client/src/views/record/panels/default-side.js +++ b/client/src/views/record/panels/default-side.js @@ -53,12 +53,12 @@ class DefaultSidePanelView extends SidePanelView { this.fieldList = Espo.Utils.cloneDeep(this.fieldList); this.hasComplexCreated = - !!this.getMetadata().get(['entityDefs', this.model.name, 'fields', 'createdAt']) && - !!this.getMetadata().get(['entityDefs', this.model.name, 'fields', 'createdBy']); + !!this.getMetadata().get(['entityDefs', this.model.entityType, 'fields', 'createdAt']) && + !!this.getMetadata().get(['entityDefs', this.model.entityType, 'fields', 'createdBy']); this.hasComplexModified = - !!this.getMetadata().get(['entityDefs', this.model.name, 'fields', 'modifiedAt']) && - !!this.getMetadata().get(['entityDefs', this.model.name, 'fields', 'modifiedBy']); + !!this.getMetadata().get(['entityDefs', this.model.entityType, 'fields', 'modifiedAt']) && + !!this.getMetadata().get(['entityDefs', this.model.entityType, 'fields', 'modifiedBy']); super.setup(); } @@ -124,7 +124,7 @@ class DefaultSidePanelView extends SidePanelView { }); } - if (this.getMetadata().get(['scopes', this.model.name ,'stream']) && !this.getUser().isPortal()) { + if (this.getMetadata().get(['scopes', this.model.entityType ,'stream']) && !this.getUser().isPortal()) { this.fieldList.push({ name: 'followers', labelText: this.translate('Followers'), diff --git a/client/src/views/record/panels/relationship.js b/client/src/views/record/panels/relationship.js index 66eaf258b3..99c9d06a3d 100644 --- a/client/src/views/record/panels/relationship.js +++ b/client/src/views/record/panels/relationship.js @@ -95,7 +95,7 @@ class RelationshipPanelView extends BottomPanelView { this.link = this.link || this.defs.link || this.panelName; if (!this.scope && !(this.link in this.model.defs.links)) { - throw new Error('Link \'' + this.link + '\' is not defined in model \'' + this.model.name + '\''); + throw new Error('Link \'' + this.link + '\' is not defined in model \'' + this.model.entityType + '\''); } this.scope = this.scope || this.model.defs.links[this.link].entity; @@ -103,7 +103,7 @@ class RelationshipPanelView extends BottomPanelView { let linkReadOnly = this.getMetadata() .get(['entityDefs', this.model.entityType, 'links', this.link, 'readOnly']) || false; - let url = this.url = this.url || this.model.name + '/' + this.model.id + '/' + this.link; + let url = this.url = this.url || this.model.entityType + '/' + this.model.id + '/' + this.link; if (!('create' in this.defs)) { this.defs.create = true; @@ -309,7 +309,7 @@ class RelationshipPanelView extends BottomPanelView { * @protected */ setupTitle() { - this.title = this.title || this.translate(this.link, 'links', this.model.name); + this.title = this.title || this.translate(this.link, 'links', this.model.entityType); var iconHtml = ''; @@ -427,7 +427,7 @@ class RelationshipPanelView extends BottomPanelView { * @private */ getStoredFilter() { - var key = 'panelFilter' + this.model.name + '-' + (this.panelName || this.name); + var key = 'panelFilter' + this.model.entityType + '-' + (this.panelName || this.name); return this.getStorage().get('state', key) || null; } @@ -436,7 +436,7 @@ class RelationshipPanelView extends BottomPanelView { * @private */ storeFilter(filter) { - var key = 'panelFilter' + this.model.name + '-' + (this.panelName || this.name); + var key = 'panelFilter' + this.model.entityType + '-' + (this.panelName || this.name); if (filter) { this.getStorage().set('state', key, filter); @@ -529,7 +529,7 @@ class RelationshipPanelView extends BottomPanelView { actionViewRelatedList(data) { var viewName = this.getMetadata().get( - ['clientDefs', this.model.name, 'relationshipPanels', this.name, 'viewModalView'] + ['clientDefs', this.model.entityType, 'relationshipPanels', this.name, 'viewModalView'] ) || this.getMetadata().get(['clientDefs', this.scope, 'modalViews', 'relatedList']) || this.viewModalView || @@ -741,7 +741,7 @@ class RelationshipPanelView extends BottomPanelView { Espo.Ui.notify(' ... '); Espo.Ajax - .postRequest(this.model.name + '/action/unlinkAll', { + .postRequest(this.model.entityType + '/action/unlinkAll', { link: data.link, id: this.model.id, }) diff --git a/client/src/views/record/row-actions/default-kanban.js b/client/src/views/record/row-actions/default-kanban.js index a0ef4fde1d..67f2bf1caf 100644 --- a/client/src/views/record/row-actions/default-kanban.js +++ b/client/src/views/record/row-actions/default-kanban.js @@ -37,7 +37,7 @@ define('views/record/row-actions/default-kanban', ['views/record/row-actions/def data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id + link: '#' + this.model.entityType + '/view/' + this.model.id }]; if (this.options.statusFieldIsEditable) { @@ -57,7 +57,7 @@ define('views/record/row-actions/default-kanban', ['views/record/row-actions/def data: { id: this.model.id }, - link: '#' + this.model.name + '/edit/' + this.model.id + link: '#' + this.model.entityType + '/edit/' + this.model.id }); } diff --git a/client/src/views/record/row-actions/default.js b/client/src/views/record/row-actions/default.js index 63f5a4fae1..6af3267e0e 100644 --- a/client/src/views/record/row-actions/default.js +++ b/client/src/views/record/row-actions/default.js @@ -75,7 +75,7 @@ class DefaultRowActionsView extends View { data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id, + link: '#' + this.model.entityType + '/view/' + this.model.id, }]; if (this.options.acl.edit) { @@ -85,7 +85,7 @@ class DefaultRowActionsView extends View { data: { id: this.model.id }, - link: '#' + this.model.name + '/edit/' + this.model.id, + link: '#' + this.model.entityType + '/edit/' + this.model.id, }); } @@ -106,7 +106,7 @@ class DefaultRowActionsView extends View { return { acl: this.options.acl, actionList: this.getActionList(), - scope: this.model.name, + scope: this.model.entityType, }; } } diff --git a/client/src/views/record/row-actions/edit-and-remove.js b/client/src/views/record/row-actions/edit-and-remove.js index 9cb5566080..ad149490d1 100644 --- a/client/src/views/record/row-actions/edit-and-remove.js +++ b/client/src/views/record/row-actions/edit-and-remove.js @@ -40,7 +40,7 @@ define('views/record/row-actions/edit-and-remove', ['views/record/row-actions/de data: { id: this.model.id }, - link: '#' + this.model.name + '/edit/' + this.model.id + link: '#' + this.model.entityType + '/edit/' + this.model.id }); } diff --git a/client/src/views/record/row-actions/relationship-no-remove.js b/client/src/views/record/row-actions/relationship-no-remove.js index a351e8478a..c20637f4af 100644 --- a/client/src/views/record/row-actions/relationship-no-remove.js +++ b/client/src/views/record/row-actions/relationship-no-remove.js @@ -37,7 +37,7 @@ define('views/record/row-actions/relationship-no-remove', ['views/record/row-act data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id + link: '#' + this.model.entityType + '/view/' + this.model.id }]; if (this.options.acl.edit) { @@ -47,7 +47,7 @@ define('views/record/row-actions/relationship-no-remove', ['views/record/row-act data: { id: this.model.id }, - link: '#' + this.model.name + '/edit/' + this.model.id + link: '#' + this.model.entityType + '/edit/' + this.model.id }); if (!this.options.unlinkDisabled) { list.push({ diff --git a/client/src/views/record/row-actions/relationship-no-unlink.js b/client/src/views/record/row-actions/relationship-no-unlink.js index 10d98ace6c..86f3e87bde 100644 --- a/client/src/views/record/row-actions/relationship-no-unlink.js +++ b/client/src/views/record/row-actions/relationship-no-unlink.js @@ -37,7 +37,7 @@ define('views/record/row-actions/relationship-no-unlink', ['views/record/row-act data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id + link: '#' + this.model.entityType + '/view/' + this.model.id }]; if (this.options.acl.edit) { @@ -48,7 +48,7 @@ define('views/record/row-actions/relationship-no-unlink', ['views/record/row-act data: { id: this.model.id }, - link: '#' + this.model.name + '/edit/' + this.model.id + link: '#' + this.model.entityType + '/edit/' + this.model.id } ]); } @@ -65,6 +65,5 @@ define('views/record/row-actions/relationship-no-unlink', ['views/record/row-act return list; }, - }); }); diff --git a/client/src/views/record/row-actions/relationship-view-and-edit.js b/client/src/views/record/row-actions/relationship-view-and-edit.js index afc304298a..6310c904cd 100644 --- a/client/src/views/record/row-actions/relationship-view-and-edit.js +++ b/client/src/views/record/row-actions/relationship-view-and-edit.js @@ -37,7 +37,7 @@ define('views/record/row-actions/relationship-view-and-edit', ['views/record/row data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id + link: '#' + this.model.entityType + '/view/' + this.model.id }]; if (this.options.acl.edit) { @@ -47,7 +47,7 @@ define('views/record/row-actions/relationship-view-and-edit', ['views/record/row data: { id: this.model.id }, - link: '#' + this.model.name + '/edit/' + this.model.id + link: '#' + this.model.entityType + '/edit/' + this.model.id }); } diff --git a/client/src/views/record/row-actions/relationship-view-and-unlink.js b/client/src/views/record/row-actions/relationship-view-and-unlink.js index bfb6c8008a..ae0cc482a1 100644 --- a/client/src/views/record/row-actions/relationship-view-and-unlink.js +++ b/client/src/views/record/row-actions/relationship-view-and-unlink.js @@ -37,7 +37,7 @@ define('views/record/row-actions/relationship-view-and-unlink', ['views/record/r data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id + link: '#' + this.model.entityType + '/view/' + this.model.id }]; if (this.options.acl.edit && !this.options.unlinkDisabled) { diff --git a/client/src/views/record/row-actions/relationship-view-only.js b/client/src/views/record/row-actions/relationship-view-only.js index a84585ce94..880a941bcc 100644 --- a/client/src/views/record/row-actions/relationship-view-only.js +++ b/client/src/views/record/row-actions/relationship-view-only.js @@ -38,7 +38,7 @@ define('views/record/row-actions/relationship-view-only', ['views/record/row-act data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id, + link: '#' + this.model.entityType + '/view/' + this.model.id, } ]; }, diff --git a/client/src/views/record/row-actions/relationship.js b/client/src/views/record/row-actions/relationship.js index dac1480d24..122ba7a806 100644 --- a/client/src/views/record/row-actions/relationship.js +++ b/client/src/views/record/row-actions/relationship.js @@ -37,7 +37,7 @@ define('views/record/row-actions/relationship', ['views/record/row-actions/defau data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id + link: '#' + this.model.entityType + '/view/' + this.model.id }]; if (this.options.acl.edit) { @@ -47,7 +47,7 @@ define('views/record/row-actions/relationship', ['views/record/row-actions/defau data: { id: this.model.id }, - link: '#' + this.model.name + '/edit/' + this.model.id + link: '#' + this.model.entityType + '/edit/' + this.model.id }); if (!this.options.unlinkDisabled) { diff --git a/client/src/views/record/row-actions/view-and-edit.js b/client/src/views/record/row-actions/view-and-edit.js index 002a1a8829..c517389d96 100644 --- a/client/src/views/record/row-actions/view-and-edit.js +++ b/client/src/views/record/row-actions/view-and-edit.js @@ -37,7 +37,7 @@ define('views/record/row-actions/view-and-edit', ['views/record/row-actions/defa data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id + link: '#' + this.model.entityType + '/view/' + this.model.id }]; if (this.options.acl.edit) { @@ -48,7 +48,7 @@ define('views/record/row-actions/view-and-edit', ['views/record/row-actions/defa data: { id: this.model.id }, - link: '#' + this.model.name + '/edit/' + this.model.id + link: '#' + this.model.entityType + '/edit/' + this.model.id } ]); } diff --git a/client/src/views/record/row-actions/view-and-remove.js b/client/src/views/record/row-actions/view-and-remove.js index 0da95e455e..efa232781b 100644 --- a/client/src/views/record/row-actions/view-and-remove.js +++ b/client/src/views/record/row-actions/view-and-remove.js @@ -37,7 +37,7 @@ define('views/record/row-actions/view-and-remove', ['views/record/row-actions/de data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id + link: '#' + this.model.entityType + '/view/' + this.model.id }]; if (this.options.acl.delete) { diff --git a/client/src/views/record/row-actions/view-only.js b/client/src/views/record/row-actions/view-only.js index fe21154c3e..2f9c01b93b 100644 --- a/client/src/views/record/row-actions/view-only.js +++ b/client/src/views/record/row-actions/view-only.js @@ -38,7 +38,7 @@ define('views/record/row-actions/view-only', ['views/record/row-actions/default' data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id + link: '#' + this.model.entityType + '/view/' + this.model.id } ]; }, diff --git a/client/src/views/search/filter.js b/client/src/views/search/filter.js index 4c18679d31..f4ef87c1c8 100644 --- a/client/src/views/search/filter.js +++ b/client/src/views/search/filter.js @@ -37,7 +37,7 @@ class FilterView extends View { data() { return { name: this.name, - scope: this.model.name, + scope: this.model.entityType, notRemovable: this.options.notRemovable, }; } diff --git a/client/src/views/settings/fields/address-preview.js b/client/src/views/settings/fields/address-preview.js index cc6b840b0b..c3597b5e83 100644 --- a/client/src/views/settings/fields/address-preview.js +++ b/client/src/views/settings/fields/address-preview.js @@ -36,6 +36,7 @@ define('views/settings/fields/address-preview', ['views/fields/address'], functi var mainModel = this.model; var model = mainModel.clone(); + model.entityType = mainModel.entityType; model.name = mainModel.name; model.set({ diff --git a/client/src/views/stream/note.js b/client/src/views/stream/note.js index 391243bac4..dd1c4c16dd 100644 --- a/client/src/views/stream/note.js +++ b/client/src/views/stream/note.js @@ -86,7 +86,7 @@ class NoteStreamView extends View { if (!this.isUserStream) { if (this.parentModel) { if ( - this.parentModel.name !== this.model.get('parentType') || + this.parentModel.entityType !== this.model.get('parentType') || this.parentModel.id !== this.model.get('parentId') ) { this.isThis = false; @@ -223,7 +223,7 @@ class NoteStreamView extends View { } getIconHtml(scope, id) { - if (this.isThis && scope === this.parentModel.name) { + if (this.isThis && scope === this.parentModel.entityType) { return; } diff --git a/client/src/views/stream/notes/email-received.js b/client/src/views/stream/notes/email-received.js index 5e7e307060..f18a48cb32 100644 --- a/client/src/views/stream/notes/email-received.js +++ b/client/src/views/stream/notes/email-received.js @@ -55,7 +55,7 @@ define('views/stream/notes/email-received', ['views/stream/note'], function (Dep if ( this.parentModel && ( - this.model.get('parentType') === this.parentModel.name && + this.model.get('parentType') === this.parentModel.entityType && this.model.get('parentId') === this.parentModel.id ) ) { diff --git a/client/src/views/stream/notes/email-sent.js b/client/src/views/stream/notes/email-sent.js index eb1d677209..d904fede51 100644 --- a/client/src/views/stream/notes/email-sent.js +++ b/client/src/views/stream/notes/email-sent.js @@ -53,7 +53,7 @@ define('views/stream/notes/email-sent', ['views/stream/note'], function (Dep) { if ( this.parentModel && ( - this.model.get('parentType') === this.parentModel.name && + this.model.get('parentType') === this.parentModel.entityType && this.model.get('parentId') === this.parentModel.id ) ) { diff --git a/client/src/views/stream/notes/update.js b/client/src/views/stream/notes/update.js index 726b852a1f..46443b6291 100644 --- a/client/src/views/stream/notes/update.js +++ b/client/src/views/stream/notes/update.js @@ -84,10 +84,10 @@ define('views/stream/notes/update', ['views/stream/note'], function (Dep) { fields.forEach(field => { let type = model.getFieldType(field) || 'base'; let viewName = this.getMetadata() - .get(['entityDefs', model.name, 'fields', field, 'view']) || + .get(['entityDefs', model.entityType, 'fields', field, 'view']) || this.getFieldManager().getViewName(type); - let attributeList = this.getFieldManager().getEntityTypeFieldAttributeList(model.name, field); + let attributeList = this.getFieldManager().getEntityTypeFieldAttributeList(model.entityType, field); let hasValue = false; diff --git a/client/src/views/stream/panel.js b/client/src/views/stream/panel.js index 948c622913..ec89af638c 100644 --- a/client/src/views/stream/panel.js +++ b/client/src/views/stream/panel.js @@ -184,7 +184,7 @@ class PanelStreamView extends RelationshipPanelView { ...this.events, }; - this.scope = this.model.name; + this.scope = this.model.entityType; this.filter = this.getStoredFilter(); this.setupTitle(); @@ -198,9 +198,9 @@ class PanelStreamView extends RelationshipPanelView { this.isInternalNoteMode = false; - this.storageTextKey = 'stream-post-' + this.model.name + '-' + this.model.id; - this.storageAttachmentsKey = 'stream-post-attachments-' + this.model.name + '-' + this.model.id; - this.storageIsInernalKey = 'stream-post-is-internal-' + this.model.name + '-' + this.model.id; + this.storageTextKey = 'stream-post-' + this.model.entityType + '-' + this.model.id; + this.storageAttachmentsKey = 'stream-post-attachments-' + this.model.entityType + '-' + this.model.id; + this.storageIsInernalKey = 'stream-post-is-internal-' + this.model.entityType + '-' + this.model.id; this.on('remove', () => { this.storeControl(); @@ -382,7 +382,7 @@ class PanelStreamView extends RelationshipPanelView { this.getCollectionFactory().create('Note', (collection) => { this.collection = collection; - collection.url = this.model.name + '/' + this.model.id + '/stream'; + collection.url = this.model.entityType + '/' + this.model.id + '/stream'; collection.maxSize = this.getConfig().get('recordsPerPageSmall') || 5; this.setFilter(this.filter); @@ -615,7 +615,7 @@ class PanelStreamView extends RelationshipPanelView { prepareNoteForPost(model) { model.set('parentId', this.model.id); - model.set('parentType', this.model.name); + model.set('parentType', this.model.entityType); } getButtonList() { @@ -667,7 +667,7 @@ class PanelStreamView extends RelationshipPanelView { // noinspection JSUnusedGlobalSymbols actionViewPostList() { - var url = this.model.name + '/' + this.model.id + '/posts'; + var url = this.model.entityType + '/' + this.model.id + '/posts'; var data = { scope: 'Note', diff --git a/client/src/views/stream/record/list.js b/client/src/views/stream/record/list.js index 248af5014b..e1aba351d6 100644 --- a/client/src/views/stream/record/list.js +++ b/client/src/views/stream/record/list.js @@ -144,7 +144,7 @@ class ListStreamRecordView extends ListExpandedRecordView { isUserStream: this.options.isUserStream, noEdit: this.options.noEdit, optionsToPass: ['acl'], - name: this.type + '-' + model.name, + name: this.type + '-' + model.entityType, selector: 'li[data-id="' + model.id + '"]', setViewBeforeCallback: this.options.skipBuildRows && !this.isRendered(), }, callback); diff --git a/client/src/views/user-security/modals/two-factor-email.js b/client/src/views/user-security/modals/two-factor-email.js index 62c69b4018..5c67ac4b8d 100644 --- a/client/src/views/user-security/modals/two-factor-email.js +++ b/client/src/views/user-security/modals/two-factor-email.js @@ -65,8 +65,7 @@ define('views/user-security/modals/two-factor-email', let codeLength = this.getConfig().get('auth2FAEmailCodeLength') || 7; let model = new Model(); - - model.name = 'UserSecurity'; + model.entityType = model.name = 'UserSecurity'; model.set('emailAddress', null); diff --git a/client/src/views/user/password-change-request.js b/client/src/views/user/password-change-request.js index 272bfedbbf..59bfcff680 100644 --- a/client/src/views/user/password-change-request.js +++ b/client/src/views/user/password-change-request.js @@ -47,9 +47,8 @@ define('views/user/password-change-request', ['view', 'model'], function (Dep, M }, setup: function () { - var model = this.model = new Model; - - model.name = 'User'; + let model = this.model = new Model(); + model.entityType = model.name = 'User'; this.createView('password', 'views/user/fields/password', { model: model, diff --git a/client/src/views/user/record/detail.js b/client/src/views/user/record/detail.js index 69307ee493..afcaf002af 100644 --- a/client/src/views/user/record/detail.js +++ b/client/src/views/user/record/detail.js @@ -313,7 +313,7 @@ define('views/user/record/detail', ['views/record/detail'], function (Dep) { getGridLayout: function (callback) { this._helper .layoutManager - .get(this.model.name, this.options.layoutName || this.layoutName, (simpleLayout) => { + .get(this.model.entityType, this.options.layoutName || this.layoutName, (simpleLayout) => { var layout = Espo.Utils.cloneDeep(simpleLayout); diff --git a/client/src/views/user/record/edit.js b/client/src/views/user/record/edit.js index d0bed3da8d..16a341e496 100644 --- a/client/src/views/user/record/edit.js +++ b/client/src/views/user/record/edit.js @@ -162,32 +162,34 @@ define('views/user/record/edit', ['views/record/edit', 'views/user/record/detail }, getGridLayout: function (callback) { - this._helper.layoutManager.get(this.model.name, this.options.layoutName || this.layoutName, function (simpleLayout) { + this._helper.layoutManager.get(this.model.entityType, this.options.layoutName || this.layoutName, simpleLayout => { var layout = Espo.Utils.cloneDeep(simpleLayout); layout.push({ "label": "Teams and Access Control", "name": "accessControl", "rows": [ - [{"name":"type"}, {"name":"isActive"}], - [{"name":"teams"}, {"name":"defaultTeam"}], - [{"name":"roles"}, false] + [{"name": "type"}, {"name": "isActive"}], + [{"name": "teams"}, {"name": "defaultTeam"}], + [{"name": "roles"}, false] ] }); + layout.push({ "label": "Portal", "name": "portal", "rows": [ - [{"name":"portals"}, {"name":"contact"}], - [{"name":"portalRoles"}, {"name":"accounts"}] + [{"name": "portals"}, {"name": "contact"}], + [{"name": "portalRoles"}, {"name": "accounts"}] ] }); + if (this.getUser().isAdmin() && this.model.isPortal()) { layout.push({ "label": "Misc", "name": "portalMisc", "rows": [ - [{"name":"dashboardTemplate"}, false] + [{"name": "dashboardTemplate"}, false] ] }); } @@ -202,7 +204,7 @@ define('views/user/record/edit', ['views/record/edit', 'views/user/record/detail }); } - if (this.type == 'edit' && this.getUser().isAdmin() && !this.model.isApi()) { + if (this.type === 'edit' && this.getUser().isAdmin() && !this.model.isApi()) { layout.push({ label: 'Password', rows: [ @@ -259,7 +261,7 @@ define('views/user/record/edit', ['views/record/edit', 'views/user/record/detail layout.push({ "name": "auth", "rows": [ - [{"name":"authMethod"}, false] + [{"name": "authMethod"}, false] ] }); } @@ -270,7 +272,7 @@ define('views/user/record/edit', ['views/record/edit', 'views/user/record/detail }; callback(gridLayout); - }.bind(this)); + }); }, getPasswordSendingMessage: function () { @@ -305,6 +307,5 @@ define('views/user/record/edit', ['views/record/edit', 'views/user/record/detail errorHandlerUserNameExists: function () { Espo.Ui.error(this.translate('userNameExists', 'messages', 'User')) }, - }); }); diff --git a/client/src/views/user/record/row-actions/relationship-followers.js b/client/src/views/user/record/row-actions/relationship-followers.js index d3d3dc45fa..a3ee67c227 100644 --- a/client/src/views/user/record/row-actions/relationship-followers.js +++ b/client/src/views/user/record/row-actions/relationship-followers.js @@ -37,7 +37,7 @@ define('views/user/record/row-actions/relationship-followers', ['views/record/ro data: { id: this.model.id }, - link: '#' + this.model.name + '/view/' + this.model.id + link: '#' + this.model.entityType + '/view/' + this.model.id }]; if (