Skip to content

Commit

Permalink
Fix: sortable column alignment - workaround for DataTables #306
Browse files Browse the repository at this point in the history
  • Loading branch information
fisharebest committed Nov 29, 2024
1 parent 870e290 commit 4f95be3
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 187 deletions.
160 changes: 2 additions & 158 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1417,13 +1417,13 @@ parameters:
path: app/GedcomRecord.php

-
message: '#^Strict comparison using \!\=\= between non\-empty\-string and '''' will always evaluate to true\.$#'
message: '#^Strict comparison using \!\=\= between lowercase\-string&non\-falsy\-string and '''' will always evaluate to true\.$#'
identifier: notIdentical.alwaysTrue
count: 1
path: app/GedcomRecord.php

-
message: '#^Strict comparison using \!\=\= between non\-falsy\-string and '''' will always evaluate to true\.$#'
message: '#^Strict comparison using \!\=\= between non\-empty\-string and '''' will always evaluate to true\.$#'
identifier: notIdentical.alwaysTrue
count: 1
path: app/GedcomRecord.php
Expand Down Expand Up @@ -11532,78 +11532,12 @@ parameters:
count: 1
path: resources/views/modules/recent_changes/changes-list.phtml

-
message: '#^Access to an undefined property object\:\:\$record\.$#'
identifier: property.notFound
count: 12
path: resources/views/modules/recent_changes/changes-table.phtml

-
message: '#^Access to an undefined property object\:\:\$time\.$#'
identifier: property.notFound
count: 2
path: resources/views/modules/recent_changes/changes-table.phtml

-
message: '#^Access to an undefined property object\:\:\$user\.$#'
identifier: property.notFound
count: 1
path: resources/views/modules/recent_changes/changes-table.phtml

-
message: '#^Cannot call method fullName\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: resources/views/modules/recent_changes/changes-table.phtml

-
message: '#^Cannot call method sortName\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: resources/views/modules/recent_changes/changes-table.phtml

-
message: '#^Cannot call method tag\(\) on mixed\.$#'
identifier: method.nonObject
count: 9
path: resources/views/modules/recent_changes/changes-table.phtml

-
message: '#^Cannot call method timestamp\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: resources/views/modules/recent_changes/changes-table.phtml

-
message: '#^Cannot call method url\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: resources/views/modules/recent_changes/changes-table.phtml

-
message: '#^Cannot call method userName\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: resources/views/modules/recent_changes/changes-table.phtml

-
message: '#^Parameter \#1 \$value of function e expects Illuminate\\Contracts\\Support\\DeferringDisplayableValue\|Illuminate\\Contracts\\Support\\Htmlable\|string\|null, int given\.$#'
identifier: argument.type
count: 1
path: resources/views/modules/recent_changes/changes-table.phtml

-
message: '#^Parameter \#1 \$value of function e expects Illuminate\\Contracts\\Support\\DeferringDisplayableValue\|Illuminate\\Contracts\\Support\\Htmlable\|string\|null, mixed given\.$#'
identifier: argument.type
count: 3
path: resources/views/modules/recent_changes/changes-table.phtml

-
message: '#^Parameter \#1 \(mixed\) of echo cannot be converted to string\.$#'
identifier: echo.nonString
count: 3
path: resources/views/modules/recent_changes/changes-table.phtml

-
message: '#^Parameter \#1 \$value of function e expects Illuminate\\Contracts\\Support\\DeferringDisplayableValue\|Illuminate\\Contracts\\Support\\Htmlable\|string\|null, int given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -12084,102 +12018,12 @@ parameters:
count: 1
path: resources/views/modules/yahrzeit/list.phtml

-
message: '#^Access to an undefined property object\:\:\$fact\.$#'
identifier: property.notFound
count: 2
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Access to an undefined property object\:\:\$fact_date\.$#'
identifier: property.notFound
count: 1
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Access to an undefined property object\:\:\$individual\.$#'
identifier: property.notFound
count: 7
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Access to an undefined property object\:\:\$yahrzeit_date\.$#'
identifier: property.notFound
count: 3
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Cannot access property \$anniv on mixed\.$#'
identifier: property.nonObject
count: 2
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Cannot call method alternateName\(\) on mixed\.$#'
identifier: method.nonObject
count: 2
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Cannot call method display\(\) on mixed\.$#'
identifier: method.nonObject
count: 2
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Cannot call method fullName\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Cannot call method julianDay\(\) on mixed\.$#'
identifier: method.nonObject
count: 2
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Cannot call method sortName\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Cannot call method tree\(\) on mixed\.$#'
identifier: method.nonObject
count: 2
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Cannot call method url\(\) on mixed\.$#'
identifier: method.nonObject
count: 1
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Parameter \#1 \$n of static method Fisharebest\\Webtrees\\I18N\:\:number\(\) expects float, mixed given\.$#'
identifier: argument.type
count: 1
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Parameter \#1 \$value of function e expects Illuminate\\Contracts\\Support\\DeferringDisplayableValue\|Illuminate\\Contracts\\Support\\Htmlable\|string\|null, int given\.$#'
identifier: argument.type
count: 1
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Parameter \#1 \$value of function e expects Illuminate\\Contracts\\Support\\DeferringDisplayableValue\|Illuminate\\Contracts\\Support\\Htmlable\|string\|null, mixed given\.$#'
identifier: argument.type
count: 5
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Parameter \#1 \(mixed\) of echo cannot be converted to string\.$#'
identifier: echo.nonString
count: 4
path: resources/views/modules/yahrzeit/table.phtml

