Skip to content

Commit

Permalink
MAGETWO-49756: Groupped Product ui configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Idolov committed Mar 2, 2016
1 parent 09afc2f commit 33ffcd3
Showing 1 changed file with 51 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ class Grouped extends AbstractModifier
*/
protected $localeCurrency;

/**
* @var array
*/
protected $uiComponentsConfig = [
'button_set' => 'grouped_products_button_set',
'modal' => 'grouped_products_modal',
'listing' => 'grouped_product_listing',
'form' => 'product_form',
];

/**
* @var string
*/
Expand All @@ -95,6 +105,7 @@ class Grouped extends AbstractModifier
* @param Status $status
* @param AttributeSetRepositoryInterface $attributeSetRepository
* @param CurrencyInterface $localeCurrency
* @param array $uiComponentsConfig
*/
public function __construct(
LocatorInterface $locator,
Expand All @@ -104,7 +115,8 @@ public function __construct(
ImageHelper $imageHelper,
Status $status,
AttributeSetRepositoryInterface $attributeSetRepository,
CurrencyInterface $localeCurrency
CurrencyInterface $localeCurrency,
array $uiComponentsConfig = []
) {
$this->locator = $locator;
$this->urlBuilder = $urlBuilder;
Expand All @@ -114,6 +126,7 @@ public function __construct(
$this->attributeSetRepository = $attributeSetRepository;
$this->status = $status;
$this->localeCurrency = $localeCurrency;
$this->uiComponentsConfig = array_replace_recursive($this->uiComponentsConfig, $uiComponentsConfig);
}

/**
Expand Down Expand Up @@ -246,8 +259,8 @@ protected function modifyQtyAndStockStatus(array $meta)
protected function getChildren()
{
$children = [
'grouped_products_button_set' => $this->getButtonSet(),
'grouped_products_modal' => $this->getModal(),
$this->uiComponentsConfig['button_set'] => $this->getButtonSet(),
$this->uiComponentsConfig['modal'] => $this->getModal(),
self::LINK_TYPE => $this->getGrid(),
];
return $children;
Expand All @@ -266,7 +279,11 @@ protected function getModal()
'config' => [
'componentType' => Modal::NAME,
'dataScope' => '',
'provider' => 'product_form.product_form_data_source',
'provider' =>
$this->uiComponentsConfig['form']
. '.'
. $this->uiComponentsConfig['form']
. '_data_source',
'options' => [
'title' => __('Add Products to Group'),
'buttons' => [
Expand All @@ -280,7 +297,7 @@ protected function getModal()
'class' => 'action-primary',
'actions' => [
[
'targetName' => 'index = grouped_product_listing',
'targetName' => 'index = ' . $this->uiComponentsConfig['listing'],
'actionName' => 'save'
],
'closeModal'
Expand All @@ -291,7 +308,7 @@ protected function getModal()
],
],
],
'children' => ['grouped_product_listing' => $this->getListing()],
'children' => [$this->uiComponentsConfig['listing'] => $this->getListing()],
];
}

Expand All @@ -308,13 +325,25 @@ protected function getListing()
'config' => [
'autoRender' => false,
'componentType' => 'insertListing',
'dataScope' => 'grouped_product_listing',
'externalProvider' => 'grouped_product_listing.grouped_product_listing_data_source',
'selectionsProvider' => 'grouped_product_listing.grouped_product_listing.product_columns.ids',
'ns' => 'grouped_product_listing',
'dataScope' => $this->uiComponentsConfig['listing'],
'externalProvider' =>
$this->uiComponentsConfig['listing']
. '.'
. $this->uiComponentsConfig['listing']
. '_data_source',
'selectionsProvider' =>
$this->uiComponentsConfig['listing']
. '.'
. $this->uiComponentsConfig['listing']
. '.product_columns.ids',
'ns' => $this->uiComponentsConfig['listing'],
'render_url' => $this->urlBuilder->getUrl('mui/index/render'),
'realTimeLink' => true,
'provider' => 'product_form.product_form_data_source',
'provider' =>
$this->uiComponentsConfig['form']
. '.'
. $this->uiComponentsConfig['form']
. '_data_source',
'dataLinks' => ['imports' => false, 'exports' => true],
'behaviourType' => 'simple',
'externalFilterMode' => true,
Expand Down Expand Up @@ -365,16 +394,22 @@ protected function getButtonSet()
'actions' => [
[
'targetName' =>
'product_form.product_form.'
$this->uiComponentsConfig['form'] . '.' . $this->uiComponentsConfig['form']
. '.'
. static::GROUP_GROUPED
. '.grouped_products_modal',
. '.'
. $this->uiComponentsConfig['modal'],
'actionName' => 'openModal',
],
[
'targetName' =>
'product_form.product_form.'
$this->uiComponentsConfig['form'] . '.' . $this->uiComponentsConfig['form']
. '.'
. static::GROUP_GROUPED
. '.grouped_products_modal.grouped_product_listing',
. '.'
. $this->uiComponentsConfig['modal']
. '.'
. $this->uiComponentsConfig['listing'],
'actionName' => 'render',
],
],
Expand Down Expand Up @@ -409,7 +444,7 @@ protected function getGrid()
'itemTemplate' => 'record',
'dataScope' => 'data.links',
'deleteButtonLabel' => __('Remove'),
'dataProvider' => 'grouped_product_listing',
'dataProvider' => $this->uiComponentsConfig['listing'],
'map' => [
'id' => 'entity_id',
'name' => 'name',
Expand Down

0 comments on commit 33ffcd3

Please sign in to comment.