From d69ec7fbd0152c5d3c90b8119510ceb8a4d0f306 Mon Sep 17 00:00:00 2001 From: maianhtu010596 Date: Mon, 26 Sep 2022 16:49:52 +0700 Subject: [PATCH] Fix issues/60 --- Resource/locale/messages.ja.yml | 2 ++ Resource/template/admin/regist.twig | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Resource/locale/messages.ja.yml b/Resource/locale/messages.ja.yml index 4921e54..65501fa 100644 --- a/Resource/locale/messages.ja.yml +++ b/Resource/locale/messages.ja.yml @@ -27,3 +27,5 @@ plugin_recommend.admin.edit.existed: この商品はすでにおすすめ商品 plugin_recommend.admin.edit.search: 商品の追加 plugin_recommend.admin.edit.product_search.header: 商品検索 plugin_recommend.admin.edit.product_search.button: 検索 + +plugin_recommend.admin.common.failed_to_load: 読み込みに失敗しました \ No newline at end of file diff --git a/Resource/template/admin/regist.twig b/Resource/template/admin/regist.twig index e2b12e5..48189ef 100644 --- a/Resource/template/admin/regist.twig +++ b/Resource/template/admin/regist.twig @@ -37,6 +37,7 @@ ); $('#searchProductModalButton').on('click', function() { + var xhr = new XMLHttpRequest(); var list = $('#searchProductModalList'); list.children().remove(); $.ajax({ @@ -46,11 +47,17 @@ 'id' : $('#admin_search_product_id').val(), 'category_id' : $('#admin_search_product_category_id').val() }, + xhr: function() { + return xhr; + }, url: '{{ url('plugin_recommend_search_product') }}', success: function(data) { // モーダルに結果を書き出し. - $('#searchProductModalList').html(data); - + if (xhr.responseURL === '{{ url('admin_login') }}') { + alert('{{ 'plugin_recommend.admin.common.failed_to_load'|trans }}'); + } else { + $('#searchProductModalList').html(data); + } }, error: function() { alert('Search product failed.');