mirror of
https://github.com/espocrm/espocrm.git
synced 2026-04-18 12:10:05 +00:00
Move allowInternalNotes to streamDefs
This commit is contained in:
@@ -33,6 +33,7 @@ use Espo\Core\Acl;
|
||||
use Espo\Core\Acl\Table as AclTable;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Record\Hook\SaveHook;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Entities\Note;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Entity;
|
||||
@@ -49,7 +50,8 @@ class BeforeCreate implements SaveHook
|
||||
private EntityManager $entityManager,
|
||||
private Acl $acl,
|
||||
private User $user,
|
||||
private NoteUtil $noteUtil
|
||||
private NoteUtil $noteUtil,
|
||||
private Metadata $metadata,
|
||||
) {}
|
||||
|
||||
public function process(Entity $entity): void
|
||||
@@ -64,6 +66,14 @@ class BeforeCreate implements SaveHook
|
||||
$entity->setIsInternal(false);
|
||||
}
|
||||
|
||||
if (
|
||||
!$entity->isPost() ||
|
||||
!$entity->getParentType() ||
|
||||
!$this->metadata->get("streamDefs.{$entity->getParentType()}.allowInternalNotes")
|
||||
) {
|
||||
$entity->setIsInternal(false);
|
||||
}
|
||||
|
||||
if ($entity->isPost()) {
|
||||
$this->noteUtil->handlePostText($entity);
|
||||
}
|
||||
|
||||
@@ -31,8 +31,10 @@ namespace Espo\Core\Upgrades\Migrations\V10_0;
|
||||
|
||||
use Espo\Core\Upgrades\Migration\Script;
|
||||
use Espo\Core\Utils\Config\ConfigWriter;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Entities\Preferences;
|
||||
use Espo\Entities\User;
|
||||
use Espo\Modules\Crm\Entities\CaseObj;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
class AfterUpgrade implements Script
|
||||
@@ -40,12 +42,30 @@ class AfterUpgrade implements Script
|
||||
public function __construct(
|
||||
private EntityManager $entityManager,
|
||||
private ConfigWriter $configWriter,
|
||||
private Metadata $metadata,
|
||||
) {}
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
$this->updatePreferences();
|
||||
$this->updateConfig();
|
||||
|
||||
/** @var array<string, array<string, mixed>> $clientDefs */
|
||||
$clientDefs = $this->metadata->get('clientDefs') ?? [];
|
||||
|
||||
foreach ($clientDefs as $name => $defs) {
|
||||
if ($name === CaseObj::ENTITY_TYPE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($defs['allowInternalNotes'] ?? false) {
|
||||
$this->metadata->set('streamDefs', $name, [
|
||||
'allowInternalNotes' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->metadata->save();
|
||||
}
|
||||
|
||||
private function updatePreferences(): void
|
||||
|
||||
@@ -103,7 +103,6 @@
|
||||
"selectDefaultFilters": {
|
||||
"filter": "open"
|
||||
},
|
||||
"allowInternalNotes": true,
|
||||
"additionalLayouts": {
|
||||
"detailPortal": {
|
||||
"type": "detail"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"allowInternalNotes": true
|
||||
}
|
||||
@@ -208,7 +208,7 @@ class PanelStreamView extends RelationshipPanelView {
|
||||
this.allowInternalNotes = false;
|
||||
|
||||
if (!this.getUser().isPortal()) {
|
||||
this.allowInternalNotes = this.getMetadata().get(['clientDefs', this.entityType, 'allowInternalNotes']);
|
||||
this.allowInternalNotes = this.getMetadata().get(['streamDefs', this.entityType, 'allowInternalNotes']);
|
||||
}
|
||||
|
||||
this.hasPinned = this.model.entityType !== 'User';
|
||||
|
||||
@@ -754,10 +754,6 @@
|
||||
"description": "Whether the scope has the kanban view mode on the list view.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"allowInternalNotes": {
|
||||
"description": "If true, it will be possible to post internal posts in the stream. Internal posts are not visible in portals.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"isExpandedByDefault": {
|
||||
"description": "Actual for category scopes (e.g. DocumentFolder). If true, then by default it will be in expanded mode.",
|
||||
"type": "boolean"
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
"bypassAssignedUserFollow": {
|
||||
"type": "boolean",
|
||||
"description": "Assigned users won't follow the record when they get assigned to it. If enabling, consider also enabling `forceAssignmentNotificator` in notificationDefs – otherwise, the assignee won't receive any notification. As of v10.0."
|
||||
},
|
||||
"allowInternalNotes": {
|
||||
"type": "boolean",
|
||||
"description": "Allow internal notes. As of v10.0."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user