Skip to content
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

P#110445 adress detailpage template #900

Merged
merged 62 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
5c8e4e0
47365 revision of the address list template
dai-eastgate Apr 25, 2024
6655e21
Merge branch 'master' of https://github.com/onOfficeGmbH/oo-wp-plugin…
yeneastgate May 6, 2024
d06e50b
47365 update content for image alt & unit test
dai-eastgate May 6, 2024
184b7e6
Merge branch 'master' into 47365-revision-of-the-address-list-template
fredericalpers May 7, 2024
07d82dd
47941 add address detail page
yeneastgate May 16, 2024
88e5909
47941 update unit test
yeneastgate May 16, 2024
ea46e52
47941 update unit test
yeneastgate May 16, 2024
c6870b6
47944 add form selection
dai-eastgate May 20, 2024
b8a0220
47945 update config show estate
dai-eastgate May 29, 2024
b574c58
47945 refactor code & update unit test
dai-eastgate May 29, 2024
3fdfeeb
Merge branch 'master' into 47365-revision-of-the-address-list-template
dai-eastgate May 29, 2024
e5e52d1
Merge branch 'master' into 47941-improvement-of-the-address-list-func…
yeneastgate May 29, 2024
a267708
47945 refactor code
dai-eastgate May 30, 2024
95d15df
47945 fix conflict
dai-eastgate Jun 6, 2024
757c366
Merge branch 'master' into 47941-improvement-of-the-address-list-func…
yeneastgate Jun 17, 2024
641216d
Merge branch 'master' into 47365-revision-of-the-address-list-template
dai-eastgate Jun 17, 2024
25812ee
Merge branch 'master' into 47944-improvement-of-the-address-list-func…
dai-eastgate Jun 17, 2024
3bf0089
Merge branch 'master' into 47945-improvement-of-the-address-list-func…
dai-eastgate Jun 17, 2024
8536328
Merge branch 'master' into 47945-improvement-of-the-address-list-func…
dai-eastgate Jun 19, 2024
9c4ff93
Merge branch 'master' into 47944-improvement-of-the-address-list-func…
dai-eastgate Jun 19, 2024
c7d3628
Merge branch 'master' into 47365-revision-of-the-address-list-template
dai-eastgate Jun 19, 2024
53395db
Merge branch 'master' into 47941-improvement-of-the-address-list-func…
yeneastgate Jun 19, 2024
db7211b
Merge branch 'master' into 47941-improvement-of-the-address-list-func…
yeneastgate Jun 19, 2024
d84e341
Merge branch 'master' into 47365-revision-of-the-address-list-template
yeneastgate Jun 21, 2024
221c59b
Merge branch 'master' into 47365-revision-of-the-address-list-template
fredericalpers Jul 23, 2024
d4b6f6d
Merge branch 'master' into 47365-revision-of-the-address-list-template
dai-eastgate Jul 26, 2024
83a5b3c
Merge branch 'master' into 47941-improvement-of-the-address-list-func…
dai-eastgate Jul 26, 2024
4773df4
Merge branch 'master' into 47944-improvement-of-the-address-list-func…
dai-eastgate Jul 26, 2024
3bfcd16
Merge branch 'master' into 47945-improvement-of-the-address-list-func…
dai-eastgate Jul 26, 2024
b7a1b8f
Merge branch 'master' into 47365-revision-of-the-address-list-template
fredericalpers Aug 22, 2024
4bc127d
Merge branch 'master' into 47941-improvement-of-the-address-list-func…
dai-eastgate Aug 22, 2024
47dab1c
Merge branch 'master' into 47944-improvement-of-the-address-list-func…
dai-eastgate Aug 22, 2024
a3d0068
Merge branch 'master' into 47945-improvement-of-the-address-list-func…
dai-eastgate Aug 26, 2024
38175cf
47945 fix conflict
dai-eastgate Aug 26, 2024
6533a6f
52295 merge add User photo
dai-eastgate Aug 26, 2024
fc8e30c
52295 merge add form selection
dai-eastgate Aug 26, 2024
b0c9bbe
52995 merge add estate list selection
dai-eastgate Aug 26, 2024
9c2cb24
52995 refactor code
dai-eastgate Aug 26, 2024
5740fb7
52295 refactor code
dai-eastgate Aug 27, 2024
4681ed2
52295 update unit test
dai-eastgate Aug 27, 2024
661025f
52295 refactor code
dai-eastgate Aug 27, 2024
a549531
Merge branch 'master' into 52295-improvement-of-the-address-list-func…
dai-eastgate Aug 27, 2024
2611ea0
render template
andernath Aug 27, 2024
bf8ed08
Merge branch '47365-revision-of-the-address-list-template' into p#110…
andernath Aug 27, 2024
36cb0be
Add test template
andernath Aug 27, 2024
c48fc8f
increase limit for Estatelist-Select in AdressDetailSettings
ingoKrOffice Aug 30, 2024
62e943b
Add AddressDetail-Logic, add estatelist in addressdetailpage, add for…
ingoKrOffice Aug 30, 2024
11a4f2b
fix tests
ingoKrOffice Sep 2, 2024
65a9388
some fixes
ingoKrOffice Sep 2, 2024
c2fddcf
remove AddressListEnvironment from AdressList
ingoKrOffice Sep 2, 2024
0f4bd6f
remove useless test
ingoKrOffice Sep 2, 2024
5252947
remove php 7.3 tests
ingoKrOffice Sep 2, 2024
42e47f0
fix tests and remove comments
ingoKrOffice Sep 2, 2024
271c63f
validate integer pageId
ingoKrOffice Sep 2, 2024
5a7d1da
prepare style sheets for address styling
andernath Sep 4, 2024
e37f948
Merge branch 'master' into p#110445-adress-detailpage-template
andernath Sep 10, 2024
35957be
Use getRows() to avoid duplicated fields with default email and phone
andernath Sep 12, 2024
c581dbb
Add image alt tag
andernath Sep 13, 2024
c0da892
Adjust styling
andernath Sep 16, 2024
f27ed69
Refactor code and merging conflicts
andernath Sep 16, 2024
21a8f09
Fix Unittests
andernath Sep 23, 2024
aa9c460
Fix styling inconsistency
andernath Sep 23, 2024
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
56 changes: 56 additions & 0 deletions css/onoffice-address-detail.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.oo-address {
display: flex;
flex-direction: column;
flex-wrap: wrap;
margin-bottom: 4rem;
}
.oo-address-name {
flex: 1 0 100%;
}
.oo-address-picture {
margin-bottom: 0.25rem;
}
.oo-address-fieldlist {
display: flex;
flex-direction: column;
}
.oo-address-placefieldlist {
display: flex;
flex-direction: column;
margin-top: 0.25rem;
margin-bottom: 0.25rem;
}
.oo-address-placefield {
font-size: 1rem;
}
.oo-address-field {
font-size: 1rem;
margin-top: 0.25rem;
margin-bottom: 0.25rem;
}
.oo-address-estatelist {
margin-bottom: 4rem;
}
.oo-address-form {
margin-bottom: 4rem;
}
@media only screen and (min-width: 960px) {
.oo-address {
flex-direction: row;
margin-bottom: 7.5rem;
}
.oo-address-picture {
flex: 1 0 50%;
padding-right: 2rem
}
.oo-address-fieldlist {
flex: 1 0 50%;
padding-left: 2rem;
}
.oo-address-estatelist {
margin-bottom: 7.5rem;
}
.oo-address-form {
margin-bottom: 7.5rem;
}
}
31 changes: 24 additions & 7 deletions plugin/AddressList.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,20 @@ public function loadAddressesById(array $addressIds, array $fields)
'outputlanguage' => Language::getDefault(),
'formatoutput' => true,
];
$parametersRaw = [
'recordids' => $addressIds,
'data' => $this->_addressParametersForImageAlt,
'outputlanguage' => Language::getDefault(),
'formatoutput' => false,
];
$pApiCall->setParameters($parameters);
$pApiCall->addRequestToQueue()->sendRequests();

