mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Merge branch '1.12' into 1.13
* 1.12: Cart promotion Action Update Enable Sylius API for app environments [Maintenance] Update dev symfony version to 5.4.* Provide post-CR fixes Remove redundant TaxonPositioner service Cover "jumping" taxons while moving with Behat scenarios Revert bc promise breaking changes Leave only bug-related code and extract the position-related logic Added: Move taxon to the top/end buttons at admin Fixed: Moving taxons up and down at admin
This commit is contained in:
commit
7aecb72d66
13 changed files with 133 additions and 35 deletions
|
|
@ -7,6 +7,10 @@
|
|||
1. The default checkout resolving route pattern has been changed from `/checkout/.+` to
|
||||
`%sylius.security.shop_regex%/checkout/.+` to reduce the probability of conflicts with other routes.
|
||||
|
||||
1. The `src/Sylius/Bundle/AdminBundle/Resources/views/Taxon/_treeWithButtons.html.twig` template has been updated to
|
||||
implement new changing taxon's position logic. If you have overridden this template, you need to update it.
|
||||
If you want to check what has changed, you might use [this PR](https://github.com/Sylius/Sylius/pull/15272) as a reference.
|
||||
|
||||
# UPGRADE FROM `v1.12.9` TO `v1.12.10`
|
||||
|
||||
1. The `Sylius\Component\Core\OrderProcessing\OrderPaymentProcessor` constructor has been changed:
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ parameters:
|
|||
sylius_core.public_dir: '%kernel.project_dir%/public'
|
||||
|
||||
sylius_api:
|
||||
enabled: false
|
||||
enabled: true
|
||||
|
||||
sylius_shop:
|
||||
product_grid:
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ There are a few kinds of actions in **Sylius**:
|
|||
* percentage discount on the order (for example: -10% on the whole order)
|
||||
* fixed unit discount (for example: -1$ off the order total but *distributed and applied on each order item unit*)
|
||||
* percentage unit discount (for example: -10% off the order total but *distributed and applied on each order item unit*)
|
||||
* shipping discount (for example: -6$ on the costs of shipping)
|
||||
* shipping precentage discount (for example: -10% off the costs of shipping)
|
||||
|
||||
.. tip::
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,20 @@ Feature: Reordering taxons
|
|||
And I should see the taxon named "Watches" in the list
|
||||
But the first taxon on the list should be "Watches"
|
||||
|
||||
@ui @javascript
|
||||
Scenario: Moving up the first taxon on list
|
||||
When I want to see all taxons in store
|
||||
And I move up "T-Shirts" taxon
|
||||
Then I should see 4 taxons on the list
|
||||
And the first taxon on the list should be "T-Shirts"
|
||||
|
||||
@ui @javascript
|
||||
Scenario: Moving down the last taxon on list
|
||||
When I want to see all taxons in store
|
||||
And I move down "Wallets" taxon
|
||||
Then I should see 4 taxons on the list
|
||||
And the last taxon on the list should be "Wallets"
|
||||
|
||||
@ui @javascript @todo
|
||||
Scenario: Changing order of the taxon on list
|
||||
When I want to see all taxons in store
|
||||
|
|
|
|||
|
|
@ -429,6 +429,14 @@ final class ManagingTaxonsContext implements Context
|
|||
Assert::same($this->createPage->getFirstTaxonOnTheList(), $taxonName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the last taxon on the list should be :taxonName
|
||||
*/
|
||||
public function theLastTaxonOnTheListShouldBe(string $taxonName): void
|
||||
{
|
||||
Assert::same($this->createPage->getLastTaxonOnTheList(), $taxonName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I enable it
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -144,6 +144,13 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
return $this->getLeaves()[0]->getText();
|
||||
}
|
||||
|
||||
public function getLastTaxonOnTheList(): string
|
||||
{
|
||||
$leaves = $this->getLeaves();
|
||||
|
||||
return $leaves[count($leaves) - 1]->getText();
|
||||
}
|
||||
|
||||
protected function getElement(string $name, array $parameters = []): NodeElement
|
||||
{
|
||||
if (!isset($parameters['%language%'])) {
|
||||
|
|
|
|||
|
|
@ -52,4 +52,6 @@ interface CreatePageInterface extends BaseCreatePageInterface
|
|||
public function moveDownTaxon(string $name): void;
|
||||
|
||||
public function getFirstTaxonOnTheList(): string;
|
||||
|
||||
public function getLastTaxonOnTheList(): string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,3 +69,21 @@ sylius_admin_ajax_taxon_move:
|
|||
_sylius:
|
||||
permission: true
|
||||
form: Sylius\Bundle\TaxonomyBundle\Form\Type\TaxonPositionType
|
||||
|
||||
sylius_admin_ajax_taxon_move_up:
|
||||
path: /{id}/move-up
|
||||
methods: [PUT]
|
||||
defaults:
|
||||
_controller: sylius.controller.taxon_position::moveUpAction
|
||||
_format: json
|
||||
_sylius:
|
||||
permission: true
|
||||
|
||||
sylius_admin_ajax_taxon_move_down:
|
||||
path: /{id}/move-down
|
||||
methods: [PUT]
|
||||
defaults:
|
||||
_controller: sylius.controller.taxon_position::moveDownAction
|
||||
_format: json
|
||||
_sylius:
|
||||
permission: true
|
||||
|
|
|
|||
|
|
@ -54,8 +54,9 @@ $(document).ready(() => {
|
|||
});
|
||||
|
||||
$('.sylius-update-product-variants').moveProductVariant($('.sylius-product-variant-position'));
|
||||
$('.sylius-taxon-move-up').taxonMoveUp();
|
||||
$('.sylius-taxon-move-down').taxonMoveDown();
|
||||
|
||||
$('.sylius-taxon-move-up').taxonMove();
|
||||
$('.sylius-taxon-move-down').taxonMove();
|
||||
|
||||
$('#sylius_shipping_method_calculator').handlePrototypes({
|
||||
prototypePrefix: 'sylius_shipping_method_calculator_calculators',
|
||||
|
|
|
|||
|
|
@ -11,40 +11,12 @@ import 'semantic-ui-css/components/api';
|
|||
import $ from 'jquery';
|
||||
|
||||
$.fn.extend({
|
||||
taxonMoveUp() {
|
||||
taxonMove() {
|
||||
const element = this;
|
||||
|
||||
element.api({
|
||||
method: 'PUT',
|
||||
on: 'click',
|
||||
beforeSend(settings) {
|
||||
/* eslint-disable-next-line no-param-reassign */
|
||||
settings.data = {
|
||||
position: $(this).data('position') - 1,
|
||||
};
|
||||
|
||||
return settings;
|
||||
},
|
||||
onSuccess() {
|
||||
window.location.reload();
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
taxonMoveDown() {
|
||||
const element = this;
|
||||
|
||||
element.api({
|
||||
method: 'PUT',
|
||||
on: 'click',
|
||||
beforeSend(settings) {
|
||||
/* eslint-disable-next-line no-param-reassign */
|
||||
settings.data = {
|
||||
position: $(this).data('position') + 1,
|
||||
};
|
||||
|
||||
return settings;
|
||||
},
|
||||
onSuccess() {
|
||||
window.location.reload();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@
|
|||
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="item sylius-taxon-move-up" data-url="{{ path('sylius_admin_ajax_taxon_move', { id: taxon.id }) }}" data-id="{{ taxon.id }}" data-position="{{ taxon.position }}">
|
||||
<div class="item sylius-taxon-move-up" data-url="{{ path('sylius_admin_ajax_taxon_move_up', { id: taxon.id }) }}">
|
||||
<i class="arrow up icon grey"></i>{{ 'sylius.ui.move_up'|trans }}
|
||||
</div>
|
||||
<div class="item sylius-taxon-move-down" data-url="{{ path('sylius_admin_ajax_taxon_move', { id: taxon.id }) }}" data-id="{{ taxon.id }}" data-position="{{ taxon.position }}">
|
||||
<div class="item sylius-taxon-move-down" data-url="{{ path('sylius_admin_ajax_taxon_move_down', { id: taxon.id }) }}">
|
||||
<i class="arrow down icon grey"></i>{{ 'sylius.ui.move_down'|trans }}
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Sylius Sp. z o.o.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Bundle\TaxonomyBundle\Controller;
|
||||
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Sylius\Component\Taxonomy\Model\TaxonInterface;
|
||||
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class TaxonPositionController
|
||||
{
|
||||
public function __construct(
|
||||
private TaxonRepositoryInterface $taxonRepository,
|
||||
private ObjectManager $taxonManager,
|
||||
) {
|
||||
}
|
||||
|
||||
public function moveUpAction(int $id): Response
|
||||
{
|
||||
$taxonToBeMoved = $this->findTaxonOr404($id);
|
||||
|
||||
if ($taxonToBeMoved->getPosition() > 0) {
|
||||
$taxonToBeMoved->setPosition($taxonToBeMoved->getPosition() - 1);
|
||||
$this->taxonManager->flush();
|
||||
}
|
||||
|
||||
return new JsonResponse('', Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
public function moveDownAction(int $id): Response
|
||||
{
|
||||
$taxonToBeMoved = $this->findTaxonOr404($id);
|
||||
|
||||
$taxonToBeMoved->setPosition($taxonToBeMoved->getPosition() + 1);
|
||||
$this->taxonManager->flush();
|
||||
|
||||
return new JsonResponse('', Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
private function findTaxonOr404(int $id): TaxonInterface
|
||||
{
|
||||
/** @var TaxonInterface|null $taxon */
|
||||
$taxon = $this->taxonRepository->find($id);
|
||||
|
||||
if (null === $taxon) {
|
||||
throw new NotFoundHttpException(sprintf('Taxon with id %d does not exist.', $id));
|
||||
}
|
||||
|
||||
Assert::isInstanceOf($taxon, TaxonInterface::class);
|
||||
|
||||
return $taxon;
|
||||
}
|
||||
}
|
||||
|
|
@ -26,6 +26,11 @@
|
|||
<argument type="service" id="sylius.factory.taxon" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.controller.taxon_position" class="Sylius\Bundle\TaxonomyBundle\Controller\TaxonPositionController">
|
||||
<argument type="service" id="sylius.repository.taxon" />
|
||||
<argument type="service" id="sylius.manager.taxon" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.custom_factory.taxon" class="Sylius\Component\Taxonomy\Factory\TaxonFactory" decorates="sylius.factory.taxon" decoration-priority="256" public="false">
|
||||
<argument type="service" id="sylius.custom_factory.taxon.inner" />
|
||||
</service>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue