mirror of
https://github.com/espocrm/espocrm.git
synced 2026-07-01 08:26:04 +00:00
my activities: include shared param
This commit is contained in:
@@ -25,13 +25,17 @@
|
||||
"type": "int",
|
||||
"min": 0,
|
||||
"required": true
|
||||
},
|
||||
"includeShared": {
|
||||
"type": "bool"
|
||||
}
|
||||
},
|
||||
"defaults": {
|
||||
"displayRecords": 10,
|
||||
"autorefreshInterval": 0.5,
|
||||
"futureDays": 3,
|
||||
"enabledScopeList": ["Meeting", "Call", "Task"]
|
||||
"enabledScopeList": ["Meeting", "Call", "Task"],
|
||||
"includeShared": false
|
||||
},
|
||||
"layout": [
|
||||
{
|
||||
@@ -46,7 +50,7 @@
|
||||
],
|
||||
[
|
||||
{"name": "futureDays"},
|
||||
false
|
||||
{"name": "includeShared"}
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ class GetUpcoming implements Action
|
||||
maxSize: $searchParams->getMaxSize(),
|
||||
futureDays: $futureDays,
|
||||
entityTypeList: $entityTypeList,
|
||||
includeShared: $request->getQueryParam('includeShared') === 'true',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ class Params
|
||||
readonly public ?int $offset = null,
|
||||
readonly public ?int $maxSize = null,
|
||||
readonly public ?int $futureDays = null,
|
||||
readonly public ?array $entityTypeList = null
|
||||
readonly public ?array $entityTypeList = null,
|
||||
readonly public bool $includeShared = false,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity as CoreEntity;
|
||||
use Espo\Core\Record\ServiceContainer;
|
||||
use Espo\Core\Select\Bool\Filters\OnlyMy;
|
||||
use Espo\Core\Select\Bool\Filters\Shared;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\DateTime as DateTimeUtil;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
@@ -57,8 +58,10 @@ use Espo\Core\Select\Where\ConverterFactory as WhereConverterFactory;
|
||||
use Espo\Core\Select\SelectBuilderFactory;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
|
||||
use Exception;
|
||||
use PDO;
|
||||
use DateTime;
|
||||
use RuntimeException;
|
||||
|
||||
class UpcomingService
|
||||
{
|
||||
@@ -118,7 +121,7 @@ class UpcomingService
|
||||
continue;
|
||||
}
|
||||
|
||||
$queryList[] = $this->getEntityTypeQuery($entityType, $user, $futureDays);
|
||||
$queryList[] = $this->getEntityTypeQuery($entityType, $user, $futureDays, $params->includeShared);
|
||||
}
|
||||
|
||||
if ($queryList === []) {
|
||||
@@ -200,10 +203,14 @@ class UpcomingService
|
||||
* @throws Forbidden
|
||||
* @throws BadRequest
|
||||
*/
|
||||
private function getEntityTypeQuery(string $entityType, User $user, int $futureDays): Select
|
||||
private function getEntityTypeQuery(string $entityType, User $user, int $futureDays, bool $includeShared): Select
|
||||
{
|
||||
$beforeString = (new DateTime())->modify('+' . $futureDays . ' days')
|
||||
->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT);
|
||||
try {
|
||||
$beforeString = (new DateTime())->modify('+' . $futureDays . ' days')
|
||||
->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT);
|
||||
} catch (Exception $e) {
|
||||
throw new RuntimeException($e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
$builder = $this->selectBuilderFactory
|
||||
->create()
|
||||
@@ -212,6 +219,10 @@ class UpcomingService
|
||||
->withBoolFilter(OnlyMy::NAME)
|
||||
->withStrictAccessControl();
|
||||
|
||||
if ($includeShared && $this->metadata->get("scopes.$entityType.collaborators")) {
|
||||
$builder->withBoolFilter(Shared::NAME);
|
||||
}
|
||||
|
||||
$orderField = 'dateStart';
|
||||
$primaryFilter = Planned::NAME;
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
"url": "URL",
|
||||
"dateFilter": "Date Filter",
|
||||
"text": "Text",
|
||||
"folder": "Folder"
|
||||
"folder": "Folder",
|
||||
"includeShared": "Include Shared"
|
||||
},
|
||||
"options": {
|
||||
"mode": {
|
||||
|
||||
@@ -154,6 +154,10 @@ class ActivitiesDashletView extends BaseDashletView {
|
||||
this.collection.data.entityTypeList = this.scopeList;
|
||||
this.collection.data.futureDays = this.getOption('futureDays');
|
||||
|
||||
if (this.getOption('includeShared')) {
|
||||
this.collection.data.includeShared = true;
|
||||
}
|
||||
|
||||
this.listenToOnce(this.collection, 'sync', () => {
|
||||
this.createView('list', 'crm:views/record/list-activities-dashlet', {
|
||||
selector: '> .list-container',
|
||||
|
||||
Reference in New Issue
Block a user