From 2d8beaeabdbc10da40e9d5d16f24937fda632678 Mon Sep 17 00:00:00 2001 From: mattamon Date: Thu, 9 Jan 2025 15:56:03 +0100 Subject: [PATCH 1/6] Add permissions and locked status to grid items --- src/Grid/Service/GridService.php | 2 ++ src/Response/Element.php | 7 ++++++- src/Response/ElementInterface.php | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Grid/Service/GridService.php b/src/Grid/Service/GridService.php index 10efba92..38f26f2d 100644 --- a/src/Grid/Service/GridService.php +++ b/src/Grid/Service/GridService.php @@ -108,6 +108,8 @@ public function getGridDataForElement( ); $data['columns'][] = $columnData; + $data['isLocked'] = $element->getIsLocked(); + $data['permissions'] = $element->getPermissions(); } return $data; diff --git a/src/Response/Element.php b/src/Response/Element.php index fd8e1f8f..a13f5030 100644 --- a/src/Response/Element.php +++ b/src/Response/Element.php @@ -18,6 +18,7 @@ use OpenApi\Attributes\Property; use OpenApi\Attributes\Schema; +use Pimcore\Bundle\StudioBackendBundle\Element\Schema\Permissions; /** * @internal @@ -34,7 +35,6 @@ 'isLocked', 'creationDate', 'modificationDate', - 'permissions', ], type: 'object' )] @@ -113,4 +113,9 @@ public function getIsLocked(): bool { return $this->isLocked; } + + public function getPermissions(): Permissions + { + return new Permissions(); + } } diff --git a/src/Response/ElementInterface.php b/src/Response/ElementInterface.php index 37cd3ea4..f0ef8225 100644 --- a/src/Response/ElementInterface.php +++ b/src/Response/ElementInterface.php @@ -16,6 +16,8 @@ namespace Pimcore\Bundle\StudioBackendBundle\Response; +use Pimcore\Bundle\StudioBackendBundle\Element\Schema\Permissions; + /** * @internal */ @@ -40,4 +42,6 @@ public function getUserOwner(): int; public function getLocked(): ?string; public function getIsLocked(): bool; + + public function getPermissions(): Permissions; } From b5648f6205929a77fce58b195e26b3d5f1db4f7f Mon Sep 17 00:00:00 2001 From: mattamon Date: Thu, 9 Jan 2025 15:59:33 +0100 Subject: [PATCH 2/6] Readd permissions --- src/Response/Element.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Response/Element.php b/src/Response/Element.php index a13f5030..164ba8a2 100644 --- a/src/Response/Element.php +++ b/src/Response/Element.php @@ -35,6 +35,7 @@ 'isLocked', 'creationDate', 'modificationDate', + 'permissions' ], type: 'object' )] From 0af1cfddd51403527d00edeaccf8c1fce9d00901 Mon Sep 17 00:00:00 2001 From: mattamon Date: Thu, 9 Jan 2025 15:00:18 +0000 Subject: [PATCH 3/6] Apply php-cs-fixer changes --- src/Response/Element.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Response/Element.php b/src/Response/Element.php index 164ba8a2..8c78ecef 100644 --- a/src/Response/Element.php +++ b/src/Response/Element.php @@ -35,7 +35,7 @@ 'isLocked', 'creationDate', 'modificationDate', - 'permissions' + 'permissions', ], type: 'object' )] From b38fdffb88c30a1bcd5886e83fa4af6c3ded5588 Mon Sep 17 00:00:00 2001 From: mattamon Date: Fri, 10 Jan 2025 10:51:15 +0100 Subject: [PATCH 4/6] Add properties to gridcollection response --- src/Grid/Attribute/Property/GridCollection.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Grid/Attribute/Property/GridCollection.php b/src/Grid/Attribute/Property/GridCollection.php index 3e24995d..3d6fb4b3 100644 --- a/src/Grid/Attribute/Property/GridCollection.php +++ b/src/Grid/Attribute/Property/GridCollection.php @@ -18,6 +18,7 @@ use OpenApi\Attributes\Items; use OpenApi\Attributes\Property; +use Pimcore\Bundle\StudioBackendBundle\Element\Schema\Permissions; use Pimcore\Bundle\StudioBackendBundle\Grid\Schema\ColumnData; /** @@ -37,6 +38,16 @@ public function __construct() type: 'array', items: new Items(ref: ColumnData::class), ), + new Property( + property: 'isLocked', + type: 'bool' + ), + new Property( + property: 'permissions', + ref: Permissions::class, + type: 'object' + ), + ] ) ); From b6328237b39e2b0888dc6955671add73e7b0091b Mon Sep 17 00:00:00 2001 From: mattamon Date: Fri, 10 Jan 2025 12:00:39 +0100 Subject: [PATCH 5/6] Add id and set everything required --- src/Grid/Attribute/Property/GridCollection.php | 5 +++++ src/Grid/Service/GridService.php | 1 + 2 files changed, 6 insertions(+) diff --git a/src/Grid/Attribute/Property/GridCollection.php b/src/Grid/Attribute/Property/GridCollection.php index 3d6fb4b3..782542da 100644 --- a/src/Grid/Attribute/Property/GridCollection.php +++ b/src/Grid/Attribute/Property/GridCollection.php @@ -30,8 +30,13 @@ public function __construct() { parent::__construct( property: 'items', + required: ['id', 'columns', 'isLocked', 'permissions'], type: 'array', items: new Items( + new Property( + property: 'id', + type: 'integer', + ), properties: [ new Property( property: 'columns', diff --git a/src/Grid/Service/GridService.php b/src/Grid/Service/GridService.php index 38f26f2d..6bc0d31d 100644 --- a/src/Grid/Service/GridService.php +++ b/src/Grid/Service/GridService.php @@ -107,6 +107,7 @@ public function getGridDataForElement( GridColumnDataEvent::EVENT_NAME ); + $data['id'] = $element->getId(); $data['columns'][] = $columnData; $data['isLocked'] = $element->getIsLocked(); $data['permissions'] = $element->getPermissions(); From 6287ac80747feb39156025a90d916be3c2ed4723 Mon Sep 17 00:00:00 2001 From: mattamon Date: Fri, 10 Jan 2025 12:15:38 +0100 Subject: [PATCH 6/6] Fix properties --- src/Grid/Attribute/Property/GridCollection.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Grid/Attribute/Property/GridCollection.php b/src/Grid/Attribute/Property/GridCollection.php index 782542da..9e58359a 100644 --- a/src/Grid/Attribute/Property/GridCollection.php +++ b/src/Grid/Attribute/Property/GridCollection.php @@ -33,11 +33,11 @@ public function __construct() required: ['id', 'columns', 'isLocked', 'permissions'], type: 'array', items: new Items( - new Property( - property: 'id', - type: 'integer', - ), properties: [ + new Property( + property: 'id', + type: 'integer', + ), new Property( property: 'columns', type: 'array',