-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 attribute group edit #31502
Merged
matthieu-rolland
merged 42 commits into
PrestaShop:develop
from
JevgenijVisockij:migrate-attribute-view
Sep 19, 2023
Merged
Migrate attribute group edit #31502
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
b93d40b
creating attribute type
JevgenijVisockij a5cf1c0
Reverting package-lock.json
JevgenijVisockij 07f6d2e
Reverting package-lock.json
JevgenijVisockij 6884659
Adding behat tests
JevgenijVisockij fff3f77
Removed unneeded AttributeType.php
JevgenijVisockij a4cff18
Fixed form type
JevgenijVisockij ddad352
PHP stan fixes
JevgenijVisockij d82bfa2
Fixed template
JevgenijVisockij 52abd99
CS fixer fix
JevgenijVisockij 7bf4547
Added attribute group type for validation
JevgenijVisockij eb4caec
Changed to use repository in handlers
JevgenijVisockij cd1ba1d
Moved layout title to controller, changed EditAttributeGroupCommand.p…
JevgenijVisockij 5c2cfe2
Update src/Core/Domain/AttributeGroup/ValueObject/AttributeGroupId.php
JevgenijVisockij fc869ce
Snaller changes from code review
JevgenijVisockij f227cc8
Update src/PrestaShopBundle/Resources/config/services/core/form/form_…
JevgenijVisockij 56fd36c
Removed InvalidAttributeGroupIdException.php replacing iwth constrain…
JevgenijVisockij ff04f69
Changed attribute group to not use GetEditableAttribute group CQRS an…
JevgenijVisockij 95764b4
Apply suggestions from code review
JevgenijVisockij 210b72b
Update tests/Integration/Behaviour/Features/Context/Domain/AttributeG…
JevgenijVisockij 5c81b80
Refactored behat tests to use multilantg
JevgenijVisockij f50a59f
Refactored attribute group js to use 2 separate files
JevgenijVisockij c874ba6
Apply suggestions from code review
JevgenijVisockij 6638569
Removed unneeded exception and smaller fixes
JevgenijVisockij f5ae785
Apply suggestions from code review
JevgenijVisockij b7573f1
Cleaned up attribute group exceptions
JevgenijVisockij d664958
Cleaned up attribute group exceptions
JevgenijVisockij bff2679
CS fixer fix
JevgenijVisockij c1af84c
Updated phpdoc for AttributeGroupFeatureContext.php
JevgenijVisockij 594c6cc
Update tests/Integration/Behaviour/Features/Context/Domain/AttributeG…
JevgenijVisockij b85cdbb
PHP stan fix
JevgenijVisockij 840a17b
Apply suggestions from code review
JevgenijVisockij 7fa4f83
Code review fixes
JevgenijVisockij 46f6e78
Apply suggestions from code review
JevgenijVisockij d38a779
Code review fixes
JevgenijVisockij c174a81
Fixed not working update and add commands
JevgenijVisockij efb4588
CS fixer fix
JevgenijVisockij a36be2e
CS Fixer fixes
JevgenijVisockij 8cdf3b6
Fixed multistore not working properly
JevgenijVisockij 2fc82fb
Cs fixer fix
JevgenijVisockij bd3f85c
Fixed some typos
JevgenijVisockij d6be6ab
Fix last issues + implement export
7aa5916
Update src/PrestaShopBundle/Resources/config/services/bundle/form/for…
matthieu-rolland File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
admin-dev/themes/new-theme/js/pages/attribute-group/form/attribute-group-form-map.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@prestashop.com so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <contact@prestashop.com> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
|
||
/** | ||
* Defines all selectors that are used in customers address add/edit form. | ||
*/ | ||
export default { | ||
attributeGroupShopAssociationInput: '#attribute_group_shop_association', | ||
}; |
39 changes: 39 additions & 0 deletions
39
admin-dev/themes/new-theme/js/pages/attribute-group/form/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@prestashop.com so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <contact@prestashop.com> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
|
||
import AttributeGroupFormMap from '@pages/attribute-group/form/attribute-group-form-map'; | ||
|
||
const {$} = window; | ||
|
||
$(() => { | ||
window.prestashop.component.initComponents( | ||
[ | ||
'TranslatableInput', | ||
'TranslatableField', | ||
], | ||
); | ||
|
||
new window.prestashop.component.ChoiceTree(AttributeGroupFormMap.attributeGroupShopAssociationInput).enableAutoCheckChildren(); | ||
}); |
72 changes: 72 additions & 0 deletions
72
src/Adapter/AttributeGroup/CommandHandler/AddAttributeGroupHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@prestashop.com so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <contact@prestashop.com> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PrestaShop\PrestaShop\Adapter\AttributeGroup\CommandHandler; | ||
|
||
use AttributeGroup; | ||
use PrestaShop\PrestaShop\Adapter\AttributeGroup\Repository\AttributeGroupRepository; | ||
use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; | ||
use PrestaShop\PrestaShop\Core\CommandBus\Attributes\AsCommandHandler; | ||
use PrestaShop\PrestaShop\Core\Domain\AttributeGroup\Command\AddAttributeGroupCommand; | ||
use PrestaShop\PrestaShop\Core\Domain\AttributeGroup\CommandHandler\AddAttributeGroupHandlerInterface; | ||
use PrestaShop\PrestaShop\Core\Domain\AttributeGroup\ValueObject\AttributeGroupId; | ||
|
||
/** | ||
* Handles adding of attribute groups using legacy logic. | ||
*/ | ||
#[AsCommandHandler] | ||
final class AddAttributeGroupHandler extends AbstractObjectModelHandler implements AddAttributeGroupHandlerInterface | ||
{ | ||
/** | ||
* @var AttributeGroupRepository | ||
*/ | ||
private $attributeGroupRepository; | ||
|
||
public function __construct(AttributeGroupRepository $attributeGroupRepository) | ||
{ | ||
$this->attributeGroupRepository = $attributeGroupRepository; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function handle(AddAttributeGroupCommand $command): AttributeGroupId | ||
{ | ||
$attributeGroup = new AttributeGroup(); | ||
|
||
$attributeGroup->name = $command->getLocalizedNames(); | ||
$attributeGroup->public_name = $command->getLocalizedPublicNames(); | ||
$attributeGroup->group_type = $command->getType()->getValue(); | ||
|
||
$id = $this->attributeGroupRepository->add($attributeGroup); | ||
|
||
$this->associateWithShops($attributeGroup, $command->getShopAssociation()); | ||
jolelievre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return $id; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/Adapter/AttributeGroup/CommandHandler/EditAttributeGroupHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@prestashop.com so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <contact@prestashop.com> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PrestaShop\PrestaShop\Adapter\AttributeGroup\CommandHandler; | ||
|
||
use PrestaShop\PrestaShop\Adapter\AttributeGroup\Repository\AttributeGroupRepository; | ||
use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; | ||
use PrestaShop\PrestaShop\Core\CommandBus\Attributes\AsCommandHandler; | ||
use PrestaShop\PrestaShop\Core\Domain\AttributeGroup\Command\EditAttributeGroupCommand; | ||
use PrestaShop\PrestaShop\Core\Domain\AttributeGroup\CommandHandler\EditAttributeGroupHandlerInterface; | ||
|
||
/** | ||
* Handles editing of attribute groups using legacy logic. | ||
*/ | ||
#[AsCommandHandler] | ||
final class EditAttributeGroupHandler extends AbstractObjectModelHandler implements EditAttributeGroupHandlerInterface | ||
{ | ||
/** | ||
* @var AttributeGroupRepository | ||
*/ | ||
private $attributeGroupRepository; | ||
|
||
public function __construct(AttributeGroupRepository $attributeGroupRepository) | ||
{ | ||
$this->attributeGroupRepository = $attributeGroupRepository; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function handle(EditAttributeGroupCommand $command): void | ||
{ | ||
$attributeGroup = $this->attributeGroupRepository->get($command->getAttributeGroupId()); | ||
|
||
$attributeGroup->name = $command->getLocalizedNames(); | ||
$attributeGroup->public_name = $command->getLocalizedPublicNames(); | ||
$attributeGroup->group_type = $command->getType()->getValue(); | ||
|
||
$this->attributeGroupRepository->update($attributeGroup); | ||
|
||
$this->associateWithShops($attributeGroup, $command->getShopAssociation()); | ||
jolelievre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/Adapter/AttributeGroup/QueryHandler/GetAttributeGroupForEditingHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* Copyright since 2007 PrestaShop SA and Contributors | ||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.md. | ||
* It is also available through the world-wide-web at this URL: | ||
* https://opensource.org/licenses/OSL-3.0 | ||
* If you did not receive a copy of the license and are unable to | ||
* obtain it through the world-wide-web, please send an email | ||
* to license@prestashop.com so we can send you a copy immediately. | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
* versions in the future. If you wish to customize PrestaShop for your | ||
* needs please refer to https://devdocs.prestashop.com/ for more information. | ||
* | ||
* @author PrestaShop SA and Contributors <contact@prestashop.com> | ||
* @copyright Since 2007 PrestaShop SA and Contributors | ||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PrestaShop\PrestaShop\Adapter\AttributeGroup\QueryHandler; | ||
|
||
use PrestaShop\PrestaShop\Adapter\AttributeGroup\Repository\AttributeGroupRepository; | ||
use PrestaShop\PrestaShop\Core\CommandBus\Attributes\AsQueryHandler; | ||
use PrestaShop\PrestaShop\Core\Domain\AttributeGroup\Query\GetAttributeGroupForEditing; | ||
use PrestaShop\PrestaShop\Core\Domain\AttributeGroup\QueryHandler\GetAttributeGroupForEditingHandlerInterface; | ||
use PrestaShop\PrestaShop\Core\Domain\AttributeGroup\QueryResult\EditableAttributeGroup; | ||
|
||
/** | ||
* Handles query which gets attribute group for editing | ||
*/ | ||
#[AsQueryHandler] | ||
final class GetAttributeGroupForEditingHandler implements GetAttributeGroupForEditingHandlerInterface | ||
{ | ||
/** | ||
* @var AttributeGroupRepository | ||
*/ | ||
private $attributeGroupRepository; | ||
|
||
public function __construct(AttributeGroupRepository $attributeGroupRepository) | ||
{ | ||
$this->attributeGroupRepository = $attributeGroupRepository; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function handle(GetAttributeGroupForEditing $query): EditableAttributeGroup | ||
{ | ||
$attributeGroup = $this->attributeGroupRepository->get($query->getAttributeGroupId()); | ||
|
||
return new EditableAttributeGroup( | ||
$query->getAttributeGroupId()->getValue(), | ||
$attributeGroup->name, | ||
$attributeGroup->public_name, | ||
$attributeGroup->group_type, | ||
$attributeGroup->getAssociatedShops() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we are in develop branch and we drop some PHP versions oldies, you can use constructor property promotion here (and in other handler classes) to simplify some lines.
Anyway, I'm not blocking your PR for this, but it can be a must have now in develop branch PRs! ;)