$records = $pApiCall->getResultRecords();
$this->fillAddressesById($records);
$this->_pDataViewAddress->setFields($fields);

$this->addRawRecordsByAPICall(clone $pApiCall, $parametersRaw);
}

/**
Expand Down Expand Up @@ -202,12 +210,7 @@ public function loadAddresses(int $inputPage = 1)

$addressParameterRaws = $pDataListViewToApi->buildParameters($this->_addressParametersForImageAlt,
$this->_pDataViewAddress, $newPage);

$pAddressRawApiCall = clone $pApiCall;
$pAddressRawApiCall->setParameters($addressParameterRaws);
$pAddressRawApiCall->addRequestToQueue()->sendRequests();
$recordsRaw = $pAddressRawApiCall->getResultRecords();
$this->_recordsRaw = array_combine(array_column($recordsRaw, 'id'), $recordsRaw);
$this->addRawRecordsByAPICall(clone $pApiCall, $addressParameterRaws);

$this->_records = $pApiCall->getResultRecords();
$this->fillAddressesById($this->_records);
Expand All @@ -227,7 +230,7 @@ private function generateRecordModifier(): ViewFieldModifierHandler
{
$fields = $this->_pDataViewAddress->getFields();

if ($this->_pDataViewAddress->getShowPhoto()) {
if ($this->getDataViewAddress() instanceof DataListViewAddress && $this->_pDataViewAddress->getShowPhoto()) {
$fields []= 'imageUrl';
}

Expand Down Expand Up @@ -460,4 +463,18 @@ public function getCurrentAddress(): array
{
return $this->_addressesById;
}

/**
* @param APIClientActionGeneric $addressApiCall
* @param array $parameters
* @throws API\ApiClientException
*/
private function addRawRecordsByAPICall(APIClientActionGeneric $addressApiCall, array $parameters) {
$addressApiCall->setParameters($parameters);
$addressApiCall->addRequestToQueue()->sendRequests();
$recordsRaw = $addressApiCall->getResultRecords();

$this->_recordsRaw = array_combine(array_column($recordsRaw, 'id'), $recordsRaw);

}
}
17 changes: 15 additions & 2 deletions plugin/ScriptLoader/ScriptLoaderGenericConfigurationDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function getScriptLoaderGenericConfiguration(): array
$values []= (new IncludeFileModel($script, 'onoffice-favorites', plugins_url('/dist/favorites.min.js', $pluginPath)))
->setDependencies(['jquery']);
}
$values = $this->addAddressStyle($values, $style, $pluginPath);

