Skip to content

Commit

Permalink
Merge branch 'graschik:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
xtremevision authored Oct 27, 2023
2 parents 97556bf + d004892 commit 247be5f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
41 changes: 38 additions & 3 deletions Component/EntitiesSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
namespace Grasch\AdminUi\Component;

use Grasch\AdminUi\Model\UiComponentGenerator;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Stdlib\ArrayManager;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Ui\Component\AbstractComponent;
Expand Down Expand Up @@ -81,6 +83,11 @@ class EntitiesSelector extends AbstractComponent
*/
protected array $_columnsConfig = [];

/**
* @var ArrayManager|mixed
*/
private ArrayManager $arrayManager;

/**
* @param ContextInterface $context
* @param UrlInterface $urlBuilder
Expand All @@ -94,6 +101,7 @@ public function __construct(
ContextInterface $context,
UrlInterface $urlBuilder,
UiComponentGenerator $uiComponentGenerator,
ArrayManager $arrayManager = null,
array $components = [],
array $data = [],
array $requiredColumnFields = []
Expand All @@ -106,6 +114,7 @@ public function __construct(

$this->urlBuilder = $urlBuilder;
$this->uiComponentGenerator = $uiComponentGenerator;
$this->arrayManager = $arrayManager ?? ObjectManager::getInstance()->create(ArrayManager::class);

$this->_requiredColumnFields = array_merge(
$this->_requiredColumnFields,
Expand Down Expand Up @@ -163,6 +172,25 @@ public function prepare()
parent::prepare();
}

/**
* @return array
* @throws LocalizedException
*/
public function getChildComponentsAsArrayForMeta(): array
{
$data = $this->getChildComponentsAsArray();

$paths = $this->arrayManager->findPaths('data', $data);
foreach ($paths as $path) {
$value = ['data' => $this->arrayManager->get($path, $data)];
$newPath = str_replace('/data', '/arguments', $path);
$data = $this->arrayManager->remove($path, $data);
$data = $this->arrayManager->set($newPath, $data, $value);
}

return $data;
}

/**
* Get child components as array
*
Expand Down Expand Up @@ -415,11 +443,13 @@ public function getButtonSet(): array
[
[
'targetName' => '${ $.parentName.replace(".button_set", "") }.modal',
'__disableTmpl' => ['targetName' => false],
'actionName' => 'toggleModal',
],
[
'targetName' =>
'${ $.parentName.replace(".button_set", "") }.listing-renderer',
'__disableTmpl' => ['targetName' => false],
'actionName' => 'render',
],
],
Expand Down Expand Up @@ -494,11 +524,13 @@ public function getListingRenderer(): array
return [
'data' => [
'config' => [
'componentType' => 'container',
'component' => 'Grasch_AdminUi/js/view/components/entities-selector/insert-listing/renderer',
'selectionsProvider' => $this->getSelectionsProvider(),
'columnsProvider' => $this->getColumnsProvider(),
'insertListing' => 'uniq_ns = ' . $this->generateUniqNamespace(),
'grid' => '${ $.parentName }.' . $this->getName()
'grid' => '${ $.parentName }.' . $this->getName(),
'__disableTmpl' => ['grid' => false],
]
],
'context' => $this->context
Expand All @@ -521,6 +553,7 @@ public function getGenericModal(): array
'data' => [
'componentClassName' => Modal::class,
'config' => [
'componentType' => Modal::NAME,
'component' => 'Magento_Ui/js/modal/modal-component',
'provider' => null,
'options' => [
Expand Down Expand Up @@ -553,10 +586,12 @@ public function getGenericModal(): array
'namespace' => '${ $.ns }',
'js_modifier' => [
'params' => $this->getJsModifierParams()
]
],
'__disableTmpl' => ['namespace' => false],
],
'links' => [
'value' => '${ $.provider }:${ $.uniq_ns }'
'value' => '${ $.provider }:${ $.uniq_ns }',
'__disableTmpl' => ['value' => false]
],
'behaviourType' => 'simple',
'externalFilterMode' => true,
Expand Down
3 changes: 0 additions & 3 deletions Model/DecodeComponentValue.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php
/**
* Copyright © InComm, Inc. All rights reserved.
*/
declare(strict_types=1);

namespace Grasch\AdminUi\Model;
Expand Down

0 comments on commit 247be5f

Please sign in to comment.