diff --git a/client/modules/crm/src/views/record/panels/tasks.js b/client/modules/crm/src/views/record/panels/tasks.js index 4b906a6e55..5cab90362b 100644 --- a/client/modules/crm/src/views/record/panels/tasks.js +++ b/client/modules/crm/src/views/record/panels/tasks.js @@ -32,7 +32,7 @@ define('crm:views/record/panels/tasks', ['views/record/panels/relationship'], fu name: 'tasks', - scope: 'Task', + entityType: 'Task', filterList: ['all', 'actual', 'completed'], diff --git a/client/src/views/import/record/panels/imported.js b/client/src/views/import/record/panels/imported.js index e4aafaf5be..f97aad63d3 100644 --- a/client/src/views/import/record/panels/imported.js +++ b/client/src/views/import/record/panels/imported.js @@ -35,7 +35,7 @@ class ImportImportedPanelView extends RelationshipPanelView { rowActionsView = 'views/record/row-actions/relationship-no-unlink' setup() { - this.scope = this.model.get('entityType'); + this.entityType = this.model.get('entityType'); this.title = this.title || this.translate('Imported', 'labels', 'Import'); super.setup(); diff --git a/client/src/views/record/panels/bottom.js b/client/src/views/record/panels/bottom.js index aa751177d7..6021bf8ff9 100644 --- a/client/src/views/record/panels/bottom.js +++ b/client/src/views/record/panels/bottom.js @@ -87,6 +87,7 @@ class BottomPanelView extends View { data() { return { scope: this.scope, + entityType: this.entityType, name: this.panelName, hiddenFields: this.recordHelper.getHiddenFields(), fieldList: this.getFieldList(), diff --git a/client/src/views/record/panels/relationship.js b/client/src/views/record/panels/relationship.js index 94a3915564..0d86082c29 100644 --- a/client/src/views/record/panels/relationship.js +++ b/client/src/views/record/panels/relationship.js @@ -56,11 +56,16 @@ class RelationshipPanelView extends BottomPanelView { url = null /** - * A scope. - * - * @type {string|null} + * @type {string} + * @deprecated Use `entityType`. */ - scope = null + scope + + /** + * An entity type. + * @type {string} + */ + entityType /** * Read-only. @@ -94,11 +99,33 @@ 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.entityType}'`); + if (!this.link) { + throw new Error(`No link or panelName.`); } - this.scope = this.scope || this.model.defs.links[this.link].entity; + // noinspection JSDeprecatedSymbols + if (!this.scope && !this.entityType) { + if (!this.model) { + throw new Error(`No model passed.`); + } + + if (!(this.link in this.model.defs.links)) { + throw new Error(`Link '${this.link}' is not defined in model '${this.model.entityType}'.`); + } + } + + this.entityType = this.entityType || this.model.defs.links[this.link].entity; + + // noinspection JSDeprecatedSymbols + if (this.scope) { + // For backward compatibility. + // noinspection JSDeprecatedSymbols + this.entityType = this.scope; + } + + // For backward compatibility. + // noinspection JSDeprecatedSymbols + this.scope = this.entityType; const linkReadOnly = this.getMetadata() .get(['entityDefs', this.model.entityType, 'links', this.link, 'readOnly']) || false; @@ -150,8 +177,8 @@ class RelationshipPanelView extends BottomPanelView { if (this.defs.create) { if ( - this.getAcl().check(this.scope, 'create') && - !~this.noCreateScopeList.indexOf(this.scope) + this.getAcl().check(this.entityType, 'create') && + !~this.noCreateScopeList.indexOf(this.entityType) ) { this.buttonList.push({ title: 'Create', @@ -227,7 +254,7 @@ class RelationshipPanelView extends BottomPanelView { this.wait(true); - this.getCollectionFactory().create(this.scope, collection => { + this.getCollectionFactory().create(this.entityType, collection => { collection.maxSize = this.recordsPerPage || this.getConfig().get('recordsPerPageSmall') || 5; if (this.defs.filters) { @@ -257,8 +284,8 @@ class RelationshipPanelView extends BottomPanelView { const viewName = this.defs.recordListView || - this.getMetadata().get(['clientDefs', this.scope, 'recordViews', 'listRelated']) || - this.getMetadata().get(['clientDefs', this.scope, 'recordViews', 'list']) || + this.getMetadata().get(['clientDefs', this.entityType, 'recordViews', 'listRelated']) || + this.getMetadata().get(['clientDefs', this.entityType, 'recordViews', 'list']) || 'views/record/list'; this.listViewName = viewName; @@ -323,13 +350,13 @@ class RelationshipPanelView extends BottomPanelView { let iconHtml = ''; if (!this.getConfig().get('scopeColorsDisabled')) { - iconHtml = this.getHelper().getScopeColorIconHtml(this.scope); + iconHtml = this.getHelper().getScopeColorIconHtml(this.entityType); } this.titleHtml = this.title; if (this.defs.label) { - this.titleHtml = iconHtml + this.translate(this.defs.label, 'labels', this.scope); + this.titleHtml = iconHtml + this.translate(this.defs.label, 'labels', this.entityType); } else { this.titleHtml = iconHtml + this.title; } @@ -353,8 +380,8 @@ class RelationshipPanelView extends BottomPanelView { } if (!orderBy) { - orderBy = this.getMetadata().get(['entityDefs', this.scope, 'collection', 'orderBy']); - order = this.getMetadata().get(['entityDefs', this.scope, 'collection', 'order']) + orderBy = this.getMetadata().get(['entityDefs', this.entityType, 'collection', 'orderBy']); + order = this.getMetadata().get(['entityDefs', this.entityType, 'collection', 'order']) } if (orderBy && !order) { @@ -428,7 +455,7 @@ class RelationshipPanelView extends BottomPanelView { * @return {string} */ translateFilter(name) { - return this.translate(name, 'presetFilters', this.scope); + return this.translate(name, 'presetFilters', this.entityType); } /** @@ -540,11 +567,11 @@ class RelationshipPanelView extends BottomPanelView { this.getMetadata().get( ['clientDefs', this.model.entityType, 'relationshipPanels', this.name, 'viewModalView'] ) || - this.getMetadata().get(['clientDefs', this.scope, 'modalViews', 'relatedList']) || + this.getMetadata().get(['clientDefs', this.entityType, 'modalViews', 'relatedList']) || this.viewModalView || 'views/modals/related-list'; - const scope = data.scope || this.scope; + const scope = data.scope || this.entityType; let filter = this.filter; diff --git a/client/src/views/stream/panel.js b/client/src/views/stream/panel.js index 07b264d084..16246715ee 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.entityType; + this.entityType = this.model.entityType; this.filter = this.getStoredFilter(); this.setupTitle(); @@ -193,7 +193,7 @@ class PanelStreamView extends RelationshipPanelView { this.allowInternalNotes = false; if (!this.getUser().isPortal()) { - this.allowInternalNotes = this.getMetadata().get(['clientDefs', this.scope, 'allowInternalNotes']); + this.allowInternalNotes = this.getMetadata().get(['clientDefs', this.entityType, 'allowInternalNotes']); } this.isInternalNoteMode = false; @@ -684,15 +684,15 @@ class PanelStreamView extends RelationshipPanelView { } getStoredFilter() { - return this.getStorage().get('state', 'streamPanelFilter' + this.scope) || null; + return this.getStorage().get('state', 'streamPanelFilter' + this.entityType) || null; } storeFilter(filter) { if (filter) { - this.getStorage().set('state', 'streamPanelFilter' + this.scope, filter); + this.getStorage().set('state', 'streamPanelFilter' + this.entityType, filter); } else { - this.getStorage().clear('state', 'streamPanelFilter' + this.scope); + this.getStorage().clear('state', 'streamPanelFilter' + this.entityType); } }