diff --git a/features/admin/taxonomy/managing_taxons/adding_images_to_existing_taxon.feature b/features/admin/taxonomy/managing_taxons/adding_images_to_existing_taxon.feature index dd7d4382f47..7cddd29ef50 100644 --- a/features/admin/taxonomy/managing_taxons/adding_images_to_existing_taxon.feature +++ b/features/admin/taxonomy/managing_taxons/adding_images_to_existing_taxon.feature @@ -9,7 +9,7 @@ Feature: Adding images to an existing taxon And the store classifies its products as "T-Shirts" And I am logged in as an administrator - @todo @ui @mink:chromedriver @api + @ui @mink:chromedriver @api Scenario: Adding a single image to an existing taxon When I want to modify the "T-Shirts" taxon And I attach the "t-shirts.jpg" image with "banner" type to this taxon @@ -17,7 +17,7 @@ Feature: Adding images to an existing taxon Then I should be notified that it has been successfully uploaded And this taxon should have an image with "banner" type - @todo @ui @mink:chromedriver @api + @ui @mink:chromedriver @api Scenario: Adding a single image to an existing taxon without specifying the type When I want to modify the "T-Shirts" taxon And I attach the "t-shirts.jpg" image to this taxon @@ -25,7 +25,7 @@ Feature: Adding images to an existing taxon Then I should be notified that it has been successfully uploaded And this taxon should have only one image - @todo @ui @mink:chromedriver @api + @ui @mink:chromedriver @api Scenario: Adding multiple images to an existing taxon When I want to modify the "T-Shirts" taxon And I attach the "t-shirts.jpg" image with "banner" type to this taxon @@ -35,7 +35,7 @@ Feature: Adding images to an existing taxon And this taxon should have an image with "banner" type And it should also have an image with "thumbnail" type - @todo @ui @javascript @api + @ui @mink:chromedriver @api Scenario: Adding multiple images of the same type to an existing taxon When I want to modify the "T-Shirts" taxon And I attach the "t-shirts.jpg" image with "banner" type to this taxon diff --git a/features/admin/taxonomy/managing_taxons/adding_taxon_with_images.feature b/features/admin/taxonomy/managing_taxons/adding_taxon_with_images.feature index 6dc77ce966e..419393f0c9f 100644 --- a/features/admin/taxonomy/managing_taxons/adding_taxon_with_images.feature +++ b/features/admin/taxonomy/managing_taxons/adding_taxon_with_images.feature @@ -8,22 +8,24 @@ Feature: Adding a new taxon with images Given the store is available in "English (United States)" And I am logged in as an administrator - @todo @ui @mink:chromedriver @no-api + @ui @mink:chromedriver @no-api Scenario: Adding a new taxon with a single image When I want to create a new taxon And I specify its code as "t-shirts" And I name it "T-Shirts" in "English (United States)" + And I set its slug to "t-shirts" And I attach the "t-shirts.jpg" image with "banner" type And I add it Then I should be notified that it has been successfully created And the "T-Shirts" taxon should appear in the registry And this taxon should have an image with "banner" type - @todo @ui @mink:chromedriver @no-api + @ui @mink:chromedriver @no-api Scenario: Adding a new taxon with multiple images When I want to create a new taxon And I specify its code as "t-shirts" And I name it "T-Shirts" in "English (United States)" + And I set its slug to "t-shirts" And I attach the "t-shirts.jpg" image with "banner" type And I attach the "t-shirts.jpg" image with "thumbnail" type And I add it diff --git a/features/admin/taxonomy/managing_taxons/changing_images_of_taxon.feature b/features/admin/taxonomy/managing_taxons/changing_images_of_taxon.feature index 4f5a3f995e3..9c1ee01279c 100644 --- a/features/admin/taxonomy/managing_taxons/changing_images_of_taxon.feature +++ b/features/admin/taxonomy/managing_taxons/changing_images_of_taxon.feature @@ -9,7 +9,7 @@ Feature: Changing images of an existing taxon And the store classifies its products as "T-Shirts" And I am logged in as an administrator - @todo @ui @mink:chromedriver @no-api + @ui @mink:chromedriver @no-api Scenario: Changing a single image of a taxon Given the "T-Shirts" taxon has an image "ford.jpg" with "banner" type When I want to modify the "T-Shirts" taxon @@ -18,7 +18,7 @@ Feature: Changing images of an existing taxon Then I should be notified that it has been successfully edited And this taxon should have an image with "banner" type - @todo @ui @javascript @api + @ui @mink:chromedriver @api Scenario: Changing the type of image of a taxon Given the "T-Shirts" taxon has an image "ford.jpg" with "thumbnail" type And the "T-Shirts" taxon also has an image "t-shirts.jpg" with "banner" type diff --git a/features/admin/taxonomy/managing_taxons/removing_images_of_taxon.feature b/features/admin/taxonomy/managing_taxons/removing_images_of_taxon.feature index 7541e7a7dfd..6f9ff24f661 100644 --- a/features/admin/taxonomy/managing_taxons/removing_images_of_taxon.feature +++ b/features/admin/taxonomy/managing_taxons/removing_images_of_taxon.feature @@ -9,7 +9,7 @@ Feature: Removing images of an existing taxon And the store classifies its products as "T-Shirts" And I am logged in as an administrator - @todo @ui @javascript @api + @ui @mink:chromedriver @api Scenario: Removing a single image of a taxon Given the "T-Shirts" taxon has an image "t-shirts.jpg" with "banner" type When I want to modify the "T-Shirts" taxon @@ -18,7 +18,7 @@ Feature: Removing images of an existing taxon Then I should be notified that the changes have been successfully applied And this taxon should not have any images - @todo @ui @javascript @api + @ui @mink:chromedriver @api Scenario: Removing all images of a taxon Given the "T-Shirts" taxon has an image "t-shirts.jpg" with "banner" type And the "T-Shirts" taxon also has an image "t-shirts.jpg" with "thumbnail" type @@ -29,7 +29,7 @@ Feature: Removing images of an existing taxon Then I should be notified that the changes have been successfully applied And this taxon should not have any images - @todo @ui @mink:chromedriver @api + @ui @mink:chromedriver @api Scenario: Removing only one image of a taxon Given the "T-Shirts" taxon has an image "t-shirts.jpg" with "banner" type And the "T-Shirts" taxon also has an image "t-shirts.jpg" with "thumbnail" type @@ -40,7 +40,7 @@ Feature: Removing images of an existing taxon And this taxon should have an image with "thumbnail" type But this taxon should not have any images with "banner" type - @todo @ui @javascript @api + @ui @mink:chromedriver @api Scenario: Removing only one image of a taxon when all images have same type Given the "T-Shirts" taxon has an image "t-shirts.jpg" with "banner" type And the "T-Shirts" taxon also has an image "mugs.jpg" with "banner" type @@ -50,7 +50,7 @@ Feature: Removing images of an existing taxon Then I should be notified that the changes have been successfully applied And this taxon should have only one image - @todo @ui @mink:chromedriver @no-api + @ui @mink:chromedriver @no-api Scenario: Adding multiple images and removing a single image of a taxon When I want to modify the "T-Shirts" taxon And I attach the "t-shirts.jpg" image with "banner" type diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php index b5f53a2fa87..54a4ffea7c4 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingTaxonsContext.php @@ -16,6 +16,8 @@ use Behat\Behat\Context\Context; use FriendsOfBehat\PageObjectExtension\Page\SymfonyPageInterface; use Sylius\Behat\Context\Ui\Admin\Helper\ValidationTrait; +use Sylius\Behat\Element\Admin\Taxon\FormElementInterface; +use Sylius\Behat\Element\Admin\Taxon\ImageFormElementInterface; use Sylius\Behat\NotificationType; use Sylius\Behat\Page\Admin\Product\UpdateSimpleProductPageInterface; use Sylius\Behat\Page\Admin\Taxon\CreateForParentPageInterface; @@ -34,14 +36,16 @@ final class ManagingTaxonsContext implements Context use ValidationTrait; public function __construct( - private SharedStorageInterface $sharedStorage, - private CreatePageInterface $createPage, - private CreateForParentPageInterface $createForParentPage, - private UpdatePageInterface $updatePage, - private CurrentPageResolverInterface $currentPageResolver, - private NotificationCheckerInterface $notificationChecker, - private JavaScriptTestHelper $testHelper, - private UpdateSimpleProductPageInterface $updateSimpleProductPage, + private readonly SharedStorageInterface $sharedStorage, + private readonly CreatePageInterface $createPage, + private readonly CreateForParentPageInterface $createForParentPage, + private readonly UpdatePageInterface $updatePage, + private readonly FormElementInterface $formElement, + private readonly ImageFormElementInterface $imageFormElement, + private readonly CurrentPageResolverInterface $currentPageResolver, + private readonly NotificationCheckerInterface $notificationChecker, + private readonly JavaScriptTestHelper $testHelper, + private readonly UpdateSimpleProductPageInterface $updateSimpleProductPage, ) { } @@ -86,11 +90,9 @@ public function iSpecifyItsCodeAs(?string $code = null): void * @When I rename it to :name in :language * @When I do not specify its name */ - public function iNameItIn(?string $name = null, $language = 'en_US') + public function iNameItIn(?string $name = null, $language = 'en_US'): void { - $currentPage = $this->resolveCurrentPage(); - - $currentPage->nameIt($name ?? '', $language); + $this->formElement->nameIt($name ?? '', $language); } /** @@ -98,11 +100,9 @@ public function iNameItIn(?string $name = null, $language = 'en_US') * @When I do not specify its slug * @When I set its slug to :slug in :language */ - public function iSetItsSlugToIn(?string $slug = null, $language = 'en_US') + public function iSetItsSlugToIn(?string $slug = null, $language = 'en_US'): void { - $currentPage = $this->resolveCurrentPage(); - - $currentPage->specifySlug($slug ?? '', $language); + $this->formElement->slugIt($slug ?? '', $language); } /** @@ -172,10 +172,10 @@ public function iSaveMyChanges() /** * @Then /^the ("[^"]+" taxon) should appear in the registry$/ */ - public function theTaxonShouldAppearInTheRegistry(TaxonInterface $taxon) + public function theTaxonShouldAppearInTheRegistry(TaxonInterface $taxon): void { $this->updatePage->open(['id' => $taxon->getId()]); - Assert::true($this->updatePage->hasResourceValues(['code' => $taxon->getCode()])); + Assert::same($this->formElement->getCode(), $taxon->getCode()); } /** @@ -309,9 +309,7 @@ public function iShouldSeeTaxonsInTheList($number) */ public function iAttachImageWithType(string $path, ?string $type = null): void { - $currentPage = $this->resolveCurrentPage(); - - $currentPage->attachImage($path, $type); + $this->imageFormElement->attachImage($path, $type); } /** @@ -327,7 +325,7 @@ public function iShouldSeeTheTaxonNamedInTheList($name) */ public function thisTaxonShouldHaveAnImageWithType(string $type): void { - Assert::true($this->updatePage->isImageWithTypeDisplayed($type)); + Assert::true($this->imageFormElement->isImageWithTypeDisplayed($type)); } /** @@ -335,7 +333,7 @@ public function thisTaxonShouldHaveAnImageWithType(string $type): void */ public function thisTaxonShouldNotHaveAnImageWithType($code) { - Assert::false($this->updatePage->isImageWithTypeDisplayed($code)); + Assert::false($this->imageFormElement->isImageWithTypeDisplayed($code)); } /** @@ -343,52 +341,52 @@ public function thisTaxonShouldNotHaveAnImageWithType($code) */ public function iRemoveAnImageWithType(string $type): void { - $this->updatePage->removeImageWithType($type); + $this->imageFormElement->removeImageWithType($type); } /** * @When I remove the first image */ - public function iRemoveTheFirstImage() + public function iRemoveTheFirstImage(): void { - $this->updatePage->removeFirstImage(); + $this->imageFormElement->removeFirstImage(); } /** * @Then /^(this taxon) should not have any images$/ */ - public function thisTaxonShouldNotHaveAnyImages(TaxonInterface $taxon) + public function thisTaxonShouldNotHaveAnyImages(TaxonInterface $taxon): void { $this->iWantToModifyATaxon($taxon); - Assert::same($this->updatePage->countImages(), 0); + Assert::same($this->imageFormElement->countImages(), 0); } /** * @When I change the image with the :type type to :path */ - public function iChangeItsImageToPathForTheType($path, $type) + public function iChangeItsImageToPathForTheType($path, $type): void { - $this->updatePage->changeImageWithType($type, $path); + $this->imageFormElement->changeImageWithType($type, $path); } /** * @When I change the first image type to :type */ - public function iChangeTheFirstImageTypeTo($type) + public function iChangeTheFirstImageTypeTo($type): void { - $this->updatePage->modifyFirstImageType($type); + $this->imageFormElement->modifyFirstImageType($type); } /** * @Then /^(this taxon) should have only one image$/ * @Then /^(this taxon) should(?:| still) have (\d+) images?$/ */ - public function thereShouldStillBeOnlyOneImageInThisTaxon(TaxonInterface $taxon, $count = 1) + public function thereShouldStillBeOnlyOneImageInThisTaxon(TaxonInterface $taxon, $count = 1): void { $this->iWantToModifyATaxon($taxon); - Assert::same($this->updatePage->countImages(), (int) $count); + Assert::same($this->imageFormElement->countImages(), (int) $count); } /** diff --git a/src/Sylius/Behat/Element/Admin/CatalogPromotion/FormElement.php b/src/Sylius/Behat/Element/Admin/CatalogPromotion/FormElement.php index 5edff044d04..2abc4ef87da 100644 --- a/src/Sylius/Behat/Element/Admin/CatalogPromotion/FormElement.php +++ b/src/Sylius/Behat/Element/Admin/CatalogPromotion/FormElement.php @@ -220,13 +220,4 @@ protected function getDefinedElements(): array 'start_date_time' => '#sylius_catalog_promotion_startDate_time', ]); } - - private function waitForFormUpdate(): void - { - $form = $this->getElement('form'); - sleep(1); // we need to sleep, as sometimes the check below is executed faster than the form sets the busy attribute - $form->waitFor(1500, function () use ($form) { - return !$form->hasAttribute('busy'); - }); - } } diff --git a/src/Sylius/Behat/Element/Admin/Channel/ExcludeTaxonsFromShowingLowestPriceInputElement.php b/src/Sylius/Behat/Element/Admin/Channel/ExcludeTaxonsFromShowingLowestPriceInputElement.php index 55adfacee2e..fa8399fc1dd 100644 --- a/src/Sylius/Behat/Element/Admin/Channel/ExcludeTaxonsFromShowingLowestPriceInputElement.php +++ b/src/Sylius/Behat/Element/Admin/Channel/ExcludeTaxonsFromShowingLowestPriceInputElement.php @@ -14,16 +14,16 @@ namespace Sylius\Behat\Element\Admin\Channel; use Behat\Mink\Session; -use FriendsOfBehat\PageObjectExtension\Element\Element; use FriendsOfBehat\SymfonyExtension\Mink\MinkParameters; +use Sylius\Behat\Element\Admin\Crud\FormElement as BaseFormElement; use Sylius\Behat\Service\Helper\AutocompleteHelperInterface; use Sylius\Component\Core\Model\TaxonInterface; -final class ExcludeTaxonsFromShowingLowestPriceInputElement extends Element implements ExcludeTaxonsFromShowingLowestPriceInputElementInterface +final class ExcludeTaxonsFromShowingLowestPriceInputElement extends BaseFormElement implements ExcludeTaxonsFromShowingLowestPriceInputElementInterface { public function __construct( Session $session, - array|MinkParameters $minkParameters = [], + array|MinkParameters $minkParameters, private AutocompleteHelperInterface $autocompleteHelper, ) { parent::__construct($session, $minkParameters); @@ -68,13 +68,4 @@ protected function getDefinedElements(): array 'taxons_excluded_from_showing_lowest_price' => '[data-test-taxons-excluded-from-showing-lowest-price]', ]); } - - private function waitForFormUpdate(): void - { - $form = $this->getElement('form'); - sleep(1); // we need to sleep, as sometimes the check below is executed faster than the form sets the busy attribute - $form->waitFor(1500, function () use ($form) { - return !$form->hasAttribute('busy'); - }); - } } diff --git a/src/Sylius/Behat/Element/Admin/Crud/FormElement.php b/src/Sylius/Behat/Element/Admin/Crud/FormElement.php index b20499557b7..4adc75c6c01 100644 --- a/src/Sylius/Behat/Element/Admin/Crud/FormElement.php +++ b/src/Sylius/Behat/Element/Admin/Crud/FormElement.php @@ -34,6 +34,15 @@ public function getValidationMessage(string $element, array $parameters = []): s return $validationMessage->getText(); } + protected function waitForFormUpdate(): void + { + $form = $this->getElement('form'); + usleep(500000); // we need to sleep, as sometimes the check below is executed faster than the form sets the busy attribute + $form->waitFor(1500, function () use ($form) { + return !$form->hasAttribute('busy'); + }); + } + /** @throws ElementNotFoundException */ private function getFieldElement(string $element, array $parameters): ?NodeElement { diff --git a/src/Sylius/Behat/Element/Admin/Promotion/FormElement.php b/src/Sylius/Behat/Element/Admin/Promotion/FormElement.php index b7b740e2cf6..af8e3f0f1b8 100644 --- a/src/Sylius/Behat/Element/Admin/Promotion/FormElement.php +++ b/src/Sylius/Behat/Element/Admin/Promotion/FormElement.php @@ -277,13 +277,4 @@ private function getChannelConfigurationOfLastRule(string $channelCode): NodeEle sprintf('[id^="sylius_promotion_rules_"][id$="_configuration_%s"]', $channelCode), ); } - - private function waitForFormUpdate(): void - { - $form = $this->getElement('form'); - sleep(1); // we need to sleep, as sometimes the check below is executed faster than the form sets the busy attribute - $form->waitFor(1500, function () use ($form) { - return !$form->hasAttribute('busy'); - }); - } } diff --git a/src/Sylius/Behat/Element/Admin/ShippingMethod/FormElement.php b/src/Sylius/Behat/Element/Admin/ShippingMethod/FormElement.php index c9fb8eee66d..c3e4f77f719 100644 --- a/src/Sylius/Behat/Element/Admin/ShippingMethod/FormElement.php +++ b/src/Sylius/Behat/Element/Admin/ShippingMethod/FormElement.php @@ -176,11 +176,4 @@ private function selectCalculatorConfigurationChannelTab(string $channelCode): v $this->getElement('calculator_configuration_channel_tab', ['%channelCode%' => $channelCode])->click(); } - - private function waitForFormUpdate(): void - { - $form = $this->getElement('form'); - usleep(500000); - $form->waitFor(1500, fn () => !$form->hasAttribute('busy')); - } } diff --git a/src/Sylius/Behat/Element/Admin/Taxon/FormElement.php b/src/Sylius/Behat/Element/Admin/Taxon/FormElement.php new file mode 100644 index 00000000000..ae38b38c99b --- /dev/null +++ b/src/Sylius/Behat/Element/Admin/Taxon/FormElement.php @@ -0,0 +1,44 @@ +getElement('code')->getValue(); + } + + public function nameIt(string $name, string $localeCode): void + { + $this->getElement('name', ['%locale_code%' => $localeCode])->setValue($name); + } + + public function slugIt(string $slug, string $localeCode): void + { + $this->getElement('slug', ['%locale_code%' => $localeCode])->setValue($slug); + } + + protected function getDefinedElements(): array + { + return array_merge(parent::getDefinedElements(), [ + 'code' => '[data-test-code]', + 'form' => '[data-live-name-value="sylius_admin:taxon:form"]', + 'name' => '[name="taxon[translations][%locale_code%][name]"]', + 'slug' => '[name="taxon[translations][%locale_code%][slug]"]', + ]); + } +} diff --git a/src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php b/src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php new file mode 100644 index 00000000000..f65fd9f766b --- /dev/null +++ b/src/Sylius/Behat/Element/Admin/Taxon/FormElementInterface.php @@ -0,0 +1,25 @@ +getElement('add_image')->press(); + $this->waitForFormUpdate(); + + $lastImage = $this->getElement('last_image'); + + if (null !== $type) { + $lastImage->fillField('Type', $type); + } + + $filesPath = $this->getParameter('files_path'); + $lastImage->find('css', '[data-test-file]')->attachFile($filesPath . $path); + } + + public function changeImageWithType(string $type, string $path): void + { + $image = $this->getElement('image_with_type', ['%type%' => $type]); + + $filesPath = $this->getParameter('files_path'); + $image->find('css', '[data-test-file]')->attachFile($filesPath . $path); + } + + public function modifyFirstImageType(string $type): void + { + $this->getElement('first_image')->fillField('Type', $type); + } + + public function removeImageWithType(string $type): void + { + $this->getElement('delete_image', ['%type%' => $type])->press(); + $this->waitForFormUpdate(); + } + + public function removeFirstImage(): void + { + $this->getElement('first_image')->find('css', '[data-test-delete-image]')->press(); + $this->waitForFormUpdate(); + } + + public function isImageWithTypeDisplayed(string $type): bool + { + try { + $image = $this->getElement('image_with_type', ['%type%' => $type]); + } catch (ElementNotFoundException) { + return false; + } + + $imageUrl = $image->getAttribute('data-test-image-url'); + $this->getDriver()->visit($imageUrl); + $statusCode = $this->getDriver()->getStatusCode(); + $this->getDriver()->back(); + + return in_array($statusCode, [200, 304], true); + } + + public function countImages(): int + { + return count($this->getElement('images')->findAll('css', '[data-test-image]')); + } + + protected function getDefinedElements(): array + { + return array_merge(parent::getDefinedElements(), [ + 'add_image' => '[data-test-images] [data-test-add-image]', + 'delete_image' => '[data-test-images] [data-test-image][data-test-type="%type%"] [data-test-delete-image]', + 'first_image' => '[data-test-images] [data-test-image]:first-child', + 'form' => '[data-live-name-value="sylius_admin:taxon:form"]', + 'image_with_type' => '[data-test-images] [data-test-image][data-test-type="%type%"]', + 'images' => '[data-test-images]', + 'last_image' => '[data-test-images] [data-test-image]:last-child', + ]); + } +} diff --git a/src/Sylius/Behat/Element/Admin/Taxon/ImageFormElementInterface.php b/src/Sylius/Behat/Element/Admin/Taxon/ImageFormElementInterface.php new file mode 100644 index 00000000000..8047a3fa125 --- /dev/null +++ b/src/Sylius/Behat/Element/Admin/Taxon/ImageFormElementInterface.php @@ -0,0 +1,33 @@ +getDriver())) { + $this->getDocument()->find('css', 'body')->click(); + } $this->getDocument()->pressButton('Create'); } diff --git a/src/Sylius/Behat/Page/Admin/Crud/UpdatePage.php b/src/Sylius/Behat/Page/Admin/Crud/UpdatePage.php index 62c5b30e5b2..127d5ce6d71 100644 --- a/src/Sylius/Behat/Page/Admin/Crud/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/Crud/UpdatePage.php @@ -19,6 +19,7 @@ use Behat\Mink\Session; use FriendsOfBehat\PageObjectExtension\Page\SymfonyPage; use FriendsOfBehat\PageObjectExtension\Page\UnexpectedPageException; +use Sylius\Behat\Service\DriverHelper; use Sylius\Component\Core\Formatter\StringInflector; use Symfony\Component\Routing\RouterInterface; @@ -35,6 +36,9 @@ public function __construct( public function saveChanges(): void { + if (DriverHelper::isJavascript($this->getDriver())) { + $this->getDocument()->find('css', 'body')->click(); + } $this->getDocument()->find('css', '[data-test-update-changes-button]')->click(); } diff --git a/src/Sylius/Behat/Page/Admin/Taxon/CreatePage.php b/src/Sylius/Behat/Page/Admin/Taxon/CreatePage.php index 4027cbaf2f4..1448fea15fc 100644 --- a/src/Sylius/Behat/Page/Admin/Taxon/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/Taxon/CreatePage.php @@ -73,35 +73,6 @@ public function hasTaxonWithName(string $name): bool return 0 !== $this->countTaxonsByName($name); } - public function nameIt(string $name, string $languageCode): void - { - $this->activateLanguageTab($languageCode); - $this->getElement('name', ['%language%' => $languageCode])->setValue($name); - - if (DriverHelper::isJavascript($this->getDriver())) { - SlugGenerationHelper::waitForSlugGeneration( - $this->getSession(), - $this->getElement('slug', ['%language%' => $languageCode]), - ); - } - } - - public function specifySlug(string $slug, string $languageCode): void - { - $this->getDocument()->fillField(sprintf('sylius_taxon_translations_%s_slug', $languageCode), $slug); - } - - public function attachImage(string $path, ?string $type = null): void - { - $filesPath = $this->getParameter('files_path'); - - $this->getDocument()->find('css', '[data-form-collection="add"]')->click(); - - $imageForm = $this->getLastImageElement(); - $imageForm->fillField('Type', $type); - $imageForm->find('css', 'input[type="file"]')->attachFile($filesPath . $path); - } - public function getLeaves(?TaxonInterface $parentTaxon = null): array { return $this->getDocument()->findAll('css', '.sylius-tree__item'); @@ -166,7 +137,6 @@ protected function getDefinedElements(): array 'code' => '#sylius_taxon_code', 'confirmation_button' => '#confirmation-button', 'description' => '#sylius_taxon_translations_en_US_description', - 'images' => '#sylius_taxon_images', 'language_tab' => '[data-locale="%locale%"] .title', 'name' => '#sylius_taxon_translations_%language%_name', 'slug' => '#sylius_taxon_translations_%language%_slug', @@ -174,14 +144,4 @@ protected function getDefinedElements(): array 'tree_item' => '.sylius-tree__item a:contains("%taxon%")', ]); } - - private function getLastImageElement(): NodeElement - { - $images = $this->getElement('images'); - $items = $images->findAll('css', 'div[data-form-collection="item"]'); - - Assert::notEmpty($items); - - return end($items); - } } diff --git a/src/Sylius/Behat/Page/Admin/Taxon/CreatePageInterface.php b/src/Sylius/Behat/Page/Admin/Taxon/CreatePageInterface.php index 25d5667ed13..b0ebdb429e8 100644 --- a/src/Sylius/Behat/Page/Admin/Taxon/CreatePageInterface.php +++ b/src/Sylius/Behat/Page/Admin/Taxon/CreatePageInterface.php @@ -30,14 +30,8 @@ public function describeItAs(string $description, string $languageCode): void; public function hasTaxonWithName(string $name): bool; - public function nameIt(string $name, string $languageCode): void; - public function specifyCode(string $code): void; - public function specifySlug(string $slug, string $languageCode): void; - - public function attachImage(string $path, ?string $type = null): void; - /** * @return NodeElement[] * diff --git a/src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php b/src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php index 0a5a21cac2c..ef9de2cd403 100644 --- a/src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/Taxon/UpdatePage.php @@ -41,54 +41,6 @@ public function describeItAs(string $description, string $languageCode): void $this->getDocument()->fillField(sprintf('sylius_taxon_translations_%s_description', $languageCode), $description); } - public function nameIt(string $name, string $languageCode): void - { - $this->activateLanguageTab($languageCode); - $this->getDocument()->fillField(sprintf('sylius_taxon_translations_%s_name', $languageCode), $name); - - if (DriverHelper::isJavascript($this->getDriver())) { - SlugGenerationHelper::waitForSlugGeneration( - $this->getSession(), - $this->getElement('slug', ['%language%' => $languageCode]), - ); - } - } - - public function specifySlug(string $slug, string $languageCode): void - { - $this->getDocument()->fillField(sprintf('sylius_taxon_translations_%s_slug', $languageCode), $slug); - } - - public function attachImage(string $path, ?string $type = null): void - { - $filesPath = $this->getParameter('files_path'); - - $this->getDocument()->find('css', '[data-form-collection="add"]')->click(); - - $imageForm = $this->getLastImageElement(); - if (null !== $type) { - $imageForm->fillField('Type', $type); - } - - $imageForm->find('css', 'input[type="file"]')->attachFile($filesPath . $path); - } - - public function isImageWithTypeDisplayed(string $type): bool - { - $imageElement = $this->getImageElementByType($type); - - $imageUrl = $imageElement ? $imageElement->find('css', 'img')->getAttribute('src') : $this->provideImageUrlForType($type); - if (null === $imageElement && null === $imageUrl) { - return false; - } - - $this->getDriver()->visit($imageUrl); - $statusCode = $this->getDriver()->getStatusCode(); - $this->getDriver()->back(); - - return in_array($statusCode, [200, 304], true); - } - public function isSlugReadonly(string $languageCode = 'en_US'): bool { return SlugGenerationHelper::isSlugReadonly( @@ -97,33 +49,6 @@ public function isSlugReadonly(string $languageCode = 'en_US'): bool ); } - public function removeImageWithType(string $type): void - { - $imageElement = $this->getImageElementByType($type); - $imageSourceElement = $imageElement->find('css', 'img'); - if (null !== $imageSourceElement) { - $this->saveImageUrlForType($type, $imageSourceElement->getAttribute('src')); - } - - $imageElement->clickLink('Delete'); - } - - public function removeFirstImage(): void - { - $imageElement = $this->getFirstImageElement(); - $imageTypeElement = $imageElement->find('css', 'input[type=text]'); - $imageSourceElement = $imageElement->find('css', 'img'); - - if (null !== $imageTypeElement && null !== $imageSourceElement) { - $this->saveImageUrlForType( - $imageTypeElement->getValue(), - $imageSourceElement->getAttribute('src'), - ); - } - - $imageElement->clickLink('Delete'); - } - public function enableSlugModification(string $languageCode = 'en_US'): void { SlugGenerationHelper::enableSlugModification( @@ -132,29 +57,6 @@ public function enableSlugModification(string $languageCode = 'en_US'): void ); } - public function countImages(): int - { - $imageElements = $this->getImageElements(); - - return count($imageElements); - } - - public function changeImageWithType(string $type, string $path): void - { - $filesPath = $this->getParameter('files_path'); - - $imageForm = $this->getImageElementByType($type); - $imageForm->find('css', 'input[type="file"]')->attachFile($filesPath . $path); - } - - public function modifyFirstImageType(string $type): void - { - $firstImage = $this->getFirstImageElement(); - - $typeField = $firstImage->findField('Type'); - $typeField->setValue($type); - } - public function getParent(): string { return $this->getElement('parent')->getValue(); @@ -238,7 +140,6 @@ protected function getDefinedElements(): array 'code' => '#sylius_taxon_code', 'description' => '#sylius_taxon_translations_en_US_description', 'enabled' => '#sylius_taxon_enabled', - 'images' => '#sylius_taxon_images', 'language_tab' => '[data-locale="%locale%"] .title', 'name' => '#sylius_taxon_translations_en_US_name', 'parent' => '#sylius_taxon_parent', @@ -256,15 +157,6 @@ private function getLastImageElement(): NodeElement return end($imageElements); } - private function getFirstImageElement(): NodeElement - { - $imageElements = $this->getImageElements(); - - Assert::notEmpty($imageElements); - - return reset($imageElements); - } - /** * @return NodeElement[] */ @@ -274,30 +166,4 @@ private function getImageElements(): array return $images->findAll('css', 'div[data-form-collection="item"]'); } - - private function getImageElementByType(string $type): ?NodeElement - { - $images = $this->getElement('images'); - $typeInput = $images->find('css', 'input[value="' . $type . '"]'); - - if (null === $typeInput) { - return null; - } - - return $typeInput->getParent()->getParent()->getParent(); - } - - private function provideImageUrlForType(string $type): ?string - { - return $this->imageUrls[$type] ?? null; - } - - private function saveImageUrlForType(string $type, string $imageUrl): void - { - if (str_contains($imageUrl, 'data:image/jpeg')) { - return; - } - - $this->imageUrls[$type] = $imageUrl; - } } diff --git a/src/Sylius/Behat/Page/Admin/Taxon/UpdatePageInterface.php b/src/Sylius/Behat/Page/Admin/Taxon/UpdatePageInterface.php index 9740f748a9f..bb65f67be94 100644 --- a/src/Sylius/Behat/Page/Admin/Taxon/UpdatePageInterface.php +++ b/src/Sylius/Behat/Page/Admin/Taxon/UpdatePageInterface.php @@ -25,28 +25,10 @@ public function chooseParent(TaxonInterface $taxon): void; public function isCodeDisabled(): bool; - public function nameIt(string $name, string $languageCode): void; - - public function specifySlug(string $slug, string $languageCode): void; - - public function attachImage(string $path, ?string $type = null): void; - - public function isImageWithTypeDisplayed(string $type): bool; - public function isSlugReadonly(string $languageCode = 'en_US'): bool; - public function removeImageWithType(string $type): void; - - public function removeFirstImage(): void; - public function enableSlugModification(string $languageCode = 'en_US'): void; - public function countImages(): int; - - public function changeImageWithType(string $type, string $path): void; - - public function modifyFirstImageType(string $type): void; - public function getParent(): string; public function getSlug(string $languageCode = 'en_US'): string; diff --git a/src/Sylius/Behat/Resources/config/services/contexts/ui.xml b/src/Sylius/Behat/Resources/config/services/contexts/ui.xml index 9872504b751..f5405cc693a 100644 --- a/src/Sylius/Behat/Resources/config/services/contexts/ui.xml +++ b/src/Sylius/Behat/Resources/config/services/contexts/ui.xml @@ -298,6 +298,8 @@ + + diff --git a/src/Sylius/Behat/Resources/config/services/elements/admin.xml b/src/Sylius/Behat/Resources/config/services/elements/admin.xml index 9c3dd8343ee..918274b37da 100644 --- a/src/Sylius/Behat/Resources/config/services/elements/admin.xml +++ b/src/Sylius/Behat/Resources/config/services/elements/admin.xml @@ -57,7 +57,7 @@ @@ -81,5 +81,17 @@ class="Sylius\Behat\Element\Admin\Zone\FormElement" parent="sylius.behat.element.admin.crud.form" /> + + + + diff --git a/src/Sylius/Bundle/AdminBundle/Form/Type/TaxonType.php b/src/Sylius/Bundle/AdminBundle/Form/Type/TaxonType.php new file mode 100644 index 00000000000..d4cbafb1c27 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Form/Type/TaxonType.php @@ -0,0 +1,47 @@ + $options */ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add('images', LiveCollectionType::class, [ + 'entry_type' => TaxonImageType::class, + 'allow_add' => true, + 'allow_delete' => true, + 'by_reference' => false, + 'button_add_options' => [ + 'label' => 'sylius.ui.add_image', + ], + 'button_delete_options' => [ + 'label' => 'sylius.ui.delete', + ], + ]) + ; + } + + public function getParent(): string + { + return BaseTaxonType::class; + } +} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/taxon/create.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/taxon/create.yaml index 78e73feb927..07e715964c5 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/taxon/create.yaml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/taxon/create.yaml @@ -2,28 +2,50 @@ twig_hooks: hooks: 'sylius_admin.taxon.create.content': form: - template: '@SyliusAdmin/taxon/create/form.html.twig' - configuration: - render_rest: false - - 'sylius_admin.taxon.create.content.form': + enabled: false + sections: + template: '@SyliusAdmin/taxon/sections.html.twig' + + 'sylius_admin.taxon.create.content.sections#left': tree: component: 'sylius_admin:taxon:tree' - sections: - template: '@SyliusAdmin/taxon/form/sections.html.twig' - 'sylius_admin.taxon.create.content.form.sections': + 'sylius_admin.taxon.create.content.sections#right': + form: + component: 'sylius_admin:taxon:form' + props: + form: '@=_context.form' + resource: '@=_context.resource' + + 'sylius_admin.taxon.create.content.sections.form': details: - template: '@SyliusAdmin/taxon/form/sections/details.html.twig' + template: '@SyliusAdmin/taxon/sections/form/details.html.twig' translations: - template: '@SyliusAdmin/taxon/form/sections/translations.html.twig' - media: - template: '@SyliusAdmin/taxon/form/sections/media.html.twig' - - 'sylius_admin.taxon.create.content.form.sections.details': + template: '@SyliusAdmin/taxon/sections/form/translations.html.twig' + images: + template: '@SyliusAdmin/taxon/sections/form/images.html.twig' + + 'sylius_admin.taxon.create.content.sections.form.details': code: - template: '@SyliusAdmin/taxon/form/sections/details/code.html.twig' + template: '@SyliusAdmin/taxon/sections/form/details/code.html.twig' parent: - template: '@SyliusAdmin/taxon/form/sections/details/parent.html.twig' + template: '@SyliusAdmin/taxon/sections/form/details/parent.html.twig' enabled: - template: '@SyliusAdmin/taxon/form/sections/details/enabled.html.twig' + template: '@SyliusAdmin/taxon/sections/form/details/enabled.html.twig' + + 'sylius_admin.taxon.create.content.sections.form.images': + image: + template: '@SyliusAdmin/taxon/sections/form/images/image.html.twig' + + 'sylius_admin.taxon.create.content.sections.form.images.image#left': + picture: + template: '@SyliusAdmin/taxon/sections/form/images/image/picture.html.twig' + button_delete: + template: '@SyliusAdmin/taxon/sections/form/images/image/button_delete.html.twig' + + 'sylius_admin.taxon.create.content.sections.form.images.image#right': + type: + template: '@SyliusAdmin/taxon/sections/form/images/image/type.html.twig' + file: + template: '@SyliusAdmin/taxon/sections/form/images/image/file.html.twig' + diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/taxon/update.yaml b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/taxon/update.yaml index 58d48c5aa9c..da487e198c0 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/taxon/update.yaml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/app/twig_hooks/taxon/update.yaml @@ -2,28 +2,51 @@ twig_hooks: hooks: 'sylius_admin.taxon.update.content': form: - template: '@SyliusAdmin/taxon/update/form.html.twig' - configuration: - render_rest: false - - 'sylius_admin.taxon.update.content.form': + enabled: false + sections: + template: '@SyliusAdmin/taxon/sections.html.twig' + + 'sylius_admin.taxon.update.content.sections#left': tree: component: 'sylius_admin:taxon:tree' - sections: - template: '@SyliusAdmin/taxon/form/sections.html.twig' - 'sylius_admin.taxon.update.content.form.sections': + 'sylius_admin.taxon.update.content.sections#right': + form: + component: 'sylius_admin:taxon:form' + props: + form: '@=_context.form' + resource: '@=_context.resource' + configuration: + method: 'PUT' + + 'sylius_admin.taxon.update.content.sections.form': details: - template: '@SyliusAdmin/taxon/form/sections/details.html.twig' + template: '@SyliusAdmin/taxon/sections/form/details.html.twig' translations: - template: '@SyliusAdmin/taxon/form/sections/translations.html.twig' - media: - template: '@SyliusAdmin/taxon/form/sections/media.html.twig' - - 'sylius_admin.taxon.update.content.form.sections.details': + template: '@SyliusAdmin/taxon/sections/form/translations.html.twig' + images: + template: '@SyliusAdmin/taxon/sections/form/images.html.twig' + + 'sylius_admin.taxon.update.content.sections.form.details': code: - template: '@SyliusAdmin/taxon/form/sections/details/code.html.twig' + template: '@SyliusAdmin/taxon/sections/form/details/code.html.twig' parent: - template: '@SyliusAdmin/taxon/form/sections/details/parent.html.twig' + template: '@SyliusAdmin/taxon/sections/form/details/parent.html.twig' enabled: - template: '@SyliusAdmin/taxon/form/sections/details/enabled.html.twig' + template: '@SyliusAdmin/taxon/sections/form/details/enabled.html.twig' + + 'sylius_admin.taxon.update.content.sections.form.images': + image: + template: '@SyliusAdmin/taxon/sections/form/images/image.html.twig' + + 'sylius_admin.taxon.update.content.sections.form.images.image#left': + picture: + template: '@SyliusAdmin/taxon/sections/form/images/image/picture.html.twig' + button_delete: + template: '@SyliusAdmin/taxon/sections/form/images/image/button_delete.html.twig' + + 'sylius_admin.taxon.update.content.sections.form.images.image#right': + type: + template: '@SyliusAdmin/taxon/sections/form/images/image/type.html.twig' + file: + template: '@SyliusAdmin/taxon/sections/form/images/image/file.html.twig' diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/taxon.yml b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/taxon.yml index 0881c0f908b..f35b1b0874b 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/routing/taxon.yml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/routing/taxon.yml @@ -6,11 +6,8 @@ sylius_admin_taxon: except: ['show', 'index'] redirect: update permission: true - vars: - all: - subheader: sylius.ui.manage_categorization_of_your_products - templates: - form: "@SyliusAdmin/Taxon/_form.html.twig" + form: + type: Sylius\Bundle\AdminBundle\Form\Type\TaxonType type: sylius.resource sylius_admin_taxon_index: @@ -31,6 +28,8 @@ sylius_admin_taxon_create_for_parent: permission: true template: '@SyliusAdmin/shared/crud/create.html.twig' redirect: sylius_admin_taxon_update + form: + type: Sylius\Bundle\AdminBundle\Form\Type\TaxonType factory: method: createForParent arguments: ['expr:notFoundOnNull(service("sylius.repository.taxon").find($id))'] diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig/component.xml b/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig/component.xml index 98a98e40537..13794f511bd 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig/component.xml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/services/twig/component.xml @@ -274,6 +274,20 @@ /> + + + Sylius\Bundle\AdminBundle\Form\Type\TaxonType + + + + diff --git a/src/Sylius/Bundle/AdminBundle/Twig/Component/Taxon/FormComponent.php b/src/Sylius/Bundle/AdminBundle/Twig/Component/Taxon/FormComponent.php new file mode 100644 index 00000000000..dac98b75526 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Twig/Component/Taxon/FormComponent.php @@ -0,0 +1,46 @@ +formFactory->create($this->formClass, $this->resource); + } +} diff --git a/src/Sylius/Bundle/AdminBundle/Twig/Component/Taxon/TreeComponent.php b/src/Sylius/Bundle/AdminBundle/Twig/Component/Taxon/TreeComponent.php index 0c6f56d5a28..41860b0d4f7 100644 --- a/src/Sylius/Bundle/AdminBundle/Twig/Component/Taxon/TreeComponent.php +++ b/src/Sylius/Bundle/AdminBundle/Twig/Component/Taxon/TreeComponent.php @@ -33,8 +33,8 @@ class TreeComponent * @param TaxonRepositoryInterface $taxonRepository */ public function __construct( - private TaxonRepositoryInterface $taxonRepository, - private ObjectManager $taxonManager, + private readonly TaxonRepositoryInterface $taxonRepository, + private readonly ObjectManager $taxonManager, ) { } diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/component/taxon_tree.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/component/taxon_tree.html.twig deleted file mode 100644 index 1afac51a3d6..00000000000 --- a/src/Sylius/Bundle/AdminBundle/templates/taxon/component/taxon_tree.html.twig +++ /dev/null @@ -1,68 +0,0 @@ -{% import '@SyliusAdmin/taxon/helper/taxon_tree.html.twig' as taxonTree %} - -
-
-
-
- -
- -
- {{ taxonTree.render(rootNodes) }} -
-
-
-
- -{#{% macro render(taxons) %}#} -{# {% import '@SyliusUi/Macro/buttons.html.twig' as buttons %}#} -{# {% import _self as tree %}#} - -{#
    #} -{# {% for taxon in taxons|filter(taxon => taxon.id is not null) %}#} -{#
  • #} -{#
    #} -{#
    #} -{# #} -{#
    #} -{# #} -{#
    #} -{#
    #} -{# #} -{#
    #} -{#
    #} -{#
    #} -{# {{ tree.render(taxon.children) }}#} -{#
  • #} -{# {% endfor %}#} -{#
#} -{#{% endmacro %}#} diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/create/form.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/create/form.html.twig deleted file mode 100644 index 84c9c9955bb..00000000000 --- a/src/Sylius/Bundle/AdminBundle/templates/taxon/create/form.html.twig +++ /dev/null @@ -1,10 +0,0 @@ -{% extends '@SyliusAdmin/shared/crud/create/content/form.html.twig' %} - -{% block form_content %} -
- {{ form_errors(form) }} - {{ form_widget(form._token) }} - - {{ parent() }} -
-{% endblock %} diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections.html.twig deleted file mode 100644 index c76fe7d14d8..00000000000 --- a/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -
- {% hook 'sections' %} -
diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/details/code.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/details/code.html.twig deleted file mode 100644 index b39aacad1d9..00000000000 --- a/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/details/code.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ form_row(hookable_metadata.context.form.code) }} diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/media.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/media.html.twig deleted file mode 100644 index 8a07ae443d3..00000000000 --- a/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/media.html.twig +++ /dev/null @@ -1,29 +0,0 @@ -
-
-

