Skip to content

Commit 92af03c

Browse files
committed
feat: add relation column type
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
1 parent cc96280 commit 92af03c

7 files changed

Lines changed: 15 additions & 15 deletions

File tree

lib/Controller/Api1Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ public function createRowInTable(int $tableId, $data): DataResponse {
13791379
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT)]
13801380
public function getRow(int $rowId): DataResponse {
13811381
try {
1382-
return new DataResponse($this->rowService->find($rowId, $this->userId)->jsonSerialize());
1382+
return new DataResponse($this->rowService->find($rowId)->jsonSerialize());
13831383
} catch (PermissionError $e) {
13841384
$this->logger->warning('A permission error occurred: ' . $e->getMessage(), ['exception' => $e]);
13851385
$message = ['message' => $e->getMessage()];

lib/Controller/RowController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function indexView(int $viewId): DataResponse {
4747
#[NoAdminRequired]
4848
public function show(int $id): DataResponse {
4949
return $this->handleError(function () use ($id) {
50-
return $this->service->find($id, $this->userId);
50+
return $this->service->find($id);
5151
});
5252
}
5353

lib/Db/RowCellRelation.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66

77
class RowCellRelation extends RowCellSuper {
88
protected ?int $value = null;
9-
protected ?int $valueType = null;
109

1110
public function __construct() {
1211
parent::__construct();
1312
$this->addType('value', 'integer');
1413
}
1514

1615
public function jsonSerialize(): array {
17-
return parent::jsonSerializePreparation($this->value, $this->valueType);
16+
return parent::jsonSerializePreparation($this->value);
1817
}
1918
}

lib/Db/RowCellRelationMapper.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ public function getDbParamType() {
2828
return IQueryBuilder::PARAM_INT;
2929
}
3030

31-
/**
32-
* @inheritDoc
33-
*/
34-
public function format(Column $column, ?string $value) {
31+
public function formatRowData(Column $column, array $row) {
32+
$value = $row['value'];
3533
return (int)$value;
3634
}
3735
}

lib/Migration/Version002001Date20260109000000.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
1515
/** @var ISchemaWrapper $schema */
1616
$schema = $schemaClosure();
1717

18-
$changes = $this->createRelationTable($schema, 'relation', Types::INTEGER);
18+
$changes = $this->createRowValueTable($schema, 'relation', Types::INTEGER);
1919
return $changes;
2020
}
2121

22-
private function createRelationTable(ISchemaWrapper $schema, string $name, string $type): ?ISchemaWrapper {
22+
private function createRowValueTable(ISchemaWrapper $schema, string $name, string $type): ?ISchemaWrapper {
2323
if (!$schema->hasTable('tables_row_cells_' . $name)) {
2424
$table = $schema->createTable('tables_row_cells_' . $name);
2525
$table->addColumn('id', Types::INTEGER, [

src/modules/modals/CreateColumn.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ export default {
307307
} else if (this.column.type === 'relation' && !this.column.customSettings?.relationType) {
308308
showInfo(t('tables', 'Please select a relation type.'))
309309
} else if (this.column.type === 'relation' && !this.column.customSettings?.targetId) {
310-
showInfo(t('tables', 'Please select a entity.'))
310+
showInfo(t('tables', 'Please select a target.'))
311311
} else if (this.column.type === 'relation' && !this.column.customSettings?.labelColumn) {
312-
showInfo(t('tables', 'Please select a display field.'))
312+
showInfo(t('tables', 'Please select a value selection label.'))
313313
} else {
314314
this.$emit('save', this.prepareSubmitData())
315315
if (this.isCustomSave) {

src/shared/components/ncTable/partials/columnTypePartials/forms/RelationForm.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
:aria-label-combobox="t('tables', 'Select relation type')"
1212
:disabled="column.id && column.id > 0"
1313
required
14+
:clearable="false"
1415
@input="onRelationTypeChange">
1516
<template #option="option">
1617
{{ option.label }}
@@ -21,7 +22,7 @@
2122

2223
<div class="row space-T">
2324
<div class="fix-col-4 title">
24-
{{ t('tables', 'Entity') }}
25+
{{ t('tables', 'Target') }}
2526
</div>
2627
<div class="fix-col-4">
2728
<NcSelect v-model="customSettings.targetId"
@@ -30,6 +31,7 @@
3031
:aria-label-combobox="t('tables', 'Select target')"
3132
:disabled="column.id && column.id > 0"
3233
required
34+
:clearable="false"
3335
@input="onTargetChange">
3436
<template #option="option">
3537
{{ option.emoji }} {{ option.label }}
@@ -40,15 +42,16 @@
4042

4143
<div class="row space-T">
4244
<div class="fix-col-4 title">
43-
{{ t('tables', 'Label column') }}
45+
{{ t('tables', 'Value selection label') }}
4446
</div>
4547
<div class="fix-col-4">
4648
<NcSelect v-model="customSettings.labelColumn"
4749
:options="availableLabelColumns"
4850
:reduce="(option) => option.id"
4951
:loading="loadingColumns"
50-
:aria-label-combobox="t('tables', 'Select label column')"
52+
:aria-label-combobox="t('tables', 'Select value selection label')"
5153
required
54+
:clearable="false"
5255
@input="onLabelColumnChange">
5356
<template #option="option">
5457
{{ option.label }}

0 commit comments

Comments
 (0)