Skip to content

Commit

Permalink
Fixes #18: NAME without "//" is misalinged and breaks the layout
Browse files Browse the repository at this point in the history
  • Loading branch information
magicsunday committed Dec 13, 2021
1 parent 2f5e651 commit 5b5df75
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion resources/js/descendants-chart.min.js

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions resources/js/modules/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,14 @@ export default class Tree
this.addFirstNames(text1, datum);
this.addLastNames(text2, datum);

if (!datum.data.firstNames.length
&& !datum.data.lastNames.length
) {
// If both first and last names are empty, add the full name as alternative
text1.append("tspan")
.text(datum.data.name);
}

this.truncateNames(text1);
this.truncateNames(text2);

Expand All @@ -640,6 +648,15 @@ export default class Tree

this.addFirstNames(text1, datum);
this.addLastNames(text1, datum, 0.25);

if (!datum.data.firstNames.length
&& !datum.data.lastNames.length
) {
// If both first and last names are empty, add the full name as alternative
text1.append("tspan")
.text(datum.data.name);
}

this.truncateNames(text1);
}
}
Expand Down
15 changes: 8 additions & 7 deletions src/Traits/IndividualTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,30 @@ trait IndividualTrait
*
* @var string
*/
private $xpathFirstNames = '//text()[following::span[@class="SURN"]][normalize-space()]';
private $xpathFirstNames
= '//span[@class="NAME"]//text()[parent::*[not(@class="wt-nickname")]][following::span[@class="SURN"]]';

/**
* The XPath identifier to extract the last name parts.
* The XPath identifier to extract the last name parts (surname + surname suffix).
*
* @var string
*/
private $xpathLastNames
= '//text()[parent::*[not(@class="wt-nickname")]][not(following::span[@class="SURN"])][normalize-space()]';
= '//span[@class="NAME"]//span[@class="SURN"]/text()|//span[@class="SURN"]/following::text()';

/**
* The XPath identifier to extract the nick name part.
* The XPath identifier to extract the nickname part.
*
* @var string
*/
private $xpathNickname = '//q[@class="wt-nickname"]';
private $xpathNickname = '//span[@class="NAME"]//q[@class="wt-nickname"]/text()';

/**
* The XPath identifier to extract the starred name part.
*
* @var string
*/
private $xpathPreferredName = '//span[@class="starredname"]';
private $xpathPreferredName = '//span[@class="NAME"]//span[@class="starredname"]/text()';

/**
* The XPath identifier to extract the alternative name parts.
Expand All @@ -65,7 +66,7 @@ trait IndividualTrait
* @param Individual $individual The current individual
* @param int $generation The generation the person belongs to
*
* @return array<string, string|int|bool|string[]>
* @return array<string, array<string>|bool|int|string>
*/
private function getIndividualData(Individual $individual, int $generation): array
{
Expand Down
5 changes: 0 additions & 5 deletions src/Traits/ModuleCustomTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public function customModuleLatestVersionUrl(): string
return self::CUSTOM_LATEST_VERSION;
}

/**
* Fetch the latest version of this module.
*
* @return string
*/
public function customModuleLatestVersion(): string
{
// No update URL provided.
Expand Down

0 comments on commit 5b5df75

Please sign in to comment.