Skip to content

Commit

Permalink
Add exportable flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon committed Dec 2, 2024
1 parent 6f557dd commit c169e2a
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(
)]
#[IsGranted(UserPermissions::DATA_OBJECTS->value)]
#[Get(
path: self::PREFIX . '/data-object/grid/available-columns/{classId}/folderId',
path: self::PREFIX . '/data-object/grid/available-columns/{classId}/{folderId}',
operationId: 'data_object_get_available_grid_columns',
description: 'data_object_get_available_grid_columns_description',
summary: 'data_object_get_available_grid_columns_summary',
Expand Down
2 changes: 2 additions & 0 deletions src/Grid/Column/Collector/Asset/MetadataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ private function getDefaultMetadata(): array
group: 'default_metadata',
sortable: true,
editable: true,
exportable: true,
localizable: true,
locale: null,
type: 'metadata.input',
Expand Down Expand Up @@ -99,6 +100,7 @@ private function getPredefinedMetadata(array $availableColumnDefinitions): array
group: 'predefined_metadata',
sortable: $availableColumnDefinitions[$type]->isSortable(),
editable: true,
exportable: $availableColumnDefinitions[$type]->isExportable(),
localizable: true,
locale: null,
type: $type,
Expand Down
1 change: 1 addition & 0 deletions src/Grid/Column/Collector/Asset/SystemFieldCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function getColumnConfigurations(array $availableColumnDefinitions): arra
group: $this->getTypeName(),
sortable: $availableColumnDefinitions[$type]->isSortable(),
editable: false,
exportable: $availableColumnDefinitions[$type]->isExportable(),
localizable: false,
locale: null,
type: $availableColumnDefinitions[$type]->getType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function getColumnConfigurations(array $availableColumnDefinitions): arra
group: $this->getTypeName(),
sortable: $availableColumnDefinitions[$type]->isSortable(),
editable: false,
exportable: $availableColumnDefinitions[$type]->isExportable(),
localizable: false,
locale: null,
type: $availableColumnDefinitions[$type]->getType(),
Expand Down
7 changes: 7 additions & 0 deletions src/Grid/Schema/ColumnConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public function __construct(
private readonly bool $sortable,
#[Property(description: 'Editable', type: 'boolean', example: false)]
private readonly bool $editable,
#[Property(description: 'Exportable', type: 'boolean', example: false)]
private readonly bool $exportable,
#[Property(description: 'Localizable', type: 'boolean', example: false)]
private readonly bool $localizable,
#[Property(description: 'Locale', type: 'string', example: 'en')]
Expand Down Expand Up @@ -82,6 +84,11 @@ public function isEditable(): bool
return $this->editable;
}

public function isExportable(): bool
{
return $this->exportable;
}

public function isLocalizable(): bool
{
return $this->localizable;
Expand Down
1 change: 1 addition & 0 deletions src/Grid/Service/ColumnConfigurationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public function buildColumnConfiguration(ColumnFieldDefinition $definition): Col
group: $definition->getGroup(),
sortable: true,
editable: !$fieldDefinition->getNoteditable(),
exportable: true,
localizable: $definition->isLocalized(),
locale: null,
type: 'dataobject.' . $fieldDefinition->getFieldType(),
Expand Down
2 changes: 1 addition & 1 deletion src/Grid/Service/GridService.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function getConfigurationFromArray(array $config, bool $isExport = false)
$columns = [];
foreach ($config as $column) {
if ($isExport && !$this->isExportable($column['type'])) {
throw new InvalidArgumentException('Column type is not exportable');
continue;
}

try {
Expand Down

0 comments on commit c169e2a

Please sign in to comment.