Skip to content

Commit

Permalink
Merge pull request PrestaShop#29732 from margud/16592/customerService…
Browse files Browse the repository at this point in the history
…-grid-migration

Customer service controller migration (grid part)
  • Loading branch information
jolelievre authored Nov 3, 2022
2 parents 8c60dcf + 031fa32 commit 91395e8
Show file tree
Hide file tree
Showing 40 changed files with 1,937 additions and 93 deletions.
2 changes: 2 additions & 0 deletions admin-dev/themes/new-theme/.webpack/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ module.exports = {
customer_address_form: './js/pages/address/form',
customer_outstanding: './js/pages/outstanding',
customer_preferences: './js/pages/customer-preferences',
customer_thread: './js/pages/customer-thread/index',
customer_thread_view: './js/pages/customer-thread/view',
customer_threads: './scss/pages/customer_thread/customer_thread.scss',
email: './js/pages/email',
employee: './js/pages/employee/index',
employee_form: './js/pages/employee/form',
Expand Down
59 changes: 59 additions & 0 deletions admin-dev/themes/new-theme/js/pages/customer-thread/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* 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 [email protected] 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 <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

import Grid from '@components/grid/grid';
import FiltersResetExtension from '@components/grid/extension/filters-reset-extension';
import ReloadListActionExtension from '@components/grid/extension/reload-list-extension';
import ExportToSqlManagerExtension from '@components/grid/extension/export-to-sql-manager-extension';
import SortingExtension from '@components/grid/extension/sorting-extension';
import LinkRowActionExtension from '@components/grid/extension/link-row-action-extension';
import SubmitGridExtension from '@components/grid/extension/submit-grid-action-extension';
import SubmitBulkExtension from '@components/grid/extension/submit-bulk-action-extension';
import SubmitRowActionExtension from '@components/grid/extension/action/row/submit-row-action-extension';
import BulkActionCheckboxExtension from '@components/grid/extension/bulk-action-checkbox-extension';
import FiltersSubmitButtonEnablerExtension from '@components/grid/extension/filters-submit-button-enabler-extension';
import ChoiceExtension from '@components/grid/extension/choice-extension';
import ColumnTogglingExtension from '@components/grid/extension/column-toggling-extension';
import PositionExtension from '@components/grid/extension/position-extension';

const {$} = window;

$(() => {
const grid = new Grid('customer_thread');

grid.addExtension(new FiltersResetExtension());
grid.addExtension(new ReloadListActionExtension());
grid.addExtension(new ExportToSqlManagerExtension());
grid.addExtension(new SortingExtension());
grid.addExtension(new LinkRowActionExtension());
grid.addExtension(new SubmitGridExtension());
grid.addExtension(new SubmitBulkExtension());
grid.addExtension(new BulkActionCheckboxExtension());
grid.addExtension(new FiltersSubmitButtonEnablerExtension());
grid.addExtension(new ColumnTogglingExtension());
grid.addExtension(new SubmitRowActionExtension());
grid.addExtension(new ChoiceExtension());
grid.addExtension(new PositionExtension(grid));
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#customer_thread_grid {
// Do not break thread status change button
.column-status .btn {
white-space: nowrap;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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 [email protected] 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 <[email protected]>
* @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\Core\Domain\CustomerService\Command;

use PrestaShop\PrestaShop\Core\Domain\CustomerService\Exception\CustomerServiceException;
use PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject\CustomerThreadId;

class BulkDeleteCustomerThreadCommand
{
/**
* @var CustomerThreadId[]
*/
private $customerThreadIds;

/**
* @param array<int, int> $customerThreadIds
*
* @throws CustomerServiceException
*/
public function __construct(array $customerThreadIds)
{
$this->setCustomerThreadIds($customerThreadIds);
}

/**
* @return CustomerThreadId[]
*/
public function getCustomerThreadIds(): array
{
return $this->customerThreadIds;
}

/**
* @param array<int, int> $customerThreadIds
*
* @throws CustomerServiceException
*/
private function setCustomerThreadIds(array $customerThreadIds): void
{
foreach ($customerThreadIds as $customerThreadId) {
$this->customerThreadIds[] = new CustomerThreadId($customerThreadId);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?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 [email protected] 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 <[email protected]>
* @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\Core\Domain\CustomerService\Command;

use PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject\CustomerThreadId;

class DeleteCustomerThreadCommand
{
/**
* @var CustomerThreadId
*/
private $customerThreadId;

public function __construct(int $customerThreadId)
{
$this->customerThreadId = new CustomerThreadId($customerThreadId);
}

/**
* @return CustomerThreadId
*/
public function getCustomerThreadId(): CustomerThreadId
{
return $this->customerThreadId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

namespace PrestaShop\PrestaShop\Adapter\CustomerService\CommandHandler;
namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\CommandHandler;

use Configuration;
use Customer;
Expand All @@ -43,7 +43,7 @@
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Tools;

final class AddOrderCustomerMessageHandler implements AddOrderCustomerMessageHandlerInterface
class AddOrderCustomerMessageHandler implements AddOrderCustomerMessageHandlerInterface
{
/**
* @var int
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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 [email protected] 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 <[email protected]>
* @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\Core\Domain\CustomerService\CommandHandler;

use PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\BulkDeleteCustomerThreadCommand;
use PrestaShop\PrestaShop\Core\Domain\CustomerService\Repository\CustomerThreadRepository;

/**
* Handles command for customer thread bulk deletion
*/
class BulkDeleteCustomerThreadHandler implements BulkDeleteCustomerThreadHandlerInterface
{
/**
* @var CustomerThreadRepository
*/
private $customerThreadRepository;

public function __construct(CustomerThreadRepository $customerThreadRepository)
{
$this->customerThreadRepository = $customerThreadRepository;
}

public function handle(BulkDeleteCustomerThreadCommand $command): void
{
foreach ($command->getCustomerThreadIds() as $customerThreadId) {
$this->customerThreadRepository->delete($customerThreadId);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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 [email protected] 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 <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\CommandHandler;

use PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\BulkDeleteCustomerThreadCommand;

/**
* Bulk delete customer thread
*/
interface BulkDeleteCustomerThreadHandlerInterface
{
public function handle(BulkDeleteCustomerThreadCommand $command): void;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?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 [email protected] 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 <[email protected]>
* @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\Core\Domain\CustomerService\CommandHandler;

use PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\DeleteCustomerThreadCommand;
use PrestaShop\PrestaShop\Core\Domain\CustomerService\Repository\CustomerThreadRepository;

/**
* Handles command for customer thread deletion
*/
class DeleteCustomerThreadHandler implements DeleteCustomerThreadHandlerInterface
{
/**
* @var CustomerThreadRepository
*/
private $customerThreadRepository;

public function __construct(CustomerThreadRepository $customerThreadRepository)
{
$this->customerThreadRepository = $customerThreadRepository;
}

/**
* @param DeleteCustomerThreadCommand $command
*
* @return void
*/
public function handle(DeleteCustomerThreadCommand $command): void
{
$this->customerThreadRepository->delete($command->getCustomerThreadId());
}
}
Loading

0 comments on commit 91395e8

Please sign in to comment.