-
message: '#^Access to an undefined property object\:\:\$change_id\.$#'
identifier: property.notFound
Expand Down
4 changes: 2 additions & 2 deletions resources/views/lists/anniversaries-table.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ use Illuminate\Support\Collection;
<small><?= view('icons/sex', ['sex' => $record->sex()]) ?></small>
<?php endif ?>
</td>
<td data-sort="<?= $fact->jd + $fact->anniv / 10000.0 ?>">
<td data-sort="<?= sprintf('x%07d', $fact->jd + $fact->anniv / 10000.0) ?>">
<?= $fact->date()->display($record->tree(), null, true) ?>
</td>
<td data-sort="<?= $fact->anniv ?>">
<td data-sort="<?= sprintf('x%07d', $fact->anniv) ?>">
<?= $fact->anniv ?>
</td>
<td data-sort="<?= $fact->label() ?>">
Expand Down
4 changes: 2 additions & 2 deletions resources/views/lists/families-table.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ $("#<?= e($table_id) ?>")
</td>

<!-- Marriage date -->
<td data-sort="<?= $family->getMarriageDate()->julianDay() ?>">
<td data-sort="<?= sprintf('x%07d', $family->getMarriageDate()->julianDay()) ?>">
<?php if ($marriage_dates = $family->getAllMarriageDates()) : ?>
<?php foreach ($marriage_dates as $marriage_date) : ?>
<div><?= $marriage_date->display($tree, null, true) ?></div>
Expand Down Expand Up @@ -254,7 +254,7 @@ $("#<?= e($table_id) ?>")
</td>

<!-- Last change -->
<td data-sort="<?= $family->lastChangeTimestamp()->timestamp() ?>">
<td data-sort="<?= sprintf('x%07d', $family->lastChangeTimestamp()->timestamp()) ?>">
<?= view('components/datetime', ['timestamp' => $family->lastChangeTimestamp()]) ?>
</td>

Expand Down
7 changes: 3 additions & 4 deletions resources/views/lists/individuals-table.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ $("#<?= e($table_id) ?>")
<!-- Birthdate -->
<?php $estimated_birth_date = $individual->getEstimatedBirthDate(); ?>

<td data-sort="<?= $estimated_birth_date->julianDay() ?>">
<td data-sort="<?= sprintf('x%07d', $estimated_birth_date->julianDay()) ?>">
<?php $birth_dates = $individual->getAllBirthDates(); ?>

<?php foreach ($birth_dates as $birth_date) : ?>
Expand Down Expand Up @@ -255,7 +255,7 @@ $("#<?= e($table_id) ?>")

<!-- Death date -->
<?php $death_dates = $individual->getAllDeathDates() ?>
<td data-sort="<?= $individual->getEstimatedDeathDate()->julianDay() ?>">
<td data-sort="<?= sprintf('x%07d', $individual->getEstimatedDeathDate()->julianDay()) ?>">
<?php foreach ($death_dates as $death_date) : ?>
<div><?= $death_date->display($tree, null, true) ?></div>
<?php endforeach ?>
Expand Down Expand Up @@ -284,7 +284,7 @@ $("#<?= e($table_id) ?>")
</td>

<!-- Last change -->
<td data-sort="<?= $individual->lastChangeTimestamp()->timestamp() ?>">
<td data-sort="<?= sprintf('x%07d', $individual->lastChangeTimestamp()->timestamp()) ?>">
<?= view('components/datetime', ['timestamp' => $individual->lastChangeTimestamp()]) ?>
</td>

Expand Down Expand Up @@ -339,4 +339,3 @@ $("#<?= e($table_id) ?>")
</tfoot>
</table>
</div>

2 changes: 1 addition & 1 deletion resources/views/lists/locations-table.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ $count_families = DB::table('families')
</td>

<!-- Last change -->
<td data-sort="<?= $location->lastChangeTimestamp()->timestamp() ?>">
<td data-sort="<?= sprintf('x%07d', $location->lastChangeTimestamp()->timestamp()) ?>">
<?= view('components/datetime', ['timestamp' => $location->lastChangeTimestamp()]) ?>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/lists/media-table.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ $count_sources = DB::table('sources')
</td>

