Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/4.3' into 4.3-symfony6
Browse files Browse the repository at this point in the history
  • Loading branch information
chihiro-adachi committed Feb 21, 2024
2 parents 171143d + 647bc49 commit ab290b6
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 9 deletions.
90 changes: 90 additions & 0 deletions codeception/acceptance/EF05MypageCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
*/

use Codeception\Util\Fixtures;
use Doctrine\DBAL\Connection;
use Doctrine\ORM\EntityManager;
use Page\Front\CustomerAddressEditPage;
use Page\Front\CustomerAddressListPage;
use Page\Front\HistoryPage;
use Page\Front\MyPage;
use Page\Front\ProductDetailPage;
use Page\Front\ShoppingPage;
use Page\Front\CartPage;
use Eccube\Repository\CustomerAddressRepository;

/**
* @group front
Expand All @@ -25,8 +30,21 @@
*/
class EF05MypageCest
{
/** @var EntityManager */
private EntityManager $em;

/** @var Connection */
private Connection $conn;

/**
* @var CustomerAddressRepository
*/
protected CustomerAddressRepository $customerAddressRepository;

public function _before(AcceptanceTester $I)
{
$this->em = Fixtures::get('entityManager');
$this->conn = $this->em->getConnection();
}

public function _after(AcceptanceTester $I)
Expand Down Expand Up @@ -287,6 +305,78 @@ public function mypage_お届け先編集削除(AcceptanceTester $I)
$I->see('お届け先は登録されていません。', '#page_mypage_delivery > div.ec-layoutRole > div.ec-layoutRole__contents > main > div > div:nth-child(2) > p');
}

/**
* @see https://github.com/EC-CUBE/ec-cube/issues/6081
*/
public function mypage_お届け先上限確認(AcceptanceTester $I)
{
$I->wantTo('EF0506-UC03-T02 Mypage お届け先上限確認');
$createCustomer = Fixtures::get('createCustomer');
$config = Fixtures::get('config');
$max = $config['eccube_deliv_addr_max'];

$customer = $createCustomer();
$I->loginAsMember($customer->getEmail(), 'password');

// 19件のお届け先を登録
/** @var \Doctrine\ORM\EntityManager $em */
$em = Fixtures::get('entityManager');

$this->customerAddressRepository = $em->getRepository(\Eccube\Entity\CustomerAddress::class);

for ($i = 0; $i < $max; $i++) {
$customerAddress = new \Eccube\Entity\CustomerAddress();
$customerAddress
->setCustomer($customer)
->setName01($customer->getName01())
->setName02($customer->getName02())
->setKana01($customer->getKana01())
->setKana02($customer->getKana02())
->setCompanyName($customer->getCompanyName())
->setPhoneNumber($customer->getPhoneNumber())
->setPostalCode($customer->getPostalCode())
->setPref($customer->getPref())
->setAddr01($customer->getAddr01())
->setAddr02($customer->getAddr02());

$em->persist($customerAddress);
}

$em->flush();

// TOPページ>マイページ>お届け先一覧で上限に達していることを確認
MyPage::go($I)->お届け先編集();

$I->wait(1);

$I->see(sprintf('お届け先登録の上限の%s件に達しています。お届け先を入力したい場合は、削除か変更を行ってください。', 20), '#page_mypage_delivery > div.ec-layoutRole > div.ec-layoutRole__contents > main > div > div:nth-child(3) > div > div');

// ご注文手続き画面で上限に達していることを確認
ProductDetailPage::go($I, 2)
->カートに入れる(1)
->カートへ進む();

CartPage::go($I)
->レジに進む();

ShoppingPage::at($I)->お届け先変更();

$I->wait(1);

$I->see(sprintf('お届け先登録の上限の%s件に達しています。お届け先を入力したい場合は、削除か変更を行ってください。', 20), 'div.ec-registerRole > div > div > div ');

// 受注に紐づくidに直接アクセスしても登録されないことを確認
// URLから受注に紐づくIDを抽出 /shopping/shipping/{id}
$redirectUrl = $I->grabFromCurrentUrl();
$shipping_id = preg_replace('/\/shopping\/shipping\/(\d+)/', '$1', $redirectUrl);

// URLに直接アクセス /shopping/shipping_edit/{id}
$I->amOnPage('/shopping/shipping_edit/'.$shipping_id);

// 404であることを確認
$I->seeInTitle('ページがみつかりません');
}

