From 62ae3dd3f2880f4c0d2a5ec33747c3f2f8448f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sva=C5=A5a=20=C5=A0imara?= Date: Mon, 24 Sep 2018 07:51:21 +0200 Subject: [PATCH] custom template for extended product form is no longer needed because ProductFormType is rendered in default fashion - added groups to ProductFormTypeExtension - tests updated appropriately --- .../Admin/Content/Product/detail.html.twig | 318 ------------------ .../Form/Admin/ProductFormTypeExtension.php | 6 +- .../acceptance/ProductImageUploadCest.php | 2 +- tests/ShopBundle/Smoke/NewProductTest.php | 24 +- 4 files changed, 17 insertions(+), 333 deletions(-) delete mode 100644 app/Resources/ShopsysFrameworkBundle/views/Admin/Content/Product/detail.html.twig diff --git a/app/Resources/ShopsysFrameworkBundle/views/Admin/Content/Product/detail.html.twig b/app/Resources/ShopsysFrameworkBundle/views/Admin/Content/Product/detail.html.twig deleted file mode 100644 index c928a259d..000000000 --- a/app/Resources/ShopsysFrameworkBundle/views/Admin/Content/Product/detail.html.twig +++ /dev/null @@ -1,318 +0,0 @@ -{% extends '@!ShopsysFramework/Admin/Content/Product/detail.html.twig' %} -{% set showHeading = false %} -{% import '@ShopsysFramework/Admin/Form/seoFormRowMacros.html.twig' as seoFormRowMacros %} -{% import _self as self %} - -{% block main_content %} - {% if isMultidomain() %} - {% set cssClassOnMultidomainInputs = 'input--domain' %} - {% else %} - {% set cssClassOnMultidomainInputs = '' %} - {% endif %} - - {{ form_start(form) }} -
- {{ form_errors(form) }} - -
-
-
-
{{ 'Name'|trans }}
-
-
- {% for locale, formName in form.productData.name %} -
-
- {{ form_widget(formName, { attr: { class: 'input--flag form-full__field__input'} }) }} - - {{ localeFlag(locale) }} - -
- {{ form_errors(formName) }} -
- {% endfor %} -
-
- - {% block product_variants %}{% endblock %} - -
- -
- {{ 'Basic information'|trans }} -
- - {% block product_catnum %} - {{ form_row(form.productData.catnum, { label: 'Catalogue number'|trans }) }} - {% endblock %} - - {% block product_partno %} - {{ form_row(form.productData.partno, { label: 'PartNo (serial number)'|trans }) }} - {% endblock %} - - {% block product_ean %} - {{ form_row(form.productData.ean, { label: 'EAN'|trans }) }} - {% endblock %} - - {{ form_id(product|default(null)) }} - - {{ form_row(form.productData.brand, { label: 'Brand'|trans}) }} - - {{ form_row(form.productData.condition) }} - -
- -
- -
- {{ 'Display and availability'|trans }} -
- - {{ form_row(form.productData.hidden, { label: 'Hide product'|trans }) }} - - {% block product_calculated_hidden_info %}{% endblock %} - - {{ form_row(form.productData.sellingFrom, { label: 'Selling start date'|trans }) }} - - {{ form_row(form.productData.sellingTo, { label: 'Selling end date'|trans }) }} - - {{ form_row(form.productData.sellingDenied, { label: 'Exclude from sale'|trans, - icon: { - title: 'Products excluded from sale can\'t be displayed on lists and can\'t be searched. Product detail is available by direct access from the URL, but it is not possible to add product to cart.'|trans - } }) }} - - {% block product_calculated_selling_denied_info %}{% endblock %} - - {% block product_main_categories %}{% endblock %} - - {% block product_categories %} -
- {{ form_label(form.productData.categoriesByDomainId, 'Assign to category'|trans) }} -
- {% for domainId, categoriesForm in form.productData.categoriesByDomainId %} -
- {% if isMultidomain() %} -
- - {{ domainIcon(domainId, 'large') }} - - {{ getDomainName(domainId) }} -
- {% endif %} - - {{ form_widget(categoriesForm) }} - {{ form_errors(categoriesForm) }} -
-
- {% endfor %} -
-
- {% endblock %} - - {{ form_row(form.productData.unit, { label: 'Unit'|trans }) }} - - {% block product_stock_and_availability %} - {{ form_row(form.productData.usingStock, { label: 'Use stocks'|trans }) }} -
- {{ form_row(form.productData.stockQuantity, { label: 'Available in stock'|trans }) }} - {{ form_row(form.productData.outOfStockAction, { label: 'Action after sellout'|trans }) }} -
- {{ form_row(form.productData.outOfStockAvailability, { label: 'Availability after sellout'|trans }) }} -
-
-
- {{ form_row(form.productData.availability, { label: 'Availability'|trans }) }} -
- {% endblock %} - - {{ form_row(form.productData.orderingPriority, { label: 'Sorting priority'|trans }) }} - - - -
- -
- {{ 'Prices'|trans }} -
- - {% block product_pricing %} - {{ form_row(form.productData.priceCalculationType, { label: 'Sale prices calculation'|trans }) }} - {{ form_row(form.productData.vat, { label: 'VAT'|trans }) }} - - {% block product_calculated_prices %}{% endblock %} - {% endblock %} - -
- -
- {% block product_description %} -
- {{ 'Description'|trans }} -
- - {% for domainId, descriptionForm in form.productData.descriptions %} - {% if isMultidomain() %} -
-
- - {{ domainIcon(domainId, 'large') }} - - {{ getDomainName(domainId) }} -
-
- {% endif %} -
-
- {{ form_widget(descriptionForm) }} -
-
- - {% endfor %} - {% endblock %} -
- -
- {% block product_short_description %} -
- {{ 'Short description'|trans }} -
- - {% for domainId, shortDescriptionForm in form.productData.shortDescriptions %} - {% if isMultidomain() %} -
-
- - {{ domainIcon(domainId, 'large') }} - - {{ getDomainName(domainId) }} -
-
- {% endif %} -
-
- {{ form_widget(shortDescriptionForm) }} -
-
- {% endfor %} - {% endblock %} -
- -
-
- {{ 'Parameters'|trans }} - - {{ form_errors(form.parameters) }} -
- - - - - - - - - - - {% macro parameterRow(parameter, index) %} - - - - - - - {% endmacro %} - - {% for key, parameter in form.parameters %} - {{ self.parameterRow(parameter, key) }} - {% else %} - {% do form.parameters.setRendered %} - {% endfor %} - - - - - -
{{ 'Parameter'|trans }}{{ 'Value'|trans }}
- {{ form_widget(parameter.parameter, { isSimple: true} ) }} - - - - {% for locale, valueTextLocaleForm in parameter.valueTextsByLocale %} -
- {{ form_widget(valueTextLocaleForm, { attr: { class: 'input--flag'} }) }} - - {{ localeFlag(locale) }} - - {{ form_errors(valueTextLocaleForm, { errors_attr: { class: 'table-form__cell__error' } } ) }} -
- {% endfor %} -
- -
{{ 'Add some parameters'|trans }}
- - -
- -
-
- {{ 'SEO'|trans }} -
- - {{ seoFormRowMacros.multidomainRow(form.productData.seoTitles, 'Page title'|trans, 60) }} - - {{ seoFormRowMacros.multidomainRow(form.productData.seoMetaDescriptions, 'Meta description'|trans, 155, 'input--seo') }} - - {{ seoFormRowMacros.multidomainRow(form.productData.seoH1s, 'Heading (H1)'|trans) }} - - {% block product_urls %}{% endblock %} -
- -
-
- {{ 'Images'|trans }} -
- {{ form_row(form.images) }} -
- -
-
- {{ 'Accessories'|trans }} -
- {{- form_errors(form.accessories) -}} -
-
- {{- form_widget(form.accessories) -}} -
- - {% if form.pluginData is empty %} - {% do form.pluginData.setRendered %} - {% else %} - {% for pluginForm in form.pluginData %} -
-
- {{ pluginForm.vars.label }} -
- - {{ form_widget(pluginForm) }} - {{ form_errors(pluginForm) }} -
- {% endfor %} - {% endif %} - - {% embed '@ShopsysFramework/Admin/Inline/FixedBar/fixedBar.html.twig' %} - {% block fixed_bar_content %} - - {{ form_save(product|default(null), form) }} - {% endblock %} - {% endembed %} - - {{ form_end(form) }} - -{% endblock %} \ No newline at end of file diff --git a/src/Shopsys/ShopBundle/Form/Admin/ProductFormTypeExtension.php b/src/Shopsys/ShopBundle/Form/Admin/ProductFormTypeExtension.php index 350b2c583..09fb89981 100644 --- a/src/Shopsys/ShopBundle/Form/Admin/ProductFormTypeExtension.php +++ b/src/Shopsys/ShopBundle/Form/Admin/ProductFormTypeExtension.php @@ -25,13 +25,15 @@ public function __construct(ProductConditionFacade $productConditionFacade) */ public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('condition', ChoiceType::class, [ + $basicInformationGroupBuilder = $builder->get('basicInformationGroup'); + + $basicInformationGroupBuilder->add('condition', ChoiceType::class, [ 'required' => true, 'choices' => $this->productConditionFacade->getAll(), 'label' => t('Condition'), ]); - $builder->remove('flags'); + $basicInformationGroupBuilder->remove('flags'); } /** diff --git a/tests/ShopBundle/Acceptance/acceptance/ProductImageUploadCest.php b/tests/ShopBundle/Acceptance/acceptance/ProductImageUploadCest.php index be37397aa..cb73814b5 100644 --- a/tests/ShopBundle/Acceptance/acceptance/ProductImageUploadCest.php +++ b/tests/ShopBundle/Acceptance/acceptance/ProductImageUploadCest.php @@ -8,7 +8,7 @@ class ProductImageUploadCest { - const IMAGE_UPLOAD_FIELD_ID = 'product_edit_form_images_file'; + const IMAGE_UPLOAD_FIELD_ID = 'product_edit_form_imageGroup_images_file'; const SAVE_BUTTON_NAME = 'product_edit_form[save]'; const EXPECTED_SUCCESS_MESSAGE = 'Product 22" Sencor SLE 22F46DM4 HELLO KITTY modified'; diff --git a/tests/ShopBundle/Smoke/NewProductTest.php b/tests/ShopBundle/Smoke/NewProductTest.php index 0cde81938..503309c86 100644 --- a/tests/ShopBundle/Smoke/NewProductTest.php +++ b/tests/ShopBundle/Smoke/NewProductTest.php @@ -56,22 +56,22 @@ public function testCreateOrEditProduct($relativeUrl) */ private function fillForm(Form $form) { - $nameForms = $form->get('product_edit_form[productData][name]'); + $nameForms = $form->get('product_edit_form[name]'); /* @var $nameForms \Symfony\Component\DomCrawler\Field\InputFormField[] */ foreach ($nameForms as $nameForm) { $nameForm->setValue('testProduct'); } - $form['product_edit_form[productData][catnum]'] = '123456'; - $form['product_edit_form[productData][partno]'] = '123456'; - $form['product_edit_form[productData][ean]'] = '123456'; - $form['product_edit_form[productData][descriptions][1]'] = 'test description'; - $form['product_edit_form[productData][price]'] = '10000'; - $form['product_edit_form[productData][vat]']->select($this->getReference(VatDataFixture::VAT_ZERO)->getId()); - $form['product_edit_form[productData][sellingFrom]'] = '1.1.1990'; - $form['product_edit_form[productData][sellingTo]'] = '1.1.2000'; - $form['product_edit_form[productData][stockQuantity]'] = '10'; - $form['product_edit_form[productData][unit]']->select($this->getReference(UnitDataFixture::UNIT_CUBIC_METERS)->getId()); - $form['product_edit_form[productData][availability]']->select($this->getReference(AvailabilityDataFixture::AVAILABILITY_IN_STOCK)->getId()); + $form['product_edit_form[productData][basicInformationGroup][catnum]'] = '123456'; + $form['product_edit_form[productData][basicInformationGroup][partno]'] = '123456'; + $form['product_edit_form[productData][basicInformationGroup][ean]'] = '123456'; + $form['product_edit_form[productData][descriptionsGroup][descriptions][1]'] = 'test description'; + $form['product_edit_form[productData][pricesGroup][productCalculatedPricesGroup][price]'] = '10000'; + $form['product_edit_form[productData][pricesGroup][vat]']->select($this->getReference(VatDataFixture::VAT_ZERO)->getId()); + $form['product_edit_form[productData][displayAvailabilityGroup][sellingFrom]'] = '1.1.1990'; + $form['product_edit_form[productData][displayAvailabilityGroup][sellingTo]'] = '1.1.2000'; + $form['product_edit_form[productData][displayAvailabilityGroup][stockGroup][stockQuantity]'] = '10'; + $form['product_edit_form[productData][displayAvailabilityGroup][unit]']->select($this->getReference(UnitDataFixture::UNIT_CUBIC_METERS)->getId()); + $form['product_edit_form[productData][displayAvailabilityGroup][availability]']->select($this->getReference(AvailabilityDataFixture::AVAILABILITY_IN_STOCK)->getId()); } /**