return array_merge($values, $this->addScripts($pluginPath, $script, $style, $defer, $async));
}
Expand Down Expand Up @@ -346,11 +347,24 @@ private function extractFormNames(string $pageContent): array
return $matches[1];
}

/**
* @param array $values
* @param string $style
* @param string $pluginPath
* @return array
*/
private function addAddressStyle(array $values, string $style, string $pluginPath) {
$pageContent = get_the_content();
if ($this->isDetailAddressPage($pageContent)) {
$values []= (new IncludeFileModel($style, 'onoffice-address-detail', plugins_url('/css/onoffice-address-detail.css', $pluginPath)));
}
return $values;
}

/**
* @param array $scripts
* @param string $pluginPath
* @param string $script
* @param string $style
* @param string $defer
* @return array
*/
Expand All @@ -371,7 +385,6 @@ private function renderScriptForAddressDetailPage(array $scripts, string $plugin
* @param array $scripts
* @param string $pluginPath
* @param string $script
* @param string $style
* @param string $defer
* @return array
*/
Expand Down
134 changes: 80 additions & 54 deletions templates.dist/address/default_detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,60 +21,86 @@

use onOffice\WPlugin\AddressList;

?>

<div class="oo-detailview">
<?php
/* @var $pAddressList AddressList */
$currentAddressArr = $pAddressList->getCurrentAddress();
foreach ($currentAddressArr as $addressId => $escapedValues) {
$imageUrl = $escapedValues['imageUrl'];
unset($escapedValues['imageUrl']);
$addressName = array('Anrede', 'Titel', 'Vorname', 'Name');
$addressPlace = array('Strasse', 'Plz', 'Ort', 'Plz-Ort');
/* @var $pAddressList AddressList */
$currentAddressArr = $pAddressList->getRows();
foreach ($currentAddressArr as $addressId => $escapedValues) {
$imageUrl = $escapedValues['imageUrl'];
unset($escapedValues['imageUrl']);
?>
<div class="oo-address">
<h2 class="oo-address-name">
<?php
$fullName = '';
foreach ($addressName as $namePart) {
$fullName .= !empty($escapedValues[$namePart]) ? $escapedValues[$namePart]. ' ' : '';
}
echo substr_replace($fullName, '', -1);;
?>
</h2>
<?php
if (!empty($imageUrl)) {
$imageAlt = $pAddressList->generateImageAlt($addressId);
echo '<picture class="oo-picture oo-address-picture">';
echo '<img class="oo-responsive-image" ' .
'src="' . esc_url($imageUrl) . '" ' .
'alt="' . esc_html($imageAlt) . '" ' .
'loading="lazy"/>';
echo '</picture>';
}
?>
<div class="oo-detailsheadline">
<h1><?php echo $escapedValues['Name']; ?></h1>
<div class="oo-detailstable">
<?php
if (!empty($imageUrl)) {
echo '<img width="350" src="'.$imageUrl.'"/>';
}
foreach ($escapedValues as $field => $value) {
echo '<div class="oo-detailslisttd">' . esc_html($pAddressList->getFieldLabel($field)) . '</div>' . "\n"
. '<div class="oo-detailslisttd">'
<div class="oo-address-fieldlist">
<?php
$addressPlaceDiv = '';
foreach ($escapedValues as $field => $value) {
if (in_array($field, $addressName) || empty($value)) {
continue;
}
if (in_array($field, $addressPlace)) {
$addressPlaceDiv .= '<div class="oo-address-placefield">'
. (is_array($value) ? esc_html(implode(', ', $value)) : esc_html($value))
. '</div>';
continue;
}
echo '<div class="oo-address-field">'
. (is_array($value) ? esc_html(implode(', ', $value)) : esc_html($value))
. '</div>' . "\n";
}?>
</div>
</div>
<?php } ?>
<!--
to filter estates on address-detail-page you have to change the estate-list-template
add this in while:
if( !$pEstatesClone->isCurrentEstateContactsInAddressFilter() )
continue;
-->
<?php
$shortCodeActiveEstates = $pAddressList->getShortCodeActiveEstates();
if (!empty($shortCodeActiveEstates)) {
?>
<div class="detail-contact-form">
<?php echo do_shortcode($shortCodeActiveEstates); ?>
</div>
<?php } ?>
<?php
$shortCodeReferenceEstates = $pAddressList->getShortCodeReferenceEstates();
if (!empty($shortCodeReferenceEstates)) {
?>
<div class="detail-contact-form">
<?php echo do_shortcode($shortCodeReferenceEstates); ?>
</div>
<?php } ?>
<?php
$shortCodeForm = $pAddressList->getShortCodeForm();
if (!empty($shortCodeForm)) {
?>
<div class="detail-contact-form">
<?php echo do_shortcode($shortCodeForm); ?>
</div>
<?php } ?>
. '</div>';
}
if(!empty($addressPlaceDiv)) {
echo '<div class="oo-address-placefieldlist">'.$addressPlaceDiv.'</div>';
}
?>
</div>
</div>
<?php } ?>
<!--
to filter estates on address-detail-page you have to change the estate-list-template
add this in while:
if( !$pEstatesClone->isCurrentEstateContactsInAddressFilter() )
continue;
-->
<?php
$shortCodeActiveEstates = $pAddressList->getShortCodeActiveEstates();
if (!empty($shortCodeActiveEstates)) {
?>
<div class="oo-address-estatelist">
<?php echo do_shortcode($shortCodeActiveEstates); ?>
</div>
<?php } ?>
<?php
$shortCodeReferenceEstates = $pAddressList->getShortCodeReferenceEstates();
if (!empty($shortCodeReferenceEstates)) {
?>
<div class="oo-address-estatelist">
<?php echo do_shortcode($shortCodeReferenceEstates); ?>
</div>
<?php } ?>
<?php
$shortCodeForm = $pAddressList->getShortCodeForm();
if (!empty($shortCodeForm)) {
?>
<div class="oo-address-form">
<?php echo do_shortcode($shortCodeForm); ?>
</div>
<?php } ?>
5 changes: 2 additions & 3 deletions templates.dist/estate/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@
ul.oo-listparking {
padding: 0 10px;
}
.clear {
width: 50%;
}
</style>

<div class="oo-estate-map">
Expand All @@ -117,6 +114,8 @@
$pEstatesClone = clone $pEstates;
$pEstatesClone->resetEstateIterator();
while ( $currentEstate = $pEstatesClone->estateIterator() ) :
if( !$pEstatesClone->isCurrentEstateContactsInAddressFilter() )
continue;
$marketingStatus = $currentEstate['vermarktungsstatus'];
unset($currentEstate['vermarktungsstatus']);
$estateId = $pEstatesClone->getCurrentEstateId();
Expand Down
3 changes: 0 additions & 3 deletions templates.dist/estate/default_detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@
ul.oo-listparking {
padding: 0 10px;
}
.clear {
width: 25%;
}
</style>
<div class="oo-detailview">
<?php
Expand Down
9 changes: 9 additions & 0 deletions tests/TestClassAddressList.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ public function prepare()
'formatoutput' => false,
];

