Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Shop parameters -> Order settings page #9007

Conversation

rokaszygmantas
Copy link
Contributor

@rokaszygmantas rokaszygmantas commented Apr 27, 2018

Questions Answers
Branch? develop
Description? Migration of Shop parameters -> Order settings controller
Type? new feature
Category? CO
BC breaks? no
Deprecations? no
Fixed ticket? n/a
How to test? Compare with legacy controller

Important guidelines


This change is Reviewable

@prestonBot prestonBot added develop Branch Waiting for wording Status: action required, waiting for wording labels Apr 27, 2018
Copy link
Contributor

@mickaelandrieu mickaelandrieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some few details needs to be fixed/improved, but it's good already

*/
class CMSDataProvider
{
public function getCMSPages($languageId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you mind to add PHPDoc for newly created classes? 👍

{
$choices = [];

foreach ($this->cmsDataProvider->getCMSPages($languageId) as $cms) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see this function moved in CmsDataProvider instead, so you can inject the array instead of the full CmsDataProvider (like we already do to inject the locales).

use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this form type already exists... wdyt @Quetzacoalt91 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find anything similar to this type - money type only adds the currency sign next to the input. This new type is used for situations like these: https://prnt.sc/jbyc7w

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure we already have this input type in Product page, isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mickaelandrieu yes I've seen this one, but it's just an extension to money type, it's extending my new type as well. It doesn't have the functionality to enter a text suffix right after the currency sign so that's why I've created a new type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok! fair enough then 👍

@mickaelandrieu mickaelandrieu added this to the 1.7.5.0 milestone Apr 30, 2018
@LouiseBonnard LouiseBonnard removed the Waiting for wording Status: action required, waiting for wording label Apr 30, 2018
*/
private function applySuffix(&$value, $key, $suffix)
{
if (strlen($value) > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need a $key here? You don't use it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because of array_walk where this method is used, array walk passes the value as the third argument so I must define the second argument as well. I don't like it, but is it worth changing array_walk to something custom because of that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this explanation to PHPDoc please, this makes Codacy cry a river.

wdyt @PierreRambaud?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, just add the explanation to PHPDoc.

Copy link
Contributor

@mickaelandrieu mickaelandrieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applySuffix have an extra parameter "key" which is not used.

@mickaelandrieu
Copy link
Contributor

Hello, @rokaszygmantas this needs a rebase.

@PierreRambaud I chose you to fairly review work of @rokaszygmantas and @sarjon as I'm in holidays for 1 week!

@@ -0,0 +1,21 @@
<?php

This comment was marked as outdated.

@rokaszygmantas rokaszygmantas force-pushed the migration/shop_parameters-order_settings branch from 137d437 to 4b966c9 Compare May 10, 2018 11:41
public: true
arguments:
- '@prestashop.adapter.data_provider.currency'
- '@=service("prestashop.adapter.data_provider.cms").getCmsChoices()'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we need to pass the language id to the function here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the cms data provider internally uses CMS::listCms($idLang = null, $idBlock = false, $active = true),
it takes the default language if no argument is passed. In this case the default language should be used so there's no need to pass it as an argument
https://github.com/PrestaShop/PrestaShop/blob/develop/classes/CMS.php#L166

mickaelandrieu
mickaelandrieu previously approved these changes May 10, 2018
@mickaelandrieu mickaelandrieu changed the title [WIP] Migrate Shop parameters -> Order settings controller Migrate Shop parameters -> Order settings page May 10, 2018
@prestonBot prestonBot added the Waiting for wording Status: action required, waiting for wording label May 10, 2018
@mickaelandrieu mickaelandrieu added the Waiting for QA Status: action required, waiting for test feedback label May 10, 2018
@rokaszygmantas
Copy link
Contributor Author

this PR is still work in progress - please don't merge it yet :)

@mickaelandrieu
Copy link
Contributor

@rokaszygmantas what is missing here from a functional point of view?

@mickaelandrieu mickaelandrieu added wip and removed Waiting for QA Status: action required, waiting for test feedback labels May 10, 2018
@rokaszygmantas
Copy link
Contributor Author

Gift options fieldset is still missing and also the links are still pointing to the legacy controller. I should finish it tomorrow :)

handleTermsAndConditionsCmsSelect(isTosEnabled) {
const tosCmsSelect = $('#form_general_tos_cms_id');

if (isTosEnabled) {
Copy link
Contributor

@PierreRambaud PierreRambaud May 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can replace the whole function by:

$('#form_general_tos_cms_id').prop('disabled', !isTosEnabled);

@rokaszygmantas
Copy link
Contributor Author

@mickaelandrieu now all functionality of the legacy controller is migrated

Copy link
Contributor

@mickaelandrieu mickaelandrieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comment

@@ -82,11 +91,19 @@ public function setData(array $data)
$data['general']['tos_cms_id'] = 0;
}

// If gift wrapping tax rules group was not submitted - reset it to 0
if (!$data['gift_options']['gift_wrapping_tax_rules_group']) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i prefer a condition using isset or array_key_exists please : more explicit

{
$errors = [];
$invalidFields = [];
$purchaseMinimumValue = $data['general']['purchase_minimum_value'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add some controls on $data['general'] and $data['gift_options']? wdyt @mickaelandrieu ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, if these 2 keys don't exist or are null what happens?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyway, this can be validated by QA.

TranslatorInterface $translator,
array $locales,
CurrencyDataProvider $currencyDataProvider,
$tosCmsChoices
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- $tosCmsChoices
+ array $tosCmsChoices

TranslatorInterface $translator,
array $locales,
CurrencyDataProvider $currencyDataProvider,
$taxChoices
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- $taxChoices
+ array $taxChoices

@mickaelandrieu mickaelandrieu added the Waiting for QA Status: action required, waiting for test feedback label May 15, 2018
@marionf
Copy link
Contributor

marionf commented May 16, 2018

Hello @rokaszygmantas

When I click on the "order" link in the breadcrumb
capture du 2018-05-16 10-17-03

I have a 404 because it's the link of the legacy page
capture du 2018-05-16 10-17-51

Otherwise everything is good :)

@marionf marionf added Waiting for author Status: action required, waiting for author feedback and removed Waiting for QA Status: action required, waiting for test feedback labels May 16, 2018
@PierreRambaud
Copy link
Contributor

@marionf Bad link in breadcrumbs is maybe fixed in #9051 :)

@marionf
Copy link
Contributor

marionf commented May 16, 2018

Oh yes you're right, so it's all good for me :)

@marionf marionf added QA ✔️ Status: check done, code approved and removed Waiting for author Status: action required, waiting for author feedback labels May 16, 2018
@mickaelandrieu
Copy link
Contributor

and ... merged!

Good job @rokaszygmantas, and thanks everyone for reviews!

@mickaelandrieu mickaelandrieu merged commit b14a802 into PrestaShop:develop May 16, 2018
@rokaszygmantas rokaszygmantas deleted the migration/shop_parameters-order_settings branch May 16, 2018 10:52
@matks matks added the migration symfony migration project label Sep 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
develop Branch migration symfony migration project QA ✔️ Status: check done, code approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants