8000 Fix table column tooltip typecast by mkrecek234 · Pull Request #2076 · atk4/ui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix table column tooltip typecast #2076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 14, 2025
Merged
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
2 changes: 1 addition & 1 deletion src/Table/Column/Tooltip.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getDataCellHtml(?Field $field = null, array $attr = []): string
public function getHtmlTags(Model $row, ?Field $field): array
{
// @TODO remove popup tooltip when null
$tooltip = $row->get($this->tooltipField);
$tooltip = $this->getApp()->uiPersistence->typecastSaveField($row->getField($this->tooltipField), $row->get($this->tooltipField));

if ($tooltip === null || $tooltip === '') {
return [
Expand Down
16 changes: 9 additions & 7 deletions tests/Table/Column/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class LinkTest extends TestCase
use CreateAppTrait;
use TableTestTrait;

private const NBSP = "\u{00a0}";

/** @var Table */
protected $table;

Expand All @@ -26,14 +28,14 @@ protected function setUp(): void

$arr = [
'table' => [
1 => ['id' => 1, 'name' => 'bar', 'ref' => 'ref123', 'salary' => -123],
1 => ['id' => 1, 'name' => 'bar', 'ref' => 'ref123', 'salary' => -1234],
],
];
$db = new Persistence\Array_($arr);
$m = new Model($db, ['table' => 'table']);
$m->addField('name');
$m->addField('ref');
$m->addField('salary');
$m->addField('salary', ['type' => 'integer']);
$this->table = new Table();
$this->table->setApp($this->createApp());
$this->table->invokeInit();
Expand Down Expand Up @@ -72,7 +74,7 @@ public function testTdLast(): void
);

self::assertSame(
'<tr data-id="1"><td>bar</td><td>ref123</td><td class="right aligned single line negative">-123</td></tr>',
'<tr data-id="1"><td>bar</td><td>ref123</td><td class="right aligned single line negative">-1' . self::NBSP . '234</td></tr>',
$this->extractTableRow($this->table)
);
}
Expand All @@ -88,7 +90,7 @@ public function testTdNotLast(): void
);

self::assertSame(
'<tr data-id="1"><td>bar</td><td>ref123</td><td class="right aligned single line negative"><b>-123</b></td></tr>',
'<tr data-id="1"><td>bar</td><td>ref123</td><td class="right aligned single line negative"><b>-1' . self::NBSP . '234</b></td></tr>',
$this->extractTableRow($this->table)
);
}
Expand All @@ -105,7 +107,7 @@ public function testTwoMoneys(): void
);

self::assertSame(
'<tr data-id="1"><td class="right aligned single line ">bar</td><td>ref123</td><td class="right aligned single line negative"><b>-123</b></td></tr>',
'<tr data-id="1"><td class="right aligned single line ">bar</td><td>ref123</td><td class="right aligned single line negative"><b>-1' . self::NBSP . '234</b></td></tr>',
$this->extractTableRow($this->table)
);
}
Expand Down Expand Up @@ -278,10 +280,10 @@ public function testNoValue(): void

public function testTooltip(): void
{
$this->table->addDecorator('name', [Table\Column\Tooltip::class, ['tooltipField' => 'ref']]);
$this->table->addDecorator('name', [Table\Column\Tooltip::class, ['tooltipField' => 'salary']]);

self::assertSame(
'<tr data-id="1"><td class=""> bar<span class="ui icon link " data-tooltip="ref123"><i class="ui icon info circle"></span></td><td>ref123</td></tr>',
'<tr data-id="1"><td class=""> bar<span class="ui icon link " data-tooltip="-1' . self::NBSP . '234"><i class="ui icon info circle"></span></td><td>ref123</td></tr>',
$this->extractTableRow($this->table)
);
}
Expand Down
Loading
0