-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #708 from afoucret/feature-search-manual-sort
Feature search manual sort
- Loading branch information
Showing
34 changed files
with
1,573 additions
and
190 deletions.
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
84 changes: 84 additions & 0 deletions
84
src/module-elasticsuite-catalog/Block/Adminhtml/Search/Term/Edit/Preview.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,84 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr> | ||
* @copyright 2018 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
|
||
namespace Smile\ElasticsuiteCatalog\Block\Adminhtml\Search\Term\Edit; | ||
|
||
use Magento\Framework\View\Element\AbstractBlock; | ||
|
||
/** | ||
* Add the merchandiser button in the search term form. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr> | ||
*/ | ||
class Preview extends \Magento\Framework\View\Element\AbstractBlock | ||
{ | ||
/** | ||
* @var \Magento\Backend\Block\Widget\Button\ButtonList | ||
*/ | ||
private $buttonList; | ||
|
||
/** | ||
* @var \Magento\Backend\Model\UrlInterface | ||
*/ | ||
private $urlBuilder; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param \Magento\Backend\Block\Widget\Context $context Block context. | ||
* @param \Magento\Backend\Model\UrlInterface $urlBuilder URL Builder. | ||
* @param array $data Block data. | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Widget\Context $context, | ||
\Magento\Backend\Model\UrlInterface $urlBuilder, | ||
array $data = [] | ||
) { | ||
$this->buttonList = $context->getButtonList(); | ||
$this->urlBuilder = $urlBuilder; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.CamelCaseMethodName) | ||
* | ||
* {@inheritDoc} | ||
*/ | ||
protected function _construct() | ||
{ | ||
parent::_construct(); | ||
|
||
$this->buttonList->add( | ||
'merchandiser-button', | ||
[ | ||
'label' => __('Merchandiser'), | ||
'class' => 'delete', | ||
'onclick' => "setLocation('" . $this->getMerchandiserUrl() . "')", | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Retrieve merchandiser button URL. | ||
* | ||
* @return string | ||
*/ | ||
private function getMerchandiserUrl() | ||
{ | ||
$queryId = $this->getRequest()->getParam('id'); | ||
|
||
return $this->urlBuilder->getUrl('search/term_merchandiser/edit', ['id' => $queryId]); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/module-elasticsuite-catalog/Block/Adminhtml/Search/Term/Merchandiser/Edit/BackButton.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,53 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr> | ||
* @copyright 2018 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
namespace Smile\ElasticsuiteCatalog\Block\Adminhtml\Search\Term\Merchandiser\Edit; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
/** | ||
* Form back button. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr> | ||
*/ | ||
class BackButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getButtonData() | ||
{ | ||
$data = []; | ||
if ($this->canRender('reset')) { | ||
$data = [ | ||
'label' => __('Back'), | ||
'class' => 'back', | ||
'on_click' => "setLocation('" . $this->getQueryUrl() . "');", | ||
'sort_order' => 10, | ||
]; | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
/** | ||
* Get back URL. | ||
* | ||
* @return string | ||
*/ | ||
public function getQueryUrl() | ||
{ | ||
return $this->getUrl('search/term/edit', ['id' => $this->getQueryId()]); | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
...dule-elasticsuite-catalog/Block/Adminhtml/Search/Term/Merchandiser/Edit/GenericButton.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,88 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr> | ||
* @copyright 2018 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
namespace Smile\ElasticsuiteCatalog\Block\Adminhtml\Search\Term\Merchandiser\Edit; | ||
|
||
/** | ||
* Generic form button. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr> | ||
*/ | ||
class GenericButton | ||
{ | ||
/** | ||
* Url Builder | ||
* | ||
* @var \Magento\Framework\UrlInterface | ||
*/ | ||
private $urlBuilder; | ||
|
||
/** | ||
* Registry | ||
* | ||
* @var \Magento\Framework\Registry | ||
*/ | ||
private $registry; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param \Magento\Backend\Block\Widget\Context $context Block context. | ||
* @param \Magento\Framework\Registry $registry Registry. | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Widget\Context $context, | ||
\Magento\Framework\Registry $registry | ||
) { | ||
$this->urlBuilder = $context->getUrlBuilder(); | ||
$this->registry = $registry; | ||
} | ||
|
||
/** | ||
* Return the current query id. | ||
* | ||
* @return int|null | ||
*/ | ||
public function getQueryId() | ||
{ | ||
$query = $this->registry->registry('current_query'); | ||
|
||
return $query ? $query->getId() : null; | ||
} | ||
|
||
/** | ||
* Generate url by route and parameters | ||
* | ||
* @param string $route Route. | ||
* @param array $params Route params. | ||
* | ||
* @return string | ||
*/ | ||
public function getUrl($route = '', $params = []) | ||
{ | ||
return $this->urlBuilder->getUrl($route, $params); | ||
} | ||
|
||
/** | ||
* Check where button can be rendered | ||
* | ||
* @param string $name Button name. | ||
* | ||
* @return string | ||
*/ | ||
public function canRender($name) | ||
{ | ||
return $name; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...module-elasticsuite-catalog/Block/Adminhtml/Search/Term/Merchandiser/Edit/ResetButton.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,43 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr> | ||
* @copyright 2018 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
namespace Smile\ElasticsuiteCatalog\Block\Adminhtml\Search\Term\Merchandiser\Edit; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
/** | ||
* Reset button. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr> | ||
*/ | ||
class ResetButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getButtonData() | ||
{ | ||
$data = []; | ||
if ($this->canRender('reset')) { | ||
$data = [ | ||
'label' => __('Reset'), | ||
'class' => 'reset', | ||
'on_click' => 'location.reload()', | ||
'sort_order' => 30, | ||
]; | ||
} | ||
|
||
return $data; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...sticsuite-catalog/Block/Adminhtml/Search/Term/Merchandiser/Edit/SaveAndContinueButton.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,43 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr> | ||
* @copyright 2018 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
namespace Smile\ElasticsuiteCatalog\Block\Adminhtml\Search\Term\Merchandiser\Edit; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
/** | ||
* Save and continue button. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr> | ||
*/ | ||
class SaveAndContinueButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getButtonData() | ||
{ | ||
$data = []; | ||
if ($this->canRender('save_and_continue_edit')) { | ||
$data = [ | ||
'label' => __('Save and Continue Edit'), | ||
'class' => 'save', | ||
'on_click' => '', | ||
'sort_order' => 90, | ||
]; | ||
} | ||
|
||
return $data; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/module-elasticsuite-catalog/Block/Adminhtml/Search/Term/Merchandiser/Edit/SaveButton.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,43 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr> | ||
* @copyright 2018 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
namespace Smile\ElasticsuiteCatalog\Block\Adminhtml\Search\Term\Merchandiser\Edit; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
/** | ||
* Save button. | ||
* | ||
* @category Smile | ||
* @package Smile\ElasticsuiteCatalog | ||
* @author Aurelien FOUCRET <aurelien.foucret@smile.fr> | ||
*/ | ||
class SaveButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
/** | ||
* @return array | ||
* @codeCoverageIgnore | ||
*/ | ||
public function getButtonData() | ||
{ | ||
$data = []; | ||
if ($this->canRender('save')) { | ||
$data = [ | ||
'label' => __('Save'), | ||
'class' => 'save primary', | ||
'on_click' => '', | ||
]; | ||
} | ||
|
||
return $data; | ||
} | ||
} |
Oops, something went wrong.