Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #96 from atrocore/i-63e4fc8df0088ab24
Browse files Browse the repository at this point in the history
Refactored of assets panel
  • Loading branch information
rratsun authored Feb 13, 2023
2 parents 9dff8cc + 305d967 commit ca7f6c1
Show file tree
Hide file tree
Showing 26 changed files with 8 additions and 877 deletions.
96 changes: 0 additions & 96 deletions app/Listeners/AbstractListener.php

This file was deleted.

81 changes: 0 additions & 81 deletions app/Listeners/EntityManagerController.php

This file was deleted.

74 changes: 3 additions & 71 deletions app/Listeners/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function modify(Event $event): void
{
$data = $event->getArgument('data');

$this->updateRelationMetadata($data);
$this->updateRelationshipPanels($data);

if ($this->getConfig()->get('isInstalled', false)) {
$typesData = $this->getAssetTypes();
Expand Down Expand Up @@ -83,85 +83,17 @@ protected function getAssetTypes(): array
return $assetTypes;
}

protected function updateRelationMetadata(array &$data): void
protected function updateRelationshipPanels(array &$data): void
{
$scopes = [];

foreach ($data['entityDefs'] as $scope => $defs) {
if (empty($defs['links']) || !empty($data['scopes'][$scope]['skipAssetSorting'])) {
if (empty($defs['links'])) {
continue 1;
}
foreach ($defs['links'] as $link => $linkData) {
if (!empty($linkData['entity']) && $linkData['entity'] == 'Asset') {
$data['clientDefs'][$scope]['relationshipPanels'][$link]['entityName'] = $scope;
$data['clientDefs'][$scope]['relationshipPanels'][$link]['view'] = "dam:views/record/panels/assets";

if (!empty($linkData['relationName'])) {
$data['clientDefs'][$scope]['relationshipPanels'][$link]['dragDrop'] = [
'isActive' => true,
'sortField' => 'sorting'
];

$data['clientDefs'][$scope]['relationshipPanels'][$link]['sortBy'] = 'sorting';
$data['clientDefs'][$scope]['relationshipPanels'][$link]['asc'] = true;

$data['clientDefs'][$scope]['relationshipPanels'][$link]['rowActionsView'] = "dam:views/asset/record/row-actions/relationship";

foreach (['edit', 'detail', 'detailSmall'] as $mode) {
$data['clientDefs'][$scope]['sidePanels'][$mode][] = [
'name' => 'mainImage',
'unshift' => true,
'label' => 'mainImage',
'view' => 'dam:views/asset/fields/main-image'
];
}

$data['entityDefs'][$scope]['links'][$link]['additionalColumns']['sorting'] = [
'type' => 'int'
];

$data['entityDefs'][$scope]['links'][$link]['additionalColumns']['isMainImage'] = [
'type' => 'bool'
];

$data['entityDefs'][$scope]['fields']['mainImage'] = [
'type' => 'image',
'previewSize' => 'medium',
'notStorable' => true,
'readOnly' => true,
'massUpdateDisabled' => true,
'filterDisabled' => true,
'emHidden' => true
];

$data['entityDefs'][$scope]['links']['mainImage'] = [
'type' => 'belongsTo',
'entity' => 'Attachment',
'skipOrmDefs' => true
];

$data['entityDefs'][$scope]['fields']['mainImageAddOnly'] = [
'type' => 'bool',
'notStorable' => true,
'layoutListDisabled' => true,
'layoutListSmallDisabled' => true,
'layoutDetailDisabled' => true,
'layoutDetailSmallDisabled' => true,
'massUpdateDisabled' => true,
'filterDisabled' => true,
'exportDisabled' => true,
'emHidden' => true
];
}

$scopes[] = $scope;
}
}
}

$data['entityDefs']['Asset']['fields']['sorting']['relatingEntityField'] = $scopes;
$data['entityDefs']['Asset']['fields']['isMainImage']['relatingEntityField'] = $scopes;

$data['app']['nonInheritedFields'][] = 'mainImage';
}
}
Loading

0 comments on commit ca7f6c1

Please sign in to comment.