<!-- Last change -->
<td data-sort="<?= $media_object->lastChangeTimestamp()->timestamp() ?>">
<td data-sort="<?= sprintf('x%07d', $media_object->lastChangeTimestamp()->timestamp()) ?>">
<?= view('components/datetime', ['timestamp' => $media_object->lastChangeTimestamp()]) ?>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/lists/notes-table.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ $count_sources = DB::table('sources')
</td>

<!-- Last change -->
<td data-sort="<?= $note->lastChangeTimestamp()->timestamp() ?>">
<td data-sort="<?= sprintf('x%07d', $note->lastChangeTimestamp()->timestamp()) ?>">
<?= view('components/datetime', ['timestamp' => $note->lastChangeTimestamp()]) ?>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/lists/repositories-table.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ $count_sources = DB::table('sources')
</td>

<!-- Last change -->
<td data-sort="<?= $repository->lastChangeTimestamp()->timestamp() ?>">
<td data-sort="<?= sprintf('x%07d', $repository->lastChangeTimestamp()->timestamp()) ?>">
<?= view('components/datetime', ['timestamp' => $repository->lastChangeTimestamp()]) ?>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/lists/sources-table.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ $count_notes = DB::table('other')
</td>

<!-- Last change -->
<td data-sort="<?= $source->lastChangeTimestamp()->timestamp() ?>">
<td data-sort="<?= sprintf('x%07d', $source->lastChangeTimestamp()->timestamp()) ?>">
<?= view('components/datetime', ['timestamp' => $source->lastChangeTimestamp()]) ?>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/lists/submitters-table.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ $count_families = DB::table('families')
<?= I18N::number($count_families[$submitter->xref()] ?? 0) ?>
</td>

<td data-sort="<?= $submitter->lastChangeTimestamp()->timestamp() ?>">
<td data-sort="<?= sprintf('x%07d', $submitter->lastChangeTimestamp()->timestamp()) ?>">
<?= view('components/datetime', ['timestamp' => $submitter->lastChangeTimestamp()]) ?>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/lists/surnames-table.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use Fisharebest\Webtrees\Tree;
<tbody>
<?php foreach ($surnames as $surn => $surns) : ?>
<tr>
<td data-sort="<?= $n = 1 + ($n ?? 0) ?>">
<td data-sort="<?= sprintf('x%07d', $n = 1 + ($n ?? 0)) ?>">
<!-- Multiple surname variants, e.g. von Groot, van Groot, van der Groot, etc. -->
<?php foreach (array_keys($surns) as $surname) : ?>
<?php if ($module instanceof IndividualListModule) : ?>
Expand Down
17 changes: 10 additions & 7 deletions resources/views/modules/recent_changes/changes-table.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

declare(strict_types=1);

use Fisharebest\Webtrees\Contracts\UserInterface;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Location;
Expand All @@ -11,16 +13,17 @@ use Fisharebest\Webtrees\Note;
use Fisharebest\Webtrees\Repository;
use Fisharebest\Webtrees\Source;
use Fisharebest\Webtrees\Submitter;
use Fisharebest\Webtrees\Timestamp;
use Fisharebest\Webtrees\View;
use Illuminate\Support\Collection;

/**
* @var int $limit_high
* @var int $limit_low
* @var array<array<int,string>> $order
* @var Collection<int,object> $rows
* @var bool $show_date
* @var bool $show_user
* @var int $limit_high
* @var int $limit_low
* @var array<array<int,string>> $order
* @var Collection<int,object{record:GedcomRecord,time:Timestamp,user:UserInterface}> $rows
* @var bool $show_date
* @var bool $show_user
*/
?>

Expand Down Expand Up @@ -88,7 +91,7 @@ use Illuminate\Support\Collection;
<a href="<?= e($row->record->url()) ?>"><?= $row->record->fullName() ?></a>
</td>

<td data-sort="<?= $row->time->timestamp() ?>" class="<?= $show_date ? '' : 'd-none' ?>">
<td data-sort="<?= sprintf('x%07d', $row->time->timestamp()) ?>" class="<?= $show_date ? '' : 'd-none' ?>">
<?= view('components/datetime', ['timestamp' => $row->time]) ?>
</td>

Expand Down
2 changes: 1 addition & 1 deletion resources/views/modules/todo/research-tasks.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use Illuminate\Support\Collection;
<tbody>
<?php foreach ($tasks as $task) : ?>
<tr>
<td data-sort="<?= $task->date()->julianDay() ?>" class="d-none d-md-table-cell wt-side-block-optional">
<td data-sort="<?= sprintf('x%07d', $task->date()->julianDay()) ?>" class="d-none d-md-table-cell wt-side-block-optional">
<?= $task->date()->display() ?>
</td>
<td data-sort="<?= e($task->record()->sortName()) ?>">
Expand Down
Loading

0 comments on commit 4f95be3

Please sign in to comment.