From 77b47e31e3b68d0ac4acc5d29d0b7357ff450342 Mon Sep 17 00:00:00 2001 From: Greg Roach Date: Fri, 14 May 2021 21:46:35 +0100 Subject: Fix: #3891 - link census seletor to new GEDCOM elements --- app/Elements/Census.php | 37 +++++++++++++++++++ app/Elements/PlaceName.php | 8 +++++ .../modules/GEDFact_assistant/select-census.phtml | 27 +++++++------- resources/views/modules/census-assistant.phtml | 42 +++++++++++++++------- 4 files changed, 89 insertions(+), 25 deletions(-) diff --git a/app/Elements/Census.php b/app/Elements/Census.php index 772bb2edfe..c47af37ba6 100644 --- a/app/Elements/Census.php +++ b/app/Elements/Census.php @@ -19,6 +19,15 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Elements; +use Fisharebest\Webtrees\Census\Census as Censuses; +use Fisharebest\Webtrees\I18N; +use Fisharebest\Webtrees\Individual; +use Fisharebest\Webtrees\Module\CensusAssistantModule; +use Fisharebest\Webtrees\Registry; +use Fisharebest\Webtrees\Services\ModuleService; +use Fisharebest\Webtrees\Tree; +use Psr\Http\Message\ServerRequestInterface; + /** * Census */ @@ -33,4 +42,32 @@ class Census extends AbstractElement 'SOUR' => '0:M', 'RESN' => '0:1', ]; + + /** + * An edit control for this data. + * + * @param string $id + * @param string $name + * @param string $value + * @param Tree $tree + * + * @return string + */ + public function edit(string $id, string $name, string $value, Tree $tree): string + { + $html = $this->editHidden($id, $name, $value) . view('modules/GEDFact_assistant/select-census', [ + 'census_places' => Censuses::censusPlaces(I18N::languageTag()), + ]); + + $xref=app(ServerRequestInterface::class)->getAttribute('xref', ''); + + $census_assistant = app(ModuleService::class)->findByInterface(CensusAssistantModule::class)->first(); + $record = Registry::individualFactory()->make($xref, $tree); + + if ($census_assistant instanceof CensusAssistantModule && $record instanceof Individual) { + $html .= $census_assistant->createCensusAssistant($record); + } + + return $html; + } } diff --git a/app/Elements/PlaceName.php b/app/Elements/PlaceName.php index a4e140fa70..0b20ab80c3 100644 --- a/app/Elements/PlaceName.php +++ b/app/Elements/PlaceName.php @@ -35,6 +35,14 @@ use function route; */ class PlaceName extends AbstractElement { + protected const SUBTAGS = [ + 'FORM' => '0:1', + 'MAP' => '0:1', + 'FONE' => '0:1', + 'ROMN' => '0:1', + 'NOTE' => '0:M', + ]; + /** * Convert a value to a canonical form. * diff --git a/resources/views/modules/GEDFact_assistant/select-census.phtml b/resources/views/modules/GEDFact_assistant/select-census.phtml index a758840bcf..a7d98926ef 100644 --- a/resources/views/modules/GEDFact_assistant/select-census.phtml +++ b/resources/views/modules/GEDFact_assistant/select-census.phtml @@ -10,23 +10,13 @@ use Fisharebest\Webtrees\I18N; ?> - - - allCensusDates() as $census) : ?> - + + diff --git a/resources/views/modules/census-assistant.phtml b/resources/views/modules/census-assistant.phtml index 1f4cacd7ac..974aa2ebf1 100644 --- a/resources/views/modules/census-assistant.phtml +++ b/resources/views/modules/census-assistant.phtml @@ -10,14 +10,14 @@ use Fisharebest\Webtrees\View; ?> -