diff --git a/features/admin/addressing/managing_countries/adding_country.feature b/features/admin/addressing/managing_countries/adding_country.feature index 37e5b6a1b7..513893b38d 100644 --- a/features/admin/addressing/managing_countries/adding_country.feature +++ b/features/admin/addressing/managing_countries/adding_country.feature @@ -7,7 +7,7 @@ Feature: Adding a new country Background: Given I am logged in as an administrator - @ui @api + @api @ui Scenario: Adding country When I want to add a new country And I choose "United States" diff --git a/features/admin/addressing/managing_countries/adding_country_with_provinces.feature b/features/admin/addressing/managing_countries/adding_country_with_provinces.feature index 5986d02e2d..ad44751123 100644 --- a/features/admin/addressing/managing_countries/adding_country_with_provinces.feature +++ b/features/admin/addressing/managing_countries/adding_country_with_provinces.feature @@ -7,7 +7,7 @@ Feature: Adding countries with provinces Background: Given I am logged in as an administrator - @ui @javascript @api + @api @ui @javascript Scenario: Adding a country with a province When I want to add a new country And I choose "United Kingdom" @@ -17,7 +17,7 @@ Feature: Adding countries with provinces And the country "United Kingdom" should appear in the store And the country "United Kingdom" should have the "Scotland" province - @ui @javascript @api + @api @ui @javascript Scenario: Adding a country with two provinces When I want to add a new country And I choose "United Kingdom" diff --git a/features/admin/addressing/managing_countries/country_validation.feature b/features/admin/addressing/managing_countries/country_validation.feature index d28b115898..b9813ad67c 100644 --- a/features/admin/addressing/managing_countries/country_validation.feature +++ b/features/admin/addressing/managing_countries/country_validation.feature @@ -8,7 +8,7 @@ Feature: Country validation Given the store operates in "Norway" And I am logged in as an administrator - @todo @ui @api + @api @ui Scenario: Trying to add a new country with used code When I want to add a new country Then I should not be able to choose "Norway" diff --git a/features/admin/addressing/managing_countries/editing_country.feature b/features/admin/addressing/managing_countries/editing_country.feature index 611628811d..b65a785917 100644 --- a/features/admin/addressing/managing_countries/editing_country.feature +++ b/features/admin/addressing/managing_countries/editing_country.feature @@ -7,7 +7,7 @@ Feature: Editing country Background: Given I am logged in as an administrator - @todo @ui @api + @api @ui Scenario: Disabling country Given the store has country "United States" When I want to edit this country @@ -16,7 +16,7 @@ Feature: Editing country Then I should be notified that it has been successfully edited And this country should be disabled - @todo @ui @api + @api @ui Scenario: Enabling country Given the store has disabled country "United States" When I want to edit this country @@ -25,7 +25,7 @@ Feature: Editing country Then I should be notified that it has been successfully edited And this country should be enabled - @todo @ui @api + @api @ui Scenario: Seeing disabled code field while editing country Given the store has country "United States" When I want to edit this country diff --git a/features/admin/addressing/managing_countries/managing_provinces_of_country.feature b/features/admin/addressing/managing_countries/managing_provinces_of_country.feature index 9df9f6a565..cc143c7cf0 100644 --- a/features/admin/addressing/managing_countries/managing_provinces_of_country.feature +++ b/features/admin/addressing/managing_countries/managing_provinces_of_country.feature @@ -8,7 +8,7 @@ Feature: Managing provinces of a country Given the store has country "United Kingdom" And I am logged in as an administrator - @todo @ui @javascript @api + @api @ui @javascript Scenario: Adding a province to an existing country When I want to edit this country And I add the "Scotland" province with "GB-SCT" code @@ -16,7 +16,7 @@ Feature: Managing provinces of a country Then I should be notified that it has been successfully edited And this country should have the "Scotland" province - @todo @ui @javascript @api + @api @ui @javascript Scenario: Removing a province from an existing country Given this country has the "Northern Ireland" province with "GB-NIR" code When I want to edit this country @@ -25,7 +25,7 @@ Feature: Managing provinces of a country Then I should be notified that it has been successfully edited And this country should not have the "Northern Ireland" province - @todo @ui @javascript @api + @api @ui @javascript Scenario: Removing a province that is a zone member should not be possible Given this country has the "Northern Ireland" province with "GB-NIR" code And this country also has the "Scotland" province with "GB-SCT" code @@ -43,7 +43,7 @@ Feature: Managing provinces of a country And this country should still have the "Scotland" province And this country should still have the "England" province - @todo @ui @javascript @api + @api @ui @javascript Scenario: Removing a province that is not a zone member anymore should be possible Given this country has the "Northern Ireland" province with "GB-NIR" code And this country also has the "Scotland" province with "GB-SCT" code @@ -60,18 +60,18 @@ Feature: Managing provinces of a country And this country should not have the "England" province And this country should still have the "Northern Ireland" and "Scotland" provinces - @todo @ui @javascript @api + @api @ui @javascript Scenario: Removing and adding a new province to an existing country Given this country has the "Northern Ireland" province with "GB-NIR" code When I want to edit this country - And I delete the "Northern Ireland" province of this country And I add the "Scotland" province with "GB-SCT" code + And I delete the "Northern Ireland" province of this country And I save my changes Then I should be notified that it has been successfully edited And this country should not have the "Northern Ireland" province And this country should have the "Scotland" province - @todo @ui @javascript @api + @api @ui @javascript Scenario: Adding a province with an austrian province code When I want to edit this country And I add the "Wien" province with "AT-9" code diff --git a/features/admin/addressing/managing_countries/province_unique_fields_validation.feature b/features/admin/addressing/managing_countries/province_unique_fields_validation.feature index f208a8db99..51bc65c210 100644 --- a/features/admin/addressing/managing_countries/province_unique_fields_validation.feature +++ b/features/admin/addressing/managing_countries/province_unique_fields_validation.feature @@ -9,7 +9,7 @@ Feature: Province unique fields validation And this country has the "Northern Ireland" province with "GB-NIR" code And I am logged in as an administrator - @todo @ui @javascript @api + @api @ui @javascript Scenario: Trying to add a new province with a taken code When I want to add a new country And I choose "Gibraltar" @@ -17,14 +17,14 @@ Feature: Province unique fields validation And I try to add it Then I should be notified that province code must be unique - @todo @ui @javascript @api + @api @ui @javascript Scenario: Trying to add a new province with a taken name When I want to edit this country And I add the "Northern Ireland" province with "GB-NI" code And I save my changes Then I should be notified that province name must be unique - @todo @ui @javascript @api + @api @ui @javascript Scenario: Trying to add new provinces with duplicated codes When I want to edit this country And I add the "Scotland" province with "GB-SCO" code @@ -32,7 +32,7 @@ Feature: Province unique fields validation And I save my changes Then I should be notified that all province codes and names within this country need to be unique - @todo @ui @javascript @api + @api @ui @javascript Scenario: Trying to add new provinces with duplicated names When I want to edit this country And I add the "Scotland" province with "GB-SC" code diff --git a/features/admin/addressing/managing_countries/province_validation.feature b/features/admin/addressing/managing_countries/province_validation.feature index d0d9ee178a..85b8c6284b 100644 --- a/features/admin/addressing/managing_countries/province_validation.feature +++ b/features/admin/addressing/managing_countries/province_validation.feature @@ -8,7 +8,7 @@ Feature: Province validation Given the store has country "United Kingdom" And I am logged in as an administrator - @todo @ui @javascript @api + @api @ui @javascript Scenario: Trying to add a new province without specifying its code When I want to create a new province in country "United Kingdom" And I name the province "Scotland" @@ -17,7 +17,7 @@ Feature: Province validation Then I should be notified that code is required And province with name "Scotland" should not be added in this country - @todo @ui @javascript @api + @api @ui @javascript Scenario: Trying to add a new province without specifying its name When I want to create a new province in country "United Kingdom" And I specify the province code as "GB-SCT" @@ -26,7 +26,7 @@ Feature: Province validation Then I should be notified that name is required And province with code "GB-SCT" should not be added in this country - @todo @ui @javascript @api + @api @ui @javascript Scenario: Trying to remove name from an existing province Given this country has the "Northern Ireland" province with "GB-NIR" code When I want to edit this country diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingCountriesContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingCountriesContext.php index eff583bd51..a8f0e6f486 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingCountriesContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingCountriesContext.php @@ -97,7 +97,7 @@ final class ManagingCountriesContext implements Context /** * @When I disable it */ - public function iDisableIt() + public function iDisableIt(): void { $this->updatePage->disable(); } @@ -134,7 +134,7 @@ final class ManagingCountriesContext implements Context /** * @Then /^(this country) should be disabled$/ */ - public function thisCountryShouldBeDisabled(CountryInterface $country) + public function thisCountryShouldBeDisabled(CountryInterface $country): void { $this->indexPage->open(); @@ -144,10 +144,10 @@ final class ManagingCountriesContext implements Context /** * @Then I should not be able to choose :name */ - public function iShouldNotBeAbleToChoose($name) + public function iShouldNotBeAbleToChoose(string $name): void { try { - $this->createPage->chooseName($name); + $this->createPage->selectCountry($name); } catch (ElementNotFoundException) { return; } @@ -158,7 +158,7 @@ final class ManagingCountriesContext implements Context /** * @Then I should not be able to edit its code */ - public function theCodeFieldShouldBeDisabled() + public function theCodeFieldShouldBeDisabled(): void { Assert::true($this->updatePage->isCodeFieldDisabled()); } @@ -220,7 +220,7 @@ final class ManagingCountriesContext implements Context /** * @When /^I(?:| also) delete the "([^"]*)" province of this country$/ */ - public function iDeleteTheProvinceOfCountry($provinceName) + public function iDeleteTheProvinceOfCountry($provinceName): void { $this->updatePage->removeProvince($provinceName); } @@ -228,27 +228,27 @@ final class ManagingCountriesContext implements Context /** * @When /^I want to create a new province in (country "([^"]*)")$/ */ - public function iWantToCreateANewProvinceInCountry(CountryInterface $country) + public function iWantToCreateANewProvinceInCountry(CountryInterface $country): void { $this->updatePage->open(['id' => $country->getId()]); - $this->updatePage->clickAddProvinceButton(); + $this->updatePage->addProvince(); } /** * @When I name the province :provinceName * @When I do not name the province */ - public function iNameTheProvince($provinceName = null) + public function iNameTheProvince($provinceName = null): void { - $this->updatePage->nameProvince($provinceName ?? ''); + $this->updatePage->specifyProvinceName($provinceName ?? ''); } /** * @When I do not specify the province code * @When I specify the province code as :provinceCode */ - public function iSpecifyTheProvinceCode($provinceCode = null) + public function iSpecifyTheProvinceCode($provinceCode = null): void { $this->updatePage->specifyProvinceCode($provinceCode ?? ''); } diff --git a/src/Sylius/Behat/Page/Admin/Country/CreatePage.php b/src/Sylius/Behat/Page/Admin/Country/CreatePage.php index e49d80008a..498fd17376 100644 --- a/src/Sylius/Behat/Page/Admin/Country/CreatePage.php +++ b/src/Sylius/Behat/Page/Admin/Country/CreatePage.php @@ -13,8 +13,6 @@ declare(strict_types=1); namespace Sylius\Behat\Page\Admin\Country; -use Behat\Mink\Element\NodeElement; -use Sylius\Behat\Behaviour\ChoosesName; use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage; use Webmozart\Assert\Assert; diff --git a/src/Sylius/Behat/Page/Admin/Country/CreatePageInterface.php b/src/Sylius/Behat/Page/Admin/Country/CreatePageInterface.php index 9845f82ead..45ba678c94 100644 --- a/src/Sylius/Behat/Page/Admin/Country/CreatePageInterface.php +++ b/src/Sylius/Behat/Page/Admin/Country/CreatePageInterface.php @@ -17,6 +17,8 @@ use Sylius\Behat\Page\Admin\Crud\CreatePageInterface as BaseCreatePageInterface; interface CreatePageInterface extends BaseCreatePageInterface { + public function selectCountry(string $countryName): void; + public function addProvince(): void; public function specifyProvinceName(string $name): void; @@ -24,6 +26,4 @@ interface CreatePageInterface extends BaseCreatePageInterface public function specifyProvinceCode(string $code): void; public function specifyProvinceAbbreviation(string $abbreviation): void; - - public function selectCountry(string $countryName): void; } diff --git a/src/Sylius/Behat/Page/Admin/Country/IndexPage.php b/src/Sylius/Behat/Page/Admin/Country/IndexPage.php index dc07e2458f..6d2374305f 100644 --- a/src/Sylius/Behat/Page/Admin/Country/IndexPage.php +++ b/src/Sylius/Behat/Page/Admin/Country/IndexPage.php @@ -20,12 +20,12 @@ class IndexPage extends BaseIndexPage implements IndexPageInterface { public function isCountryDisabled(CountryInterface $country): bool { - return $this->checkCountryStatus($country, 'Disabled'); + return $this->checkCountryStatus($country, 'disabled'); } public function isCountryEnabled(CountryInterface $country): bool { - return $this->checkCountryStatus($country, 'Enabled'); + return $this->checkCountryStatus($country, 'enabled'); } private function checkCountryStatus(CountryInterface $country, string $status): bool @@ -36,6 +36,6 @@ class IndexPage extends BaseIndexPage implements IndexPageInterface $row = $tableAccessor->getRowWithFields($table, ['code' => $country->getCode()]); $enabledField = $tableAccessor->getFieldFromRow($table, $row, 'enabled'); - return $enabledField->getText() === $status; + return $enabledField->has('css', sprintf('[data-test-status-%s]', $status)); } } diff --git a/src/Sylius/Behat/Page/Admin/Country/UpdatePage.php b/src/Sylius/Behat/Page/Admin/Country/UpdatePage.php index 51542405b1..4233b9567b 100644 --- a/src/Sylius/Behat/Page/Admin/Country/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/Country/UpdatePage.php @@ -30,6 +30,33 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface return $codeField->getAttribute('disabled') === 'disabled'; } + public function addProvince(): void + { + $count = count($this->getProvinceItems()); + + $this->getElement('add_province')->click(); + + $this->getDocument()->waitFor(5, fn () => $count + 1 === count($this->getProvinceItems())); + } + + public function specifyProvinceName(string $name): void + { + $province = $this->getElement('last_province'); + $province->find('css', '[data-test-province-name]')->setValue($name); + } + + public function specifyProvinceCode(string $code): void + { + $province = $this->getElement('last_province'); + $province->find('css', '[data-test-province-code]')->setValue($code); + } + + public function specifyProvinceAbbreviation(string $abbreviation): void + { + $province = $this->getElement('last_province'); + $province->find('css', '[data-test-province-abbreviation]')->setValue($abbreviation); + } + public function isThereProvince(string $provinceName): bool { $provinces = $this->getElement('provinces'); @@ -47,78 +74,36 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface public function removeProvince(string $provinceName): void { if ($this->isThereProvince($provinceName)) { - $provinces = $this->getElement('provinces'); + $province = $this->getProvinceElement($provinceName); - $item = $provinces - ->find('css', sprintf('div[data-form-collection="item"] input[value="%s"]', $provinceName)) - ->getParent() - ->getParent() - ->getParent() - ->getParent() - ->getParent() - ; - - $item->clickLink('Delete'); + $province->find('css', '[data-test-delete-province]')->click(); + $this->getDocument()->waitFor(5, fn () => !$this->isThereProvince($provinceName)); } } - public function addProvince(string $name, string $code, string $abbreviation = null): void - { - $this->clickAddProvinceButton(); - - $provinceForm = $this->getLastProvinceElement(); - - $provinceForm->fillField('Name', $name); - $provinceForm->fillField('Code', $code); - - if (null !== $abbreviation) { - $provinceForm->fillField('Abbreviation', $abbreviation); - } - } - - public function clickAddProvinceButton(): void - { - $this->getDocument()->clickLink('Add province'); - } - - public function nameProvince(string $name): void - { - $provinceForm = $this->getLastProvinceElement(); - - $provinceForm->fillField('Name', $name); - } - public function removeProvinceName(string $provinceName): void { if ($this->isThereProvince($provinceName)) { - $provinces = $this->getElement('provinces'); - - $item = $provinces->find('css', 'div[data-form-collection="item"] input[value="' . $provinceName . '"]')->getParent(); - $item->fillField('Name', ''); + $province = $this->getProvinceElement($provinceName); + $province->find('css', '[data-test-province-name]')->setValue(''); } } - public function specifyProvinceCode(string $code): void - { - $provinceForm = $this->getLastProvinceElement(); - - $provinceForm->fillField('Code', $code); - } public function getFormValidationErrors(): array { - $errors = $this->getElement('form')->findAll('css', '.sylius-validation-error:not(.pointing)'); + $errors = $this->getElement('form')->findAll('css', '.alert-danger'); return array_map(fn (NodeElement $element) => $element->getText(), $errors); } public function getValidationMessage(string $element): string { - $provinceForm = $this->getLastProvinceElement(); + $province = $this->getElement('last_province'); - $foundElement = $provinceForm->find('css', '.sylius-validation-error'); + $foundElement = $province->find('css', '.invalid-feedback'); if (null === $foundElement) { - throw new ElementNotFoundException($this->getSession(), 'Tag', 'css', '.sylius-validation-error'); + throw new ElementNotFoundException($this->getSession(), 'Tag', 'css', '.invalid-feedback'); } return $foundElement->getText(); @@ -135,22 +120,22 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface 'code' => '[data-test-code]', 'enabled' => '[data-test-enabled]', 'provinces' => '[data-test-provinces]', -// 'last_province' => '[data-test-provinces] [data-test-province]:last-child', -// 'add_province' => '[data-test-add-province]' -// 'code' => '#sylius_country_code', -// 'enabled' => '#sylius_country_enabled', -// 'form' => 'form', -// 'provinces' => '#sylius_country_provinces', + 'last_province' => '[data-test-provinces] [data-test-province]:last-child', + 'add_province' => '[data-test-add-province]', + 'form' => 'form', ]); } - private function getLastProvinceElement(): NodeElement + private function getProvinceItems(): array { - $provinces = $this->getElement('provinces'); - $items = $provinces->findAll('css', 'div[data-form-collection="item"]'); + $items = $this->getElement('provinces')->findAll('css', '[data-test-province]'); + Assert::isArray($items); - Assert::notEmpty($items); + return $items; + } - return end($items); + private function getProvinceElement(string $provinceName): NodeElement|null + { + return $this->getDocument()->find('xpath', sprintf('//*[@data-test-province and .//*[contains(@value, \'%s\')]]', $provinceName)); } } diff --git a/src/Sylius/Behat/Page/Admin/Country/UpdatePageInterface.php b/src/Sylius/Behat/Page/Admin/Country/UpdatePageInterface.php index 642c1f0bc2..69592dc510 100644 --- a/src/Sylius/Behat/Page/Admin/Country/UpdatePageInterface.php +++ b/src/Sylius/Behat/Page/Admin/Country/UpdatePageInterface.php @@ -23,22 +23,20 @@ interface UpdatePageInterface extends BaseUpdatePageInterface public function isCodeFieldDisabled(): bool; + public function addProvince(): void; + + public function specifyProvinceName(string $name): void; + + public function specifyProvinceCode(string $code): void; + + public function specifyProvinceAbbreviation(string $abbreviation): void; + public function isThereProvince(string $provinceName): bool; public function isThereProvinceWithCode(string $provinceCode): bool; - public function addProvince(string $name, string $code, string $abbreviation = null): void; - public function removeProvince(string $provinceName): void; - public function clickAddProvinceButton(): void; - - public function nameProvince(string $provinceName): void; - - public function removeProvinceName(string $provinceName): void; - - public function specifyProvinceCode(string $provinceCode): void; - /** @return array */ public function getFormValidationErrors(): array; } diff --git a/src/Sylius/Behat/Page/Admin/Crud/UpdatePage.php b/src/Sylius/Behat/Page/Admin/Crud/UpdatePage.php index af2989c39a..f5d871354c 100644 --- a/src/Sylius/Behat/Page/Admin/Crud/UpdatePage.php +++ b/src/Sylius/Behat/Page/Admin/Crud/UpdatePage.php @@ -35,7 +35,7 @@ class UpdatePage extends SymfonyPage implements UpdatePageInterface public function saveChanges(): void { - $this->getDocument()->pressButton('sylius_save_changes_button'); + $this->getDocument()->find('css', '[data-test-update-changes-button]')->click(); } public function cancelChanges(): void diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Country/Form/ComponentForm/Sections/Details/_enabled.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Country/Form/ComponentForm/Sections/Details/_enabled.html.twig index ac6ffae7df..96853c6227 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Country/Form/ComponentForm/Sections/Details/_enabled.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Country/Form/ComponentForm/Sections/Details/_enabled.html.twig @@ -1 +1 @@ -{{ form_row(form.enabled, { label_attr: { class: 'checkbox-switch' } }, sylius_test_form_attribute('enabled')) }} +{{ form_row(form.enabled, sylius_test_form_attribute('enabled')|merge({ label_attr: { class: 'checkbox-switch' } })) }} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Country/Form/ComponentForm/Sections/_provinces.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Country/Form/ComponentForm/Sections/_provinces.html.twig index 9e5605b5f0..9241c8bdf4 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Country/Form/ComponentForm/Sections/_provinces.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Country/Form/ComponentForm/Sections/_provinces.html.twig @@ -36,8 +36,8 @@ -
- {{ form_row(provinceForm.vars.button_delete, {label: 'X', attr: {class: 'btn btn-outline-danger'}}) }} +
+ {{ form_row(provinceForm.vars.button_delete, {attr: {class: 'btn btn-outline-danger'}}) }}
diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/Actions/_cancel.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/Actions/_cancel.html.twig index 7317bdc21d..b973872ebb 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/Actions/_cancel.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/Actions/_cancel.html.twig @@ -5,4 +5,4 @@ configuration.vars.index.route.parameters|default(configuration.vars.route.parameters|default({})) ) %} -{{ _button.cancel({ text: 'sylius.ui.cancel'|trans, url: index_url, class: 'btn' }) }} +{{ _button.cancel(sylius_test_form_attribute('cancel-changes-button')|merge({ text: 'sylius.ui.cancel'|trans, url: index_url, class: 'btn' })) }} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/Actions/_update.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/Actions/_update.html.twig index 825aaa3fda..b3af6d4481 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/Actions/_update.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Crud/Common/Content/Header/TitleBlock/Actions/_update.html.twig @@ -1,3 +1,3 @@ {% import '@SyliusAdmin/Shared/Helper/button.html.twig' as _button %} -{{ _button.primary({ text: 'sylius.ui.update'|trans, type: 'submit', form: form.vars.id }) }} +{{ _button.primary(sylius_test_form_attribute('update-changes-button')|merge({ text: 'sylius.ui.update'|trans, type: 'submit', form: form.vars.id })) }} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Field/boolean.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Field/boolean.html.twig index abb518de17..c0922ef373 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Field/boolean.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Grid/Field/boolean.html.twig @@ -1,7 +1,7 @@ {% from '@SyliusAdmin/Shared/Helper/icon.html.twig' import icon as _icon %} {% if true == data %} - {{ _icon({ icon: 'check', class: 'icon text-green' }) }} + {{ _icon({ icon: 'check', class: 'icon text-green' }) }} {% else %} - {{ _icon({ icon: 'x', class: 'icon icon-sm text-secondary' }) }} + {{ _icon({ icon: 'x', class: 'icon icon-sm text-secondary' }) }} {% endif %} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/button.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/button.html.twig index dc064fc0be..7ece9fd77d 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/button.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Shared/Helper/button.html.twig @@ -30,7 +30,7 @@ class="{{ buttonClass }}" {% if p.disabled %}aria-disabled="true"{% endif %} {% if p.dropdown %}data-bs-toggle="dropdown"{% endif %} - {{ p.attr }}> + {{ block('attributes') }}> {{ p.icon ? i({ icon: p.icon }) }} {{ not p.iconOnly ? p.text }} @@ -41,7 +41,7 @@ class="{{ buttonClass }}" {% if p.disabled %}disabled{% endif %} {% if p.dropdown %}data-bs-toggle="dropdown"{% endif %} - {{ p.attr }}> + {{ block('attributes') }}> {{ p.icon ? i({ icon: p.icon }) }} {{ not p.iconOnly ? p.text }} @@ -98,3 +98,14 @@ {{ _.default(params) }} {% endmacro %} + +{% block attributes -%} + {%- for attrname, attrvalue in p.attr -%} + {{- " " -}} + {%- if attrvalue is same as(true) -%} + {{- attrname }}="{{ attrname }}" + {%- elseif attrvalue is not same as(false) -%} + {{- attrname }}="{{ attrvalue }}" + {%- endif -%} + {%- endfor -%} +{%- endblock attributes -%}