Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/Db/Row2Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,10 @@ private function parseEntities(IResult $result, array $sleeves): array {

$column = $this->columnMapper->find($rowData['column_id']);
$columnType = $column->getType();
$cellClassName = 'OCA\Tables\Db\RowCell' . ucfirst($columnType);
$entity = call_user_func($cellClassName . '::fromRowData', $rowData); // >5.2.3
if (!isset($cellMapperCache[$columnType])) {
$cellMapperCache[$columnType] = $this->getCellMapperFromType($columnType);
}
$value = $cellMapperCache[$columnType]->formatEntity($column, $entity);
$value = $cellMapperCache[$columnType]->formatRowData($column, $rowData);
$compositeKey = (string)$rowData['row_id'] . ',' . (string)$rowData['column_id'];
if ($cellMapperCache[$columnType]->hasMultipleValues()) {
if (array_key_exists($compositeKey, $rowValues)) {
Expand Down
8 changes: 4 additions & 4 deletions lib/Db/RowCellMapperSuper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public function __construct(IDBConnection $db, string $table, string $class) {
}

/**
* Format a row cell entity to API response array
* Format a row cell raw value from DB to API response array
*
* @param T $cell
* @param array<string, mixed> $row
* @return TOutgoing
*/
public function formatEntity(Column $column, RowCellSuper $cell) {
public function formatRowData(Column $column, array $row) {
/** @var TOutgoing $value */
$value = $cell->getValue();
$value = $row['value'];
return $value;
}
/*
Expand Down
8 changes: 4 additions & 4 deletions lib/Db/RowCellNumberMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ public function __construct(IDBConnection $db) {
parent::__construct($db, $this->table, RowCellNumber::class);
}

public function formatEntity(Column $column, RowCellSuper $cell) {
$value = $cell->getValue();
public function formatRowData(Column $column, array $row) {
$value = $row['value'];
if ($value === '') {
return null;
}
$decimals = $column->getNumberDecimals() ?? 0;
if ($decimals === 0) {
return (int)$value;
} else {
return round(floatval($value), $decimals);
}

return round(floatval($value), $decimals);
}

public function applyDataToEntity(Column $column, RowCellSuper $cell, $data): void {
Expand Down
4 changes: 2 additions & 2 deletions lib/Db/RowCellSelectionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public function applyDataToEntity(Column $column, RowCellSuper $cell, $data): vo
$cell->setValue($this->valueToJsonDbValue($column, $data));
}

public function formatEntity(Column $column, RowCellSuper $cell) {
return json_decode($cell->getValue());
public function formatRowData(Column $column, array $row) {
return json_decode($row['value']);
}

private function valueToJsonDbValue(Column $column, $value): string {
Expand Down
22 changes: 12 additions & 10 deletions lib/Db/RowCellUsergroupMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,20 @@ public function applyDataToEntity(Column $column, RowCellSuper $cell, $data): vo
$cell->setValueWrapper($data);
}

public function formatEntity(Column $column, RowCellSuper $cell) {
$displayName = $cell->getValue();
if ($cell->getValueType() === UsergroupType::USER) {
$displayName = $this->userManager->getDisplayName($cell->getValue()) ?? $cell->getValue();
} elseif ($cell->getValueType() === UsergroupType::CIRCLE) {
$displayName = $this->circleHelper->getCircleDisplayName($cell->getValue(), ($this->userSession->getUser()?->getUID() ?: '')) ?: $cell->getValue();
} elseif ($cell->getValueType() === UsergroupType::GROUP) {
$displayName = $this->groupHelper->getGroupDisplayName($cell->getValue()) ?: $cell->getValue();
public function formatRowData(Column $column, array $row) {
$value = $row['value'];
$valueType = (int)$row['value_type'];
$displayName = $value;
if ($valueType === UsergroupType::USER) {
$displayName = $this->userManager->getDisplayName($value) ?? $value;
} elseif ($valueType === UsergroupType::CIRCLE) {
$displayName = $this->circleHelper->getCircleDisplayName($value, ($this->userSession->getUser()?->getUID() ?: '')) ?: $value;
} elseif ($valueType === UsergroupType::GROUP) {
$displayName = $this->groupHelper->getGroupDisplayName($value) ?: $value;
}
return [
'id' => $cell->getValue(),
'type' => $cell->getValueType(),
'id' => $value,
'type' => $valueType,
'displayName' => $displayName,
];
}
Expand Down
Loading