public function mypage_退会手続き未実施(AcceptanceTester $I)
{
$I->wantTo('EF0507-UC03-T01 Mypage 退会手続き 未実施');
Expand Down
6 changes: 5 additions & 1 deletion html/template/admin/assets/js/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ var toggleBtnBulk = function(checkboxSelector, btnSelector) {
/////////// 2重submit制御.

if (typeof Ladda !== 'undefined') {
Ladda.bind('button[type=submit]', {timeout: 2000});
// a[token-for-anchor] を押下されるとJavaScriptで formを作成してPOSTする仕様になっていて、
// aタグにdisable属性を付与しても駄目(form生成&postしてしまう)だったので、cssでpointer-event:none;しています。
// https://github.com/EC-CUBE/ec-cube/pull/5971
Ladda.bind('button[type=submit],a[token-for-anchor]', {timeout: 2000});
$('button[type=submit].btn-ec-regular').attr('data-spinner-color', '#595959');
}

Expand All @@ -144,6 +147,7 @@ $(function() {
$('a[token-for-anchor]').click(function(e) {
e.preventDefault();
var $this = $(this);
$this.css('pointer-events','none');
var data = $this.data();
if (data.confirm != false) {
if (!confirm(data.message ? data.message : '削除してもよろしいですか?')) {
Expand Down
34 changes: 33 additions & 1 deletion html/template/default/assets/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/Eccube/Controller/ShoppingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\RateLimiter\RateLimiterFactory;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\RouterInterface;
Expand Down Expand Up @@ -668,6 +669,14 @@ public function shippingEdit(Request $request, Shipping $Shipping)

$CustomerAddress = new CustomerAddress();
if ($this->isGranted('IS_AUTHENTICATED_FULLY')) {

$Customer = $this->getUser();
$addressCurrNum = count($Customer->getCustomerAddresses());
$addressMax = $this->eccubeConfig['eccube_deliv_addr_max'];
if ($addressCurrNum >= $addressMax) {
throw new NotFoundHttpException();
}

// ログイン時は会員と紐付け
$CustomerAddress->setCustomer($this->getUser());
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/Eccube/EventListener/TwigInitializeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ public function setFrontVariables(RequestEvent $event)
$this->twig->addGlobal('Page', $Page);
$this->twig->addGlobal('title', $Page->getName());
$this->twig->addGlobal('isMaintenance', $this->systemService->isMaintenanceMode());
$this->twig->addGlobal('isDebugMode', env('APP_DEBUG'));
}

public function setAdminGlobals(RequestEvent $event)
Expand All @@ -254,6 +255,8 @@ public function setAdminGlobals(RequestEvent $event)
}
$this->twig->addGlobal('eccubeNav', $eccubeNav);
$this->twig->addGlobal('isMaintenance', $this->systemService->isMaintenanceMode());
$this->twig->addGlobal('isDebugMode', env('APP_DEBUG'));

}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Eccube/Resource/locale/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ front.shopping.payment_method_unselected: Please select the payment method.
front.shopping.not_available_payment_method: The payment method you have selected is not available.
front.shopping.payment_method_not_fount: Sorry, you have no payment options. If you have selected multiple delivery methods, you can only select the same payment option for them all.
front.under_maintenance: The site is currently under maintenance.
front.under_debug_mode: The site is currently under debug mode.

#====================================================================================
# Admin Console
Expand Down Expand Up @@ -505,6 +506,7 @@ admin.common.move_to_confirm_save_and_move: Save & Move
admin.common.admin_url_warning: 'Please set the Admin Console URL that is hard to guess for security. You can set it at "<a href="%url%">Security</a>".'
admin.common.restrict_file_upload_info: 'If this feature is used infrequently, disabling it while not in use provides additional security. You can disable this feature by setting the environment variable ECCUBE_RESTRICT_FILE_UPLOAD to 1.'
admin.common.notice_maintenance_mode: 'Currently in maintenance mode.'
admin.common.notice_debug_mode: The site is currently under debug mode.


# Labels related to entity
Expand Down
4 changes: 3 additions & 1 deletion src/Eccube/Resource/locale/messages.ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ front.shopping.payment_method_unselected: お支払い方法を選択してく
front.shopping.not_available_payment_method: 選択したお支払い方法はご利用できません。
front.shopping.payment_method_not_fount: 選択できるお支払い方法がありません。配送方法が異なる場合は同じ配送方法を選んでください。
front.under_maintenance: メンテナンスモードが有効になっています。
front.under_debug_mode: デバッグモードが有効になっています。


#====================================================================================
# 管理画面
Expand Down Expand Up @@ -505,7 +507,7 @@ admin.common.move_to_confirm_save_and_move: 保存して移動
admin.common.admin_url_warning: '管理画面URLは、セキュリティのため推測されにくいものを設定してください。「<a href="%url%">セキュリティ管理</a>」から設定できます。'
admin.common.restrict_file_upload_info: 'この機能の利用頻度が低い場合、使用しない間は無効化することでセキュリティを更に向上させることができます。環境変数 ECCUBE_RESTRICT_FILE_UPLOAD を 1 に設定することで機能を無効化することが可能です。'
admin.common.notice_maintenance_mode: '現在メンテナンスモード中です。'

admin.common.notice_debug_mode: 'デバッグモードが有効になっています。'

# エンティティに関連するラベル
admin.common.id: ID
Expand Down
1 change: 1 addition & 0 deletions src/Eccube/Resource/template/admin/default_frame.twig
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ file that was distributed with this source code.

{{ include('@admin/alert.twig') }}
{{ include('@admin/info.twig') }}
{{ include('@admin/notice_debug_mode.twig') }}

{% block main %}{% endblock %}

Expand Down
8 changes: 8 additions & 0 deletions src/Eccube/Resource/template/admin/notice_debug_mode.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% if isDebugMode %}
<div class="alert alert-danger alert-dismissible fade show m-3" role="alert">
<i class="fa fa-warning fa-lg me-2"></i>
<span class="fw-bold">{{ 'admin.common.notice_debug_mode'|trans }}</span>
<button class="btn-close" type="button" data-bs-dismiss="alert" aria-label="Close">
</button>
</div>
{% endif %}
38 changes: 32 additions & 6 deletions src/Eccube/Resource/template/default/default_frame.twig
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,39 @@ file that was distributed with this source code.
{{ include('block.twig', {'Blocks': Layout.BodyAfter}) }}
{% endif %}

{% if isMaintenance is defined and isMaintenance %}
<div class="ec-maintenanceAlert">
<div>
<div class="ec-maintenanceAlert__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"/></div>
{{ 'front.under_maintenance'|trans }}

{% if isMaintenance is defined and isMaintenance and isDebugMode %}
<dev class="ec-twoModeAlert">
<div class="ec-maintenanceAlert">
<div>
<div class="ec-maintenanceAlert__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"/></div>
{{ 'front.under_maintenance'|trans }}
</div>
</div>
</div>
<div class="ec-debugModeAlert bg-danger">
<div>
<div class="ec-debugModeAlert__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"/></div>
{{ 'front.under_debug_mode'|trans }}
</div>
</div>
</dev>
{% else %}
{% if isMaintenance %}
<div class="ec-maintenanceAlert">
<div>
<div class="ec-maintenanceAlert__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"/></div>
{{ 'front.under_maintenance'|trans }}
</div>
</div>
{% endif %}
{% if isDebugMode %}
<div class="ec-debugModeAlert bg-danger">
<div>
<div class="ec-debugModeAlert__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"/></div>
{{ 'front.under_debug_mode'|trans }}
</div>
</div>
{% endif %}
{% endif %}

<div class="ec-layoutRole">
Expand Down

0 comments on commit ab290b6

Please sign in to comment.