From 36738573f6e70f07ec3545e26c6c9111fc8e0d58 Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Wed, 17 Sep 2025 08:51:01 +0000 Subject: [PATCH] feat: enhance table row use cases with additional settings and permissions fields --- .../entities/table/table-datastructures.ts | 19 +++++++++++++++++++ .../use-cases/add-row-in-table.use.case.ts | 15 +++++++++++++++ .../get-row-by-primary-key.use.case.ts | 16 +++++++++++++++- .../use-cases/update-row-in-table.use.case.ts | 15 +++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/backend/src/entities/table/table-datastructures.ts b/backend/src/entities/table/table-datastructures.ts index 3c7faab26..4e92da800 100644 --- a/backend/src/entities/table/table-datastructures.ts +++ b/backend/src/entities/table/table-datastructures.ts @@ -3,6 +3,7 @@ import { FilterCriteriaEnum } from '../../enums/index.js'; import { TableAccessLevelsDs } from '../permission/application/data-structures/create-permissions.ds.js'; import { FoundActionEventDTO } from '../table-actions/table-action-rules-module/application/dto/found-action-rules-with-actions-and-events.dto.js'; import { TableWidgetRO } from '../widget/table-widget.interface.js'; +import { TableSettingsInRowsDS } from './application/data-structures/found-table-rows.ds.js'; export class FilteringFieldsDs { @ApiProperty() @@ -155,9 +156,15 @@ export class TableRowRODs { @ApiProperty({ isArray: true }) list_fields: Array; + @ApiProperty({ isArray: true }) + excluded_fields: Array; + @ApiProperty({ isArray: true, type: FoundActionEventDTO }) action_events?: Array; + @ApiProperty({ isArray: true, type: FoundActionEventDTO }) + table_actions?: Array; + @ApiProperty() identity_column: string; @@ -169,4 +176,16 @@ export class TableRowRODs { @ApiProperty({ isArray: true, type: ReferencedTableNamesAndColumnsDs }) referenced_table_names_and_columns: Array; + + @ApiProperty() + can_delete: boolean; + + @ApiProperty() + can_update: boolean; + + @ApiProperty() + can_add: boolean; + + @ApiProperty({ type: TableSettingsInRowsDS }) + table_settings: TableSettingsInRowsDS; } diff --git a/backend/src/entities/table/use-cases/add-row-in-table.use.case.ts b/backend/src/entities/table/use-cases/add-row-in-table.use.case.ts index b8a818cc8..37d9d30cf 100644 --- a/backend/src/entities/table/use-cases/add-row-in-table.use.case.ts +++ b/backend/src/entities/table/use-cases/add-row-in-table.use.case.ts @@ -226,6 +226,21 @@ export class AddRowInTableUseCase extends AbstractUseCase 0 ? tableSettings.list_fields : [], identity_column: tableSettings?.identity_column ? tableSettings.identity_column : null, referenced_table_names_and_columns: referencedTableNamesAndColumnsWithTablesDisplayNames, + excluded_fields: tableSettings?.excluded_fields ? tableSettings.excluded_fields : [], + can_delete: tableSettings ? tableSettings.can_delete : true, + can_update: tableSettings ? tableSettings.can_update : true, + can_add: tableSettings ? tableSettings.can_add : true, + table_settings: { + sortable_by: tableSettings?.sortable_by?.length > 0 ? tableSettings.sortable_by : [], + ordering: tableSettings?.ordering ? tableSettings.ordering : undefined, + identity_column: tableSettings?.identity_column ? tableSettings.identity_column : null, + list_fields: tableSettings?.list_fields?.length > 0 ? tableSettings.list_fields : [], + allow_csv_export: tableSettings ? tableSettings.allow_csv_export : true, + allow_csv_import: tableSettings ? tableSettings.allow_csv_import : true, + can_delete: tableSettings ? tableSettings.can_delete : true, + can_update: tableSettings ? tableSettings.can_update : true, + can_add: tableSettings ? tableSettings.can_add : true, + }, }; } } catch (e) { diff --git a/backend/src/entities/table/use-cases/get-row-by-primary-key.use.case.ts b/backend/src/entities/table/use-cases/get-row-by-primary-key.use.case.ts index 215438b2a..0bb6d0c7e 100644 --- a/backend/src/entities/table/use-cases/get-row-by-primary-key.use.case.ts +++ b/backend/src/entities/table/use-cases/get-row-by-primary-key.use.case.ts @@ -224,7 +224,21 @@ export class GetRowByPrimaryKeyUseCase display_name: tableSettings?.display_name ? tableSettings.display_name : null, table_access_level: tableAccessLevel.accessLevel, excluded_fields: tableSettings?.excluded_fields ? tableSettings.excluded_fields : [], - } as any; + can_delete: tableSettings ? tableSettings.can_delete : true, + can_update: tableSettings ? tableSettings.can_update : true, + can_add: tableSettings ? tableSettings.can_add : true, + table_settings: { + sortable_by: tableSettings?.sortable_by?.length > 0 ? tableSettings.sortable_by : [], + ordering: tableSettings?.ordering ? tableSettings.ordering : undefined, + identity_column: tableSettings?.identity_column ? tableSettings.identity_column : null, + list_fields: tableSettings?.list_fields?.length > 0 ? tableSettings.list_fields : [], + allow_csv_export: tableSettings ? tableSettings.allow_csv_export : true, + allow_csv_import: tableSettings ? tableSettings.allow_csv_import : true, + can_delete: tableSettings ? tableSettings.can_delete : true, + can_update: tableSettings ? tableSettings.can_update : true, + can_add: tableSettings ? tableSettings.can_add : true, + }, + }; } private async attachForeignColumnNames( diff --git a/backend/src/entities/table/use-cases/update-row-in-table.use.case.ts b/backend/src/entities/table/use-cases/update-row-in-table.use.case.ts index ac0dfb6b8..e5a45e362 100644 --- a/backend/src/entities/table/use-cases/update-row-in-table.use.case.ts +++ b/backend/src/entities/table/use-cases/update-row-in-table.use.case.ts @@ -283,6 +283,21 @@ export class UpdateRowInTableUseCase list_fields: tableSettings?.list_fields?.length > 0 ? tableSettings.list_fields : [], identity_column: tableSettings?.identity_column ? tableSettings.identity_column : null, referenced_table_names_and_columns: referencedTableNamesAndColumnsWithTablesDisplayNames, + excluded_fields: tableSettings?.excluded_fields ? tableSettings.excluded_fields : [], + can_delete: tableSettings ? tableSettings.can_delete : true, + can_update: tableSettings ? tableSettings.can_update : true, + can_add: tableSettings ? tableSettings.can_add : true, + table_settings: { + sortable_by: tableSettings?.sortable_by?.length > 0 ? tableSettings.sortable_by : [], + ordering: tableSettings?.ordering ? tableSettings.ordering : undefined, + identity_column: tableSettings?.identity_column ? tableSettings.identity_column : null, + list_fields: tableSettings?.list_fields?.length > 0 ? tableSettings.list_fields : [], + allow_csv_export: tableSettings ? tableSettings.allow_csv_export : true, + allow_csv_import: tableSettings ? tableSettings.allow_csv_import : true, + can_delete: tableSettings ? tableSettings.can_delete : true, + can_update: tableSettings ? tableSettings.can_update : true, + can_add: tableSettings ? tableSettings.can_add : true, + }, }; } catch (e) { operationResult = OperationResultStatusEnum.unsuccessfully;