include shared dashlet parameter

This commit is contained in:
Yuri Kuznetsov
2025-02-25 10:24:17 +02:00
parent e635a28f16
commit 9a407eef6d
7 changed files with 132 additions and 19 deletions
@@ -1,8 +1,9 @@
{
"view":"views/dashlets/abstract/record-list",
"view": "views/dashlets/abstract/record-list",
"aclScope": "Case",
"entityType": "Case",
"options": {
"view": "views/dashlets/options/record-list",
"fields": {
"title": {
"type": "varchar",
@@ -20,6 +21,9 @@
"expandedLayout": {
"type": "base",
"view": "views/dashlets/fields/records/expanded-layout"
},
"includeShared": {
"type": "bool"
}
},
"defaults": {
@@ -27,6 +31,7 @@
"order": "desc",
"displayRecords": 5,
"populateAssignedUser": true,
"includeShared": false,
"expandedLayout": {
"rows": [
[
@@ -65,11 +70,12 @@
{
"rows": [
[
{"name": "title"}
{"name": "title"},
{"name": "autorefreshInterval"}
],
[
{"name": "displayRecords"},
{"name": "autorefreshInterval"}
{"name": "includeShared"}
],
[
{"name": "expandedLayout"},
@@ -1,8 +1,9 @@
{
"view":"views/dashlets/abstract/record-list",
"view": "views/dashlets/abstract/record-list",
"aclScope": "Lead",
"entityType": "Lead",
"options": {
"view": "views/dashlets/options/record-list",
"fields": {
"title": {
"type": "varchar",
@@ -20,6 +21,9 @@
"expandedLayout": {
"type": "base",
"view": "views/dashlets/fields/records/expanded-layout"
},
"includeShared": {
"type": "bool"
}
},
"defaults": {
@@ -27,6 +31,7 @@
"order": "desc",
"displayRecords": 5,
"populateAssignedUser": true,
"includeShared": false,
"expandedLayout": {
"rows": [
[
@@ -59,11 +64,12 @@
{
"rows": [
[
{"name": "title"}
{"name": "title"},
{"name": "autorefreshInterval"}
],
[
{"name": "displayRecords"},
{"name": "autorefreshInterval"}
{"name": "includeShared"}
],
[
{"name": "expandedLayout"},
@@ -1,8 +1,9 @@
{
"view":"views/dashlets/abstract/record-list",
"view": "views/dashlets/abstract/record-list",
"aclScope": "Opportunity",
"entityType": "Opportunity",
"options": {
"view": "views/dashlets/options/record-list",
"fields": {
"title": {
"type": "varchar",
@@ -20,6 +21,9 @@
"expandedLayout": {
"type": "base",
"view": "views/dashlets/fields/records/expanded-layout"
},
"includeShared": {
"type": "bool"
}
},
"defaults": {
@@ -27,6 +31,7 @@
"order": "asc",
"displayRecords": 5,
"populateAssignedUser": true,
"includeShared": false,
"expandedLayout": {
"rows": [
[
@@ -56,11 +61,12 @@
{
"rows": [
[
{"name": "title"}
{"name": "title"},
{"name": "autorefreshInterval"}
],
[
{"name": "displayRecords"},
{"name": "autorefreshInterval"}
{"name": "includeShared"}
],
[
{"name": "expandedLayout"},
@@ -1,8 +1,9 @@
{
"view":"crm:views/dashlets/tasks",
"view": "crm:views/dashlets/tasks",
"aclScope": "Task",
"entityType": "Task",
"options": {
"view": "views/dashlets/options/record-list",
"fields": {
"title": {
"type": "varchar",
@@ -20,12 +21,16 @@
"expandedLayout": {
"type": "base",
"view": "views/dashlets/fields/records/expanded-layout"
},
"includeShared": {
"type": "bool"
}
},
"defaults": {
"orderBy": "dateUpcoming",
"order": "asc",
"displayRecords": 5,
"includeShared": false,
"expandedLayout": {
"rows": [
[
@@ -58,14 +63,16 @@
{
"rows": [
[
{"name": "title"}
],
[
{"name": "displayRecords"},
{"name": "title"},
{"name": "autorefreshInterval"}
],
[
{"name": "expandedLayout", "fullWidth": true}
{"name": "displayRecords"},
{"name": "includeShared"}
],
[
{"name": "expandedLayout"},
false
]
]
}
@@ -68,13 +68,21 @@ class RecordListDashletView extends BaseDashletView {
rowActionsView = 'views/record/row-actions/view-and-edit'
/**
* @protected
* @type {boolean}
*/
hasCollaborators
init() {
this.name = this.options.name || this.name;
this.scope = this.getMetadata().get(['dashlets', this.name, 'entityType']) || this.scope;
this.scope = this.getMetadata().get(`dashlets.${this.name}.entityType`) || this.scope;
this.additionalRowActionList = this.getMetadata().get(`dashlets.${this.name}.rowActionList`) ||
this.additionalRowActionList;
this.hasCollaborators = !!this.getMetadata().get(`scopes.${this.scope}.collaborators`);
super.init();
}
@@ -86,7 +94,22 @@ class RecordListDashletView extends BaseDashletView {
* @return {module:search-manager~data}
*/
getSearchData() {
return this.getOption('searchData');
/** @type {module:search-manager~data} */
const data = Espo.Utils.cloneDeep(this.getOption('searchData'));
if (!this.hasCollaborators) {
return data;
}
if (this.getOption('includeShared')) {
if (!data.bool) {
data.bool = {};
}
data.bool.shared = true;
}
return data;
}
afterRender() {
@@ -172,7 +195,7 @@ class RecordListDashletView extends BaseDashletView {
name: 'create',
text: this.translate('Create ' + this.scope, 'labels', this.scope),
iconHtml: '<span class="fas fa-plus"></span>',
url: '#'+this.scope+'/create',
url: `#${this.scope}/create`,
});
}
}
+16 -1
View File
@@ -36,8 +36,23 @@ class BaseDashletOptionsModalView extends ModalView {
cssName = 'options-modal'
className = 'dialog dialog-record'
name = ''
/**
* @protected
* @type {string}
*/
name
/**
* @protected
* @type {boolean}
*/
escapeDisabled = true
/**
* @protected
* @type {boolean}
*/
saveDisabled = false;
buttonList = [
@@ -0,0 +1,50 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2025 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://www.espocrm.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
import BaseDashletOptionsModalView from 'views/dashlets/options/base';
export default class RecordListDashletOptionsModalView extends BaseDashletOptionsModalView {
/**
* @protected
* @type {boolean}
*/
hasCollaborators
setup() {
const entityType = this.getMetadata().get(`dashlets.${this.name}.entityType`);
this.hasCollaborators = entityType && !!this.getMetadata().get(`scopes.${entityType}.collaborators`);
super.setup();
if (!this.hasCollaborators) {
this.getRecordView().hideField('includeShared');
}
}
}