forked from shopware/shopware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEXT-9291 - Add Data Protection Information checkbox, fixes shopwareB…
- Loading branch information
Showing
7 changed files
with
158 additions
and
9 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
changelog/_unreleased/2021-01-14-add-data-protection-information-checkbox.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: Add Data Protection Information checkbox | ||
issue: NEXT-9291 | ||
author: Rune Laenen | ||
author_email: [email protected] | ||
author_github: runelaenen | ||
--- | ||
# Core | ||
* Added `core.loginRegistration.requireDataProtectionCheckbox` configuration option, defaults to false. | ||
* Added `acceptedDataProtection` parameter to `Shopware\Core\Checkout\Customer\SalesChannel\RegisterRoute` | ||
* Added `acceptedDataProtection` validation rule if `core.loginRegistration.requireDataProtectionCheckbox` configuration is enabled | ||
___ | ||
# Storefront | ||
* Added blocks `component_privacy_dpi`, `component_privacy_dpi_checkbox` and `component_privacy_dpi_label` in `@Storefront/storefront/component/privacy-notice.html.twig` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Core/Migration/Migration1610625925RequireDataProtectionCheckbox.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Shopware\Core\Migration; | ||
|
||
use Doctrine\DBAL\Connection; | ||
use Shopware\Core\Defaults; | ||
use Shopware\Core\Framework\Migration\MigrationStep; | ||
use Shopware\Core\Framework\Uuid\Uuid; | ||
|
||
class Migration1610625925RequireDataProtectionCheckbox extends MigrationStep | ||
{ | ||
public function getCreationTimestamp(): int | ||
{ | ||
return 1610625925; | ||
} | ||
|
||
public function update(Connection $connection): void | ||
{ | ||
$connection->insert('system_config', [ | ||
'id' => Uuid::randomBytes(), | ||
'configuration_key' => 'core.loginRegistration.requireDataProtectionCheckbox', | ||
'configuration_value' => json_encode(['_value' => false]), | ||
'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT), | ||
]); | ||
} | ||
|
||
public function updateDestructive(Connection $connection): void | ||
{ | ||
// implement update destructive | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,7 @@ | |
.register-shipping { | ||
padding-top: $spacer-lg; | ||
} | ||
|
||
.register-form .privacy-notice { | ||
margin-bottom: $spacer; | ||
} |
50 changes: 41 additions & 9 deletions
50
src/Storefront/Resources/views/storefront/component/privacy-notice.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,44 @@ | ||
{% block component_privacy_notice %} | ||
<p class="form-text privacy-notice"> | ||
{% block component_privacy_label %} | ||
<label> | ||
<strong>{{ "general.privacyTitle"|trans|sw_sanitize }}</strong><br /> | ||
{{ "general.privacyNotice"|trans({ | ||
'%url%': path('frontend.cms.page',{ id: shopware.config.core.basicInformation.privacyPage }) | ||
})|raw }} | ||
</label> | ||
<div class="form-text privacy-notice"> | ||
{% block component_privacy_title %} | ||
<strong>{{ "general.privacyTitle"|trans|sw_sanitize }}</strong><br/> | ||
{% endblock %} | ||
</p> | ||
|
||
{% block component_privacy_dpi %} | ||
{% if shopware.config.core.loginRegistration.requireDataProtectionCheckbox == 1 %} | ||
<div class="custom-control custom-checkbox data-protection-information"> | ||
{% block component_privacy_dpi_checkbox %} | ||
<input type="checkbox" | ||
class="custom-control-input {% if formViolations.getViolations('/acceptedDataProtection') is not empty %} is-invalid{% endif %}" | ||
name="acceptedDataProtection" | ||
required="required" | ||
value="1" | ||
id="acceptedDataProtection" | ||
{% if data.get('acceptedDataProtection') %}checked="checked"{% endif %}> | ||
{% endblock %} | ||
|
||
{% block component_privacy_dpi_label %} | ||
<label class="custom-control-label no-validation" | ||
for="acceptedDataProtection"> | ||
{{ "general.privacyNotice"|trans({ | ||
'%url%': path('frontend.cms.page',{ id: shopware.config.core.basicInformation.privacyPage }) | ||
})|raw }} | ||
|
||
{{ "general.required"|trans|sw_sanitize }} | ||
</label> | ||
{% endblock %} | ||
</div> | ||
{% else %} | ||
<div class="data-protection-information"> | ||
{% block component_privacy_label %} | ||
<label> | ||
{{ "general.privacyNotice"|trans({ | ||
'%url%': path('frontend.cms.page',{ id: shopware.config.core.basicInformation.privacyPage }) | ||
})|raw }} | ||
</label> | ||
{% endblock %} | ||
</div> | ||
{% endif %} | ||
{% endblock %} | ||
</div> | ||
{% endblock %} |