mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
dashboard templates
This commit is contained in:
59
application/Espo/Controllers/DashboardTemplate.php
Normal file
59
application/Espo/Controllers/DashboardTemplate.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2019 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use \Espo\Core\Exceptions\Forbidden;
|
||||
use \Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
class DashboardTemplate extends \Espo\Core\Controllers\Record
|
||||
{
|
||||
protected function checkControllerAccess()
|
||||
{
|
||||
if (!$this->getUser()->isAdmin()) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
|
||||
public function postActionDeployToUsers($params, $data)
|
||||
{
|
||||
if (empty($data->id)) throw new BadRequest();
|
||||
if (empty($data->userIdList)) throw new BadRequest();
|
||||
|
||||
return $this->getServiceFactory()->create('DashboardTemplate')->deployToUsers($data->id, $data->userIdList);
|
||||
}
|
||||
|
||||
public function postActionDeployToTeam($params, $data)
|
||||
{
|
||||
if (empty($data->id)) throw new BadRequest();
|
||||
if (empty($data->teamId)) throw new BadRequest();
|
||||
|
||||
return $this->getServiceFactory()->create('DashboardTemplate')->deployToTeam($data->id, $data->teamId);
|
||||
}
|
||||
}
|
||||
35
application/Espo/Entities/DashboardTemplate.php
Normal file
35
application/Espo/Entities/DashboardTemplate.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2019 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Entities;
|
||||
|
||||
class DashboardTemplate extends \Espo\Core\ORM\Entity
|
||||
{
|
||||
|
||||
}
|
||||
@@ -39,6 +39,7 @@
|
||||
"Integrations": "Integrations",
|
||||
"Extensions": "Extensions",
|
||||
"Webhooks": "Webhooks",
|
||||
"Dashboard Templates": "Dashboard Templates",
|
||||
"Upload": "Upload",
|
||||
"Installing...": "Installing...",
|
||||
"Upgrading...": "Upgrading...",
|
||||
@@ -245,6 +246,7 @@
|
||||
"systemRequirements": "System Requirements for EspoCRM.",
|
||||
"apiUsers": "Separate users for integration purposes.",
|
||||
"webhooks": "Manage webhooks.",
|
||||
"dashboardTemplates": "Deploy dashboards to users.",
|
||||
"pdfTemplates": "Templates for printing to PDF."
|
||||
},
|
||||
"options": {
|
||||
|
||||
12
application/Espo/Resources/i18n/en_US/DashboardTemplate.json
Normal file
12
application/Espo/Resources/i18n/en_US/DashboardTemplate.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"fields": {
|
||||
"layout": "Layout"
|
||||
},
|
||||
"links": {
|
||||
},
|
||||
"labels": {
|
||||
"Create DashboardTemplate": "Create Template",
|
||||
"Deploy to Users": "Deploy to Users",
|
||||
"Deploy to Team": "Deploy to Team"
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@
|
||||
"LeadCapture": "Lead Capture Entry Point",
|
||||
"LeadCaptureLogRecord": "Lead Capture Log Record",
|
||||
"ArrayValue": "Array Value",
|
||||
"DashboardTemplate": "Dashboard Template",
|
||||
"Webhook": "Webhook"
|
||||
},
|
||||
"scopeNamesPlural": {
|
||||
@@ -88,6 +89,7 @@
|
||||
"LeadCapture": "Lead Capture",
|
||||
"LeadCaptureLogRecord": "Lead Capture Log",
|
||||
"ArrayValue": "Array Values",
|
||||
"DashboardTemplate": "Dashboard Templates",
|
||||
"Webhook": "Webhooks"
|
||||
},
|
||||
"labels": {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[
|
||||
{
|
||||
"rows": [
|
||||
[{"name": "name"}, false],
|
||||
[{"name": "layout", "fullWidth": true}]
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,8 @@
|
||||
[
|
||||
{
|
||||
"rows": [
|
||||
[{"name": "name"}, false],
|
||||
[{"name": "layout", "fullWidth": true}]
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,3 @@
|
||||
[
|
||||
{"name": "name", "link": true}
|
||||
]
|
||||
@@ -214,6 +214,12 @@
|
||||
"label": "Webhooks",
|
||||
"description": "webhooks"
|
||||
},
|
||||
{
|
||||
|
||||
"url": "#DashboardTemplate",
|
||||
"label": "Dashboard Templates",
|
||||
"description": "dashboardTemplates"
|
||||
},
|
||||
{
|
||||
"url": "#Attachment",
|
||||
"label": "Attachments",
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"controller": "controllers/record",
|
||||
"views": {
|
||||
"detail": "views/dashboard-template/detail"
|
||||
},
|
||||
"menu": {
|
||||
"detail": {
|
||||
"buttons": [
|
||||
{
|
||||
"action": "deployToUsers",
|
||||
"label": "Deploy to Users"
|
||||
},
|
||||
{
|
||||
"action": "deployToTeam",
|
||||
"label": "Deploy to Team"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"searchPanelDisabled": true
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"fields": {
|
||||
"name": {
|
||||
"type": "varchar",
|
||||
"maxLength": 100,
|
||||
"trim": true
|
||||
},
|
||||
"layout": {
|
||||
"type": "jsonArray",
|
||||
"view": "views/settings/fields/dashboard-layout",
|
||||
"inlineEditDisabled": true
|
||||
},
|
||||
"dashletsOptions": {
|
||||
"type": "jsonObject",
|
||||
"disabled": true
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "datetime",
|
||||
"readOnly": true
|
||||
},
|
||||
"modifiedAt": {
|
||||
"type": "datetime",
|
||||
"readOnly": true
|
||||
},
|
||||
"createdBy": {
|
||||
"type": "link",
|
||||
"readOnly": true
|
||||
},
|
||||
"modifiedBy": {
|
||||
"type": "link",
|
||||
"readOnly": true
|
||||
}
|
||||
},
|
||||
"links": {
|
||||
"createdBy": {
|
||||
"type": "belongsTo",
|
||||
"entity": "User"
|
||||
},
|
||||
"modifiedBy": {
|
||||
"type": "belongsTo",
|
||||
"entity": "User"
|
||||
}
|
||||
},
|
||||
"collection": {
|
||||
"orderBy": "name",
|
||||
"order": "asc"
|
||||
}
|
||||
}
|
||||
80
application/Espo/Services/DashboardTemplate.php
Normal file
80
application/Espo/Services/DashboardTemplate.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2019 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Services;
|
||||
|
||||
use \Espo\ORM\Entity;
|
||||
|
||||
use \Espo\Core\Exceptions\NotFount;
|
||||
|
||||
class DashboardTemplate extends Record
|
||||
{
|
||||
public function deployToUsers(string $id, array $userIdList)
|
||||
{
|
||||
$template = $this->getEntityManager()->fetchEntity('DashboardTemplate', $id);
|
||||
if (!$template) throw new NotFount();
|
||||
|
||||
foreach ($userIdList as $userId) {
|
||||
$preferences = $this->getEntityManager()->fetchEntity('Preferences', $userId);
|
||||
if (!$preferences) continue;
|
||||
$preferences->set([
|
||||
'dashboardLayout' => $template->get('layout'),
|
||||
'dashletsOptions' => $template->get('dashletsOptions'),
|
||||
]);
|
||||
$this->getEntityManager()->saveEntity($preferences);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function deployToTeam(string $id, string $teamId)
|
||||
{
|
||||
$template = $this->getEntityManager()->fetchEntity('DashboardTemplate', $id);
|
||||
if (!$template) throw new NotFount();
|
||||
|
||||
$team = $this->getEntityManager()->fetchEntity('Team', $teamId);
|
||||
if (!$team) throw new NotFount();
|
||||
|
||||
$userList = $this->getEntityManager()->getRepository('User')->join(['teams'])->distinct()->where([
|
||||
'teams.id' => $teamId,
|
||||
])->find();
|
||||
|
||||
foreach ($userList as $user) {
|
||||
$preferences = $this->getEntityManager()->fetchEntity('Preferences', $user->id);
|
||||
if (!$preferences) continue;
|
||||
$preferences->set([
|
||||
'dashboardLayout' => $template->get('layout'),
|
||||
'dashletsOptions' => $template->get('dashletsOptions'),
|
||||
]);
|
||||
$this->getEntityManager()->saveEntity($preferences);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
49
client/src/views/dashboard-template/detail.js
Normal file
49
client/src/views/dashboard-template/detail.js
Normal file
@@ -0,0 +1,49 @@
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2019 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/dashboard-template/detail', 'views/detail', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
actionDeployToUsers: function () {
|
||||
this.createView('dialog', 'views/dashboard-template/modals/deploy-to-users', {
|
||||
model: this.model,
|
||||
}, function (view) {
|
||||
view.render();
|
||||
}, this);
|
||||
},
|
||||
|
||||
actionDeployToTeam: function () {
|
||||
this.createView('dialog', 'views/dashboard-template/modals/deploy-to-team', {
|
||||
model: this.model,
|
||||
}, function (view) {
|
||||
view.render();
|
||||
}, this);
|
||||
},
|
||||
});
|
||||
});
|
||||
97
client/src/views/dashboard-template/modals/deploy-to-team.js
Normal file
97
client/src/views/dashboard-template/modals/deploy-to-team.js
Normal file
@@ -0,0 +1,97 @@
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2019 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/dashboard-template/modals/deploy-to-team', ['views/modal', 'model'], function (Dep, Model) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
className: 'dialog dialog-record',
|
||||
|
||||
templateContent: '<div class="record">{{{record}}}</div>',
|
||||
|
||||
setup: function () {
|
||||
this.buttonList = [
|
||||
{
|
||||
name: 'deploy',
|
||||
html: this.translate('Deploy for Team', 'labels', 'DashboardTemplate'),
|
||||
style: 'danger',
|
||||
},
|
||||
{
|
||||
name: 'cancel',
|
||||
label: 'Cancel',
|
||||
},
|
||||
];
|
||||
|
||||
this.headerHtml = this.getHelper().escapeString(this.model.get('name'));
|
||||
|
||||
this.formModel = new Model();
|
||||
this.formModel.name = 'None';
|
||||
|
||||
this.formModel.setDefs({
|
||||
fields: {
|
||||
'team': {
|
||||
type: 'link',
|
||||
entity: 'Team',
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.createView('record', 'views/record/edit-for-modal', {
|
||||
scope: 'None',
|
||||
model: this.formModel,
|
||||
el: this.getSelector() + ' .record',
|
||||
detailLayout: [
|
||||
{
|
||||
rows: [
|
||||
[
|
||||
{
|
||||
name: 'team',
|
||||
fullWidth: true,
|
||||
labelText: this.translate('team', 'links'),
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
],
|
||||
});
|
||||
},
|
||||
|
||||
actionDeploy: function () {
|
||||
if (this.getView('record').processFetch()) {
|
||||
Espo.Ajax.postRequest('DashboardTemplate/action/deployToTeam', {
|
||||
id: this.model.id,
|
||||
teamId: this.formModel.get('teamId'),
|
||||
}).then(function () {
|
||||
Espo.Ui.success(this.translate('Done'));
|
||||
this.close();
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,98 @@
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2019 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://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 General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
define('views/dashboard-template/modals/deploy-to-users', ['views/modal', 'model'], function (Dep, Model) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
className: 'dialog dialog-record',
|
||||
|
||||
templateContent: '<div class="record">{{{record}}}</div>',
|
||||
|
||||
setup: function () {
|
||||
this.buttonList = [
|
||||
{
|
||||
name: 'deploy',
|
||||
html: this.translate('Deploy for Users', 'labels', 'DashboardTemplate'),
|
||||
style: 'danger',
|
||||
},
|
||||
{
|
||||
name: 'cancel',
|
||||
label: 'Cancel',
|
||||
},
|
||||
];
|
||||
|
||||
this.headerHtml = this.getHelper().escapeString(this.model.get('name'));
|
||||
|
||||
this.formModel = new Model();
|
||||
this.formModel.name = 'None';
|
||||
|
||||
this.formModel.setDefs({
|
||||
fields: {
|
||||
'users': {
|
||||
type: 'linkMultiple',
|
||||
view: 'views/fields/users',
|
||||
entity: 'User',
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.createView('record', 'views/record/edit-for-modal', {
|
||||
scope: 'None',
|
||||
model: this.formModel,
|
||||
el: this.getSelector() + ' .record',
|
||||
detailLayout: [
|
||||
{
|
||||
rows: [
|
||||
[
|
||||
{
|
||||
name: 'users',
|
||||
fullWidth: true,
|
||||
labelText: this.translate('users', 'links'),
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
],
|
||||
});
|
||||
},
|
||||
|
||||
actionDeploy: function () {
|
||||
if (this.getView('record').processFetch()) {
|
||||
Espo.Ajax.postRequest('DashboardTemplate/action/deployToUsers', {
|
||||
id: this.model.id,
|
||||
userIdList: this.formModel.get('usersIds'),
|
||||
}).then(function () {
|
||||
Espo.Ui.success(this.translate('Done'));
|
||||
this.close();
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user