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

[4.1.x, 4.2.x] 値をスペースで更新してから更新をキャンセルすると、元の値が消える不具合の修正 #5828

Merged
merged 9 commits into from
Oct 12, 2022
24 changes: 23 additions & 1 deletion src/Eccube/Form/Type/Admin/CalendarType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Validator\ValidatorInterface;

/**
* Class CalendarType
Expand All @@ -41,13 +42,19 @@ class CalendarType extends AbstractType
*/
protected $calendarRepository;

/**
* @var ValidatorInterface
*/
protected $validator;

/**
* CalendarType constructor.
*/
public function __construct(EccubeConfig $eccubeConfig, CalendarRepository $calendarRepository)
public function __construct(EccubeConfig $eccubeConfig, ValidatorInterface $validator, CalendarRepository $calendarRepository)
{
$this->eccubeConfig = $eccubeConfig;
$this->calendarRepository = $calendarRepository;
$this->validator = $validator;
}

/**
Expand Down Expand Up @@ -88,6 +95,21 @@ public function buildForm(FormBuilderInterface $builder, array $options)
// 日付重複チェック
/** @var Calendar $Calendar */
$Calendar = $event->getData();

$errors = $this->validator->validate(
$Calendar->getHoliday(),
[
new Assert\Range([
'min' => '0003-01-01',
'minMessage' => 'form_error.out_of_range',
]),
]
);

if ($errors->count()) {
return;
}

$qb = $this->calendarRepository->createQueryBuilder('c');
$qb
->select('count(c.id)')
Expand Down
8 changes: 1 addition & 7 deletions src/Eccube/Resource/template/admin/Product/category.twig
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,7 @@ file that was distributed with this source code.
});

groupItem.on('click', 'button.action-edit-cancel', function(e) {
e.preventDefault();
var current = $(this).parents('li');
current.find('[data-origin-value]').each(function(e) {
$(this).val($(this).attr('data-origin-value'));
});
current.find('.mode-view').removeClass('d-none');
current.find('.mode-edit').addClass('d-none');
location.href = "{% if TargetCategory.id %}{{ url('admin_product_category_edit', {id: TargetCategory.id}) }}{% elseif Parent %}{{ url('admin_product_category_show', {'parent_id': Parent.id}) }}{% else %}{{ url('admin_product_category') }}{% endif %}";
});

groupItem.find('.is-invalid').each(function(e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,7 @@ file that was distributed with this source code.
current.find('.mode-edit').removeClass('d-none');
});
sortable.on('click', 'button.action-edit-cancel', function(e) {
e.preventDefault();
var current = $(this).parents('li');
current.find('[data-origin-value]').each(function(e) {
$(this).val($(this).attr('data-origin-value'));
});
current.find('.mode-view').removeClass('d-none');
current.find('.mode-edit').addClass('d-none');
location.href = "{{ url('admin_product_class_category', {'class_name_id': ClassName.id}) }}";
});
sortable.find('.is-invalid').each(function(e) {
var current = $(this).parents('li');
Expand Down
8 changes: 1 addition & 7 deletions src/Eccube/Resource/template/admin/Product/class_name.twig
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,7 @@ file that was distributed with this source code.
});
// 編集キャンセル
$('.sortable-item').on('click', 'button.action-edit-cancel', function(e) {
e.preventDefault();
var current = $(this).parents('li');
current.find('[data-origin-value]').each(function(e) {
$(this).val($(this).attr('data-origin-value'));
});
current.find('.mode-view').removeClass('d-none');
current.find('.mode-edit').addClass('d-none');
location.href = '{{ url('admin_product_class_name') }}';
});

// 編集時, エラーがあれば入力欄を表示.
Expand Down
8 changes: 1 addition & 7 deletions src/Eccube/Resource/template/admin/Product/tag.twig
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,7 @@ file that was distributed with this source code.

// 編集キャンセル
$('.sortable-item').on('click', 'button.action-edit-cancel', function(e) {
e.preventDefault();
var current = $(this).parents("li");
current.find('[data-origin-value]').each(function(e) {
$(this).val($(this).attr('data-origin-value'));
});
current.find('.mode-view').removeClass('d-none');
current.find('.mode-edit').addClass('d-none');
location.href = '{{ url('admin_product_tag') }}';
});
// 編集時, エラーがあれば入力欄を表示.
$('.sortable-item').find('.is-invalid').each(function(e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ file that was distributed with this source code.
<button class="btn btn-ec-conversion action-edit-submit" type="submit">{{ 'admin.common.decision'|trans }}</button>
</div>
<div class="col-auto d-flex align-items-center">
<button class="btn btn-ec-sub action-edit-cancel" type="submit">{{ 'admin.common.cancel'|trans }}</button>
<button type="button" class="btn btn-ec-sub action-edit-cancel" >{{ 'admin.common.cancel'|trans }}</button>
</div>
{{ form_errors(form.delivery_time) }}
{{ form_widget(form.sort_no, {'attr': {'class': "sort-no" }}) }}
Expand Down