$addressParametersWithFormatDetail = [
'recordids' => [13,37],
'data' => ['contactCategory', 'Vorname', 'Name', 'Zusatz1', 'branch', 'communityOfHeirs', 'communityOfOwners', 'umbrellaOrganization', 'association', 'institution', 'department'],
'outputlanguage' => "ENG",
'formatoutput' => false,
];

$pSDKWrapper->addResponseByParameters
(onOfficeSDK::ACTION_ID_READ, 'address', '', $parameters, null, $response);
$pSDKWrapper->addResponseByParameters
Expand All @@ -140,6 +147,8 @@ public function prepare()
$addressParametersWithFormat['data'][] = 'imageUrl';
$pSDKWrapper->addResponseByParameters
(onOfficeSDK::ACTION_ID_READ, 'address', '', $addressParametersWithFormat, null, $responseRaw);
$pSDKWrapper->addResponseByParameters
(onOfficeSDK::ACTION_ID_READ, 'address', '', $addressParametersWithFormatDetail, null, $responseRaw);

$pMockViewFieldModifierHandler = $this->getMockBuilder(ViewFieldModifierHandler::class)
->setMethods(['processRecord', 'getAllAPIFields'])
Expand Down
3 changes: 0 additions & 3 deletions tests/resources/templates/output_default_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
ul.oo-listparking {
padding: 0 10px;
}
.clear {
width: 25%;
}
</style>
<div class="oo-detailview">
<div class="oo-detailsheadline">
Expand Down
Loading