- {{ 'sylius.ui.media'|trans }} {{ 'sylius.ui.work_in_progress'|trans }} -

-
-
-
-
- -
-
-
- - -
-
- - -
-
-
-
- -
diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/form/tree.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/form/tree.html.twig deleted file mode 100644 index db9683d6072..00000000000 --- a/src/Sylius/Bundle/AdminBundle/templates/taxon/form/tree.html.twig +++ /dev/null @@ -1,400 +0,0 @@ -
-
-
-
- -
- -
-
-
diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/helper/taxon_tree.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/helper/tree.html.twig similarity index 92% rename from src/Sylius/Bundle/AdminBundle/templates/taxon/helper/taxon_tree.html.twig rename to src/Sylius/Bundle/AdminBundle/templates/taxon/helper/tree.html.twig index 52c3a78892a..bd931c05195 100644 --- a/src/Sylius/Bundle/AdminBundle/templates/taxon/helper/taxon_tree.html.twig +++ b/src/Sylius/Bundle/AdminBundle/templates/taxon/helper/tree.html.twig @@ -27,7 +27,8 @@ role="button" class="dropdown-item" data-action="live#action" - data-live-action-param="prevent|delete(taxonId={{ taxonId }})" + data-live-action-param="prevent|delete" + data-live-taxon-id-param="{{ taxonId }}" > {{ 'sylius.ui.delete'|trans }} @@ -37,7 +38,8 @@ role="button" class="dropdown-item" data-action="live#action" - data-live-action-param="prevent|moveUp(taxonId={{ taxonId }})" + data-live-action-param="prevent|moveUp" + data-live-taxon-id-param="{{ taxonId }}" > {{ 'sylius.ui.move_up'|trans }} @@ -47,7 +49,8 @@ role="button" class="dropdown-item" data-action="live#action" - data-live-action-param="prevent|moveDown(taxonId={{ taxonId }})" + data-live-action-param="prevent|moveDown" + data-live-taxon-id-param="{{ taxonId }}" > {{ 'sylius.ui.move_down'|trans }} @@ -99,7 +102,7 @@ {% endmacro %} {% macro render(taxons, nested = false) %} - {% import '@SyliusAdmin/taxon/helper/taxon_tree.html.twig' as _self %} + {% import '@SyliusAdmin/taxon/helper/tree.html.twig' as _self %}
    {% if nested == false %} diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/sections.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections.html.twig new file mode 100644 index 00000000000..024b0d1e573 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections.html.twig @@ -0,0 +1,12 @@ +
    +
    +
    +
    + {% hook 'sections#left' %} +
    +
    + {% hook 'sections#right' %} +
    +
    +
    +
    diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form.html.twig new file mode 100644 index 00000000000..43dd134ecd9 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form.html.twig @@ -0,0 +1,16 @@ +{# Rendered with \Sylius\Bundle\AdminBundle\Twig\Component\Taxon\FormComponent #} + +{% form_theme form '@SyliusAdmin/shared/form_theme.html.twig' %} + +
    + {{ form_start(form, {'attr': {'class': 'ui loadable form', 'novalidate': 'novalidate', 'id': form.vars.id}}) }} + {% if hookable_metadata.configuration.method is defined %} + + {% endif %} + {{ form_errors(form) }} + {{ form_widget(form._token) }} + + {% hook 'form' with { form } %} + + {{ form_end(form, {render_rest: hookable.configuration.render_rest|default(false)}) }} +
    diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/details.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/details.html.twig similarity index 100% rename from src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/details.html.twig rename to src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/details.html.twig diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/details/code.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/details/code.html.twig new file mode 100644 index 00000000000..fed599e8cff --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/details/code.html.twig @@ -0,0 +1 @@ +{{ form_row(hookable_metadata.context.form.code, sylius_test_form_attribute('code')) }} diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/details/enabled.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/details/enabled.html.twig similarity index 100% rename from src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/details/enabled.html.twig rename to src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/details/enabled.html.twig diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/details/parent.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/details/parent.html.twig similarity index 100% rename from src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/details/parent.html.twig rename to src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/details/parent.html.twig diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images.html.twig new file mode 100644 index 00000000000..03bc7415e12 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images.html.twig @@ -0,0 +1,22 @@ +{% set form = hookable_metadata.context.form %} + +
    +
    +
    +

    + {{ 'sylius.ui.media'|trans }} +

    +
    +
    +
    + {% for image_form in form.images %} + {% hook 'images' with {form: image_form} %} + {% endfor %} +
    + +
    + {{ form_widget(form.images.vars.button_add, sylius_test_form_attribute('add-image')|sylius_merge_recursive({attr: {class: 'btn btn-outline-primary '}})) }} +
    +
    +
    +
    diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image.html.twig new file mode 100644 index 00000000000..0141ee2333c --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image.html.twig @@ -0,0 +1,14 @@ +{% set form = hookable_metadata.context.form %} + +
    +
    + {% hook "image#left" %} +
    +
    + {% hook "image#right" %} +
    +
    diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image/button_delete.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image/button_delete.html.twig new file mode 100644 index 00000000000..980c1762297 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image/button_delete.html.twig @@ -0,0 +1,3 @@ +
    + {{ form_widget(hookable_metadata.context.form.vars.button_delete, sylius_test_form_attribute('delete-image')|sylius_merge_recursive({attr: { class: 'btn btn-outline-danger w-100'}})) }} +
    diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image/file.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image/file.html.twig new file mode 100644 index 00000000000..247a5c419a9 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image/file.html.twig @@ -0,0 +1,3 @@ +
    + {{ form_row(hookable_metadata.context.form.file, sylius_test_form_attribute('file')) }} +
    diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image/picture.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image/picture.html.twig new file mode 100644 index 00000000000..da07d0ae1b7 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image/picture.html.twig @@ -0,0 +1,7 @@ +
    + {% if hookable_metadata.context.form.vars.value.path is not null %} + + {% else %} + + {% endif %} +
    diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image/type.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image/type.html.twig new file mode 100644 index 00000000000..a8942da99dc --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/images/image/type.html.twig @@ -0,0 +1,3 @@ +
    + {{ form_row(hookable_metadata.context.form.type, sylius_test_form_attribute('type')) }} +
    diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/translations.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/translations.html.twig similarity index 65% rename from src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/translations.html.twig rename to src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/translations.html.twig index d6ef263f5fc..15887f9d048 100644 --- a/src/Sylius/Bundle/AdminBundle/templates/taxon/form/sections/translations.html.twig +++ b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/form/translations.html.twig @@ -3,12 +3,13 @@
    {% set body %} {% verbatim %} -
    +
    + + + + + +
    {{ form_row(translationForm.name, { attr: { 'data-taxon-slug-target': 'sluggable', 'data-action': 'change->taxon-slug#generateSlug' } }) }}
    diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/tree.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/tree.html.twig new file mode 100644 index 00000000000..66b17ae21e6 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/templates/taxon/sections/tree.html.twig @@ -0,0 +1,16 @@ +{# Rendered with \Sylius\Bundle\AdminBundle\Twig\Component\Taxon\TreeComponent #} + +{% import '@SyliusAdmin/taxon/helper/tree.html.twig' as taxonTree %} + +
    +
    +
    +
    + +
    +
    + {{ taxonTree.render(rootNodes) }} +
    +
    +
    +
    diff --git a/src/Sylius/Bundle/AdminBundle/templates/taxon/update/form.html.twig b/src/Sylius/Bundle/AdminBundle/templates/taxon/update/form.html.twig deleted file mode 100644 index 3c598c1e031..00000000000 --- a/src/Sylius/Bundle/AdminBundle/templates/taxon/update/form.html.twig +++ /dev/null @@ -1,10 +0,0 @@ -{% extends '@SyliusAdmin/shared/crud/update/content/form.html.twig' %} - -{% block form_content %} -
    - {{ form_errors(form) }} - {{ form_widget(form._token) }} - - {{ parent() }} -
    -{% endblock %}