├── .gitignore
├── first-pass-unstable
└── app
│ └── code
│ └── Pulsestorm
│ └── SimpleUiComponent
│ ├── view
│ ├── adminhtml
│ │ ├── templates
│ │ │ └── content.phtml
│ │ ├── ui_component
│ │ │ ├── templates
│ │ │ │ └── different.xhtml
│ │ │ └── pulsestorm_simple.xml
│ │ └── layout
│ │ │ └── pulsestorm_simpleuicomponent_index_index.xml
│ └── base
│ │ └── ui_component
│ │ └── etc
│ │ ├── definition.xml
│ │ └── definition.map.xml
│ ├── Block
│ └── Adminhtml
│ │ └── Main.php
│ ├── registration.php
│ ├── Model
│ ├── DataProvider.php
│ └── ValidationState.php
│ ├── etc
│ ├── module.xml
│ ├── di.xml
│ ├── adminhtml
│ │ ├── routes.xml
│ │ └── menu.xml
│ └── acl.xml
│ ├── Component
│ └── Simple.php
│ └── Controller
│ └── Adminhtml
│ └── Index
│ └── Index.php
├── second-pass-stable
└── app
│ └── code
│ └── Pulsestorm
│ └── SimpleUiComponent
│ ├── view
│ └── adminhtml
│ │ ├── templates
│ │ └── content.phtml
│ │ ├── web
│ │ ├── template
│ │ │ └── pulsestorm_simple_template.html
│ │ └── js
│ │ │ └── pulsestorm_simple_component.js
│ │ ├── layout
│ │ └── pulsestorm_simpleuicomponent_index_index.xml
│ │ └── ui_component
│ │ ├── templates
│ │ └── different.xhtml
│ │ └── pulsestorm_simple.xml
│ ├── Block
│ └── Adminhtml
│ │ └── Main.php
│ ├── registration.php
│ ├── Model
│ └── DataProvider.php
│ ├── etc
│ ├── module.xml
│ ├── adminhtml
│ │ ├── routes.xml
│ │ └── menu.xml
│ └── acl.xml
│ ├── Component
│ └── Simple.php
│ └── Controller
│ └── Adminhtml
│ └── Index
│ └── Index.php
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *bak*.php
3 | *bak*.xml
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/view/adminhtml/templates/content.phtml:
--------------------------------------------------------------------------------
1 |
This is my template, there are many like it, but this one is mine.
--------------------------------------------------------------------------------
/second-pass-stable/app/code/Pulsestorm/SimpleUiComponent/view/adminhtml/templates/content.phtml:
--------------------------------------------------------------------------------
1 | This is my template, there are many like it, but this one is mine.
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/view/adminhtml/ui_component/templates/different.xhtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Hello Brave New World
4 |
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/Block/Adminhtml/Main.php:
--------------------------------------------------------------------------------
1 | 'baz']];
8 | }
9 | }
--------------------------------------------------------------------------------
/second-pass-stable/app/code/Pulsestorm/SimpleUiComponent/Model/DataProvider.php:
--------------------------------------------------------------------------------
1 | 'baz']];
8 | }
9 | }
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/etc/module.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/second-pass-stable/app/code/Pulsestorm/SimpleUiComponent/etc/module.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/Model/ValidationState.php:
--------------------------------------------------------------------------------
1 |
3 |
4 | Rendered with Knockout.js
5 |
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/view/base/ui_component/etc/definition.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/etc/di.xml:
--------------------------------------------------------------------------------
1 |
2 | -->
3 |
4 |
5 |
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/etc/adminhtml/routes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/second-pass-stable/app/code/Pulsestorm/SimpleUiComponent/etc/adminhtml/routes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/view/adminhtml/layout/pulsestorm_simpleuicomponent_index_index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/second-pass-stable/app/code/Pulsestorm/SimpleUiComponent/view/adminhtml/layout/pulsestorm_simpleuicomponent_index_index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/etc/adminhtml/menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/second-pass-stable/app/code/Pulsestorm/SimpleUiComponent/etc/adminhtml/menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/etc/acl.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/second-pass-stable/app/code/Pulsestorm/SimpleUiComponent/etc/acl.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/Component/Simple.php:
--------------------------------------------------------------------------------
1 | $this->getContext()->getDataProvider()->getData()];
20 | }
21 | }
--------------------------------------------------------------------------------
/second-pass-stable/app/code/Pulsestorm/SimpleUiComponent/Component/Simple.php:
--------------------------------------------------------------------------------
1 | $this->getContext()->getDataProvider()->getData()];
20 | }
21 | }
--------------------------------------------------------------------------------
/second-pass-stable/app/code/Pulsestorm/SimpleUiComponent/view/adminhtml/web/js/pulsestorm_simple_component.js:
--------------------------------------------------------------------------------
1 | define(['uiElement','ko'], function(Element, ko){
2 | //needs to return a js object extended from uiElement that
3 | //defines a template. Magento and Knockout.js will use
4 | //the returned object as a view model constructor
5 | viewModelConstructor = Element.extend({
6 | defaults: {
7 | template: 'Pulsestorm_SimpleUiComponent/pulsestorm_simple_template'
8 | },
9 | message: ko.observable("Hello Knockout.js!")
10 | });
11 |
12 | return viewModelConstructor;
13 | });
14 |
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/Controller/Adminhtml/Index/Index.php:
--------------------------------------------------------------------------------
1 | resultPageFactory = $resultPageFactory;
11 | return parent::__construct($context);
12 | }
13 |
14 | public function execute()
15 | {
16 | return $this->resultPageFactory->create();
17 | }
18 | protected function _isAllowed()
19 | {
20 | return $this->_authorization->isAllowed('ACL RULE HERE');
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/second-pass-stable/app/code/Pulsestorm/SimpleUiComponent/Controller/Adminhtml/Index/Index.php:
--------------------------------------------------------------------------------
1 | resultPageFactory = $resultPageFactory;
11 | return parent::__construct($context);
12 | }
13 |
14 | public function execute()
15 | {
16 | return $this->resultPageFactory->create();
17 | }
18 | protected function _isAllowed()
19 | {
20 | return $this->_authorization->isAllowed('ACL RULE HERE');
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/view/base/ui_component/etc/definition.map.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | -
7 |
- @provider
8 | - @component
9 | - @template
10 | - @sortOrder
11 | - @displayArea
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/second-pass-stable/app/code/Pulsestorm/SimpleUiComponent/view/adminhtml/ui_component/templates/different.xhtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
Hello Brave New World
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # magento2-simple-ui-component
2 |
3 | This repository holds sample code for the [Magento UI Component](http://alanstorm.com/category/magento-2#magento_2_ui) series.
4 |
5 | The code in `first-pass-unstable` disables Magento's XSD configuration in order to create a very basic UI Component that, similar to core components, renders an XHTML template.
6 |
7 | The code in `second-pass-stable` attempts to create a simple UI Component that loads RequireJS modules/Knockout.js view models and templates, **and** does so without violating the Magento provided XSD files.
8 |
9 | Code samples are currently tested against Magento 2.1.1. Hopefully the techniques hold solid. See the [Simplest UI Component](http://alanstorm.com/magento_simplest_ui_component) article, other [others in the series](http://alanstorm.com/category/magento-2#magento_2_ui), for more context.
10 |
11 | The release of Magento 2.2 broke the `first-pass-unstable` version of this module. We were able to fix it by [cargo cultingadding the following file](https://github.com/astorm/magento2-simple-ui-component/blob/master/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/view/base/ui_component/etc/definition.map.xml). We don't really know why this works, as `definition.map.xml` is one of those things Magento have added without really explaining what it's for.
--------------------------------------------------------------------------------
/first-pass-unstable/app/code/Pulsestorm/SimpleUiComponent/view/adminhtml/ui_component/pulsestorm_simple.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | - templates/different
4 |
5 |
6 |
7 |
8 |
9 | Pulsestorm\SimpleUiComponent\Model\DataProvider
10 |
11 |
12 | pulsestorm_simple_data_source
13 |
14 |
15 | entity_id
16 |
17 |
18 | id
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/second-pass-stable/app/code/Pulsestorm/SimpleUiComponent/view/adminhtml/ui_component/pulsestorm_simple.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 | - templates/different
8 |
9 |
10 |
11 |
12 |
13 | Pulsestorm\SimpleUiComponent\Model\DataProvider
14 |
15 |
16 | hello_world_data_source
17 |
18 |
19 | entity_id
20 |
21 |
22 | id
23 |
24 |
25 |
26 |
27 |
29 |
30 |
32 | Magento\Framework\View\Element\Text
33 |
34 | -
35 |
37 |
- Pulsestorm_SimpleUiComponent/js/pulsestorm_simple_component
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------