Skip to content

Commit

Permalink
magento-engcom/magento2#3 Add edit action and grid element
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Röttig authored and Lars Röttig committed May 21, 2017
1 parent c5f9131 commit 771b143
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 10 deletions.
39 changes: 39 additions & 0 deletions app/code/Magento/Inventory/Controller/Adminhtml/Sources/Edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Inventory\Controller\Adminhtml\Sources;

/**
* Class Edit
*/
class Edit extends \Magento\Backend\App\Action
{
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $resultPageFactory;

/**
* Edit constructor.
*
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory)
{
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}

/**
* @return \Magento\Framework\View\Result\Page
*/
public function execute()
{
return $this->resultPageFactory->create();
}
}
25 changes: 21 additions & 4 deletions app/code/Magento/Inventory/Controller/Adminhtml/Sources/Index.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Inventory\Controller\Adminhtml\Sources;

/**
* Class Index
*/
class Index extends \Magento\Backend\App\Action
{

const ADMIN_RESOURCE = 'Sources';
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $resultPageFactory;

/**
* Index constructor.
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory)
{
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}


/**
* @return \Magento\Framework\View\Result\Page
*/
public function execute()
{
return $this->resultPageFactory->create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
* See COPYING.txt for license details.
*/

namespace Magento\Inventory\Ui\Component\Listing\Column\Magentoinventorysource;
namespace Magento\Inventory\Ui\Component\Listing\Columns;

use Magento\InventoryApi\Api\Data\SourceInterface;

/**
* Class PageActions
* Class SourceActions
*/
class PageActions extends \Magento\Ui\Component\Listing\Columns\Column
class SourceActions extends \Magento\Ui\Component\Listing\Columns\Column
{

/**
* Add new edit action for the ui grid.
* Add new edit action for the ui grid.
*/
public function prepareDataSource(array $dataSource)
{
Expand All @@ -29,7 +29,7 @@ public function prepareDataSource(array $dataSource)
}

$href = $this->getContext()->getUrl(
"magento_inventory_source/page/edit",
"inventory/sources/edit",
[SourceInterface::SOURCE_ID => $id]
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>

</body>
</page>
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@
</argument>
</dataSource>
<listingToolbar name="listing_top">
<settings>
<sticky>true</sticky>
</settings>
<bookmark name="bookmarks"/>
<columnsControls name="columns_controls"/>
<massaction name="listing_massaction" component="Magento_Ui/js/grid/tree-massactions">
<action name="delete">
<settings>
<confirm>
<message translate="true">Delete selected items?</message>
<title translate="true">Delete items</title>
</confirm>
<url path="catalog/product/massDelete"/>
<type>delete</type>
<label translate="true">Delete</label>
</settings>
</action>
</massaction>
<paging name="listing_paging"/>
</listingToolbar>
<columns name="inventory_source_listing_columns">
Expand All @@ -65,7 +83,7 @@
</item>
</argument>
</column>
<actionsColumn name="actions" class="Magento\Inventory\Ui\Component\Listing\Column\Magentoinventorysource\PageActions">
<actionsColumn name="actions" class="Magento\Inventory\Ui\Component\Listing\Columns\SourceActions">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="resizeEnabled" xsi:type="boolean">false</item>
Expand Down

0 comments on commit 771b143

Please sign in to comment.