maria kern – netz98 gmbh magento 2 ui...
TRANSCRIPT
![Page 1: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/1.jpg)
MARIA KERN – NETZ98 GMBH
MAGENTO 2 UI COMPONENTSTHE JS PART
![Page 2: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/2.jpg)
Maria KernSenior Frontend Architect at netz98 GmbH
www.netz98.de
@maja_kern
CommerceHero: maria-kern
Magento 2 UI Components – The JS part
![Page 3: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/3.jpg)
netz98 GmbH www.netz98.de [email protected]
1
2
3
4
5
6
DEFINITION
REAL LIFE EXAMPLEBASIC STRUCTURE
DEBUGGING USEFUL FUNCTIONS AND PROPERTIES
INITIALIZATION PROCESS
MAGENTO 2 UI COMPONENTS – THE JS PART
AGENDA
3
4
![Page 4: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/4.jpg)
UI components definitionMAGENTO 2 UI COMPONENTS – THE JS PART
![Page 5: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/5.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
UI COMPONENTS DEFINITION
5
The UI components are:
• the base for many user interface (UI) elements(buttons, fields, tables, minicart)
• designed for simple and flexible rendering of user interfaces
• defined in the module Magento_UI
• used in Magento frontend and backend
![Page 6: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/6.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
UI COMPONENTS DEFINITION
6
BACKEND FRONTEND
![Page 7: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/7.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
UI COMPONENTS DEFINITION
7
Magento_Ui/js/grid/listing
Magento_Ui/js/grid/toolbar
Magento_Ui/js/form/element/abstract
Magento_Ui/js/form/components/fieldsetBACKEND FRONTEND
![Page 8: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/8.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
UI COMPONENTS DEFINITION
8
Magento_Checkout/js/view/cart/totals
Magento_Ui/js/grid/listing
Magento_Ui/js/grid/toolbar
Magento_Ui/js/form/element/abstract
Magento_Checkout/js/view/minicart
Magento_Ui/js/form/components/fieldsetBACKEND FRONTEND
![Page 9: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/9.jpg)
Basic structure of UI componentsMAGENTO 2 UI COMPONENTS – THE JS PART
![Page 10: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/10.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
BASIC STRUCTURE OF UI COMPONENTS
10
uiClass
uiElement
uiCollection /uiComponent
JS DEPENDENCY AND INHERITANCE
![Page 11: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/11.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
BASIC STRUCTURE OF UI COMPONENTS
11
uiClass
uiElement
uiCollection /uiComponent
JS DEPENDENCY AND INHERITANCE
<UI_Module_dir>/view/base/web/js/lib/core/class.js
<UI_Module_dir>/view/base/web/js/lib/core/element/element.js
<UI_Module_dir>/view/base/web/js/lib/core/collection.js
![Page 12: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/12.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
BASIC STRUCTURE OF UI COMPONENTS
12
uiClass
uiElement
uiCollection /uiComponent
JS DEPENDENCY AND INHERITANCE
<UI_Module_dir>/view/base/web/js/lib/core/class.js
<UI_Module_dir>/view/base/web/js/lib/core/element/element.js
<UI_Module_dir>/view/base/web/js/lib/core/collection.js
the uiClass is an abstract class where all components are extended from
![Page 13: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/13.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS - THE JS PART
BASIC STRUCTURE OF UI COMPONENTS
13
uiClass
uiElement
uiCollection /uiComponent
custom component 1
custom component 2 custom component 3
child component other child component
JS DEPENDENCY AND INHERITANCE
<UI_Module_dir>/view/base/web/js/lib/core/class.js
<UI_Module_dir>/view/base/web/js/lib/core/element/element.js
<UI_Module_dir>/view/base/web/js/lib/core/collection.js
other child component
use uiElement class as base class of your own component, if you won’t have child components
![Page 14: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/14.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS - THE JS PART
BASIC STRUCTURE OF UI COMPONENTS
14
uiClass
uiElement
uiCollection /uiComponent
custom component 1
custom component 2 custom component 3
child component other child component
JS DEPENDENCY AND INHERITANCE
<UI_Module_dir>/view/base/web/js/lib/core/class.js
<UI_Module_dir>/view/base/web/js/lib/core/element/element.js
<UI_Module_dir>/view/base/web/js/lib/core/collection.js
other child component
use uiCollection / uiComponent class as base, if your component will contain a collection of child UI components
![Page 15: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/15.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS - THE JS PART
BASIC STRUCTURE OF UI COMPONENTS
15
uiClass
uiElement
uiCollection /uiComponent
custom component 1
custom component 2 custom component 3
child component other child component
JS DEPENDENCY AND INHERITANCE
<UI_Module_dir>/view/base/web/js/lib/core/class.js
<UI_Module_dir>/view/base/web/js/lib/core/element/element.js
<UI_Module_dir>/view/base/web/js/lib/core/collection.js
other child component
![Page 16: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/16.jpg)
Useful functions and propertiesMAGENTO 2 UI COMPONENTS – THE JS PART
![Page 17: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/17.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
17
• extend() implements inheritance of UI components
• initialize() is called during instantiation
EXTEND AND INITIALIZE
![Page 18: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/18.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
18
• extend() implements inheritance of UI components
• initialize() is called during instantiation
EXTEND AND INITIALIZE
DEPENDENCY
![Page 19: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/19.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
19
• extend() implements inheritance of UI components
• initialize() is called during instantiation
EXTEND AND INITIALIZE
INHERITANCE
![Page 20: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/20.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
20
• extend() implements inheritance of UI components
• initialize() is called during instantiation
EXTEND AND INITIALIZE
OVERWRITE / EXTEND A METHOD
![Page 21: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/21.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
21
CONFIGURATION AND FIRST LEVEL PROPERTIES
Every component has a “defaults” object
> Declaring properties
![Page 22: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/22.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
22
CONFIGURATION AND FIRST LEVEL PROPERTIES
custom properties
![Page 23: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/23.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
23
CONFIGURATION AND FIRST LEVEL PROPERTIES
a lot of given properties
![Page 24: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/24.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
24
CONFIGURATION AND FIRST LEVEL PROPERTIES
Configuration properties will be available as “first level properties”
this.isVisible
![Page 25: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/25.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
25
A lot of default properties and methods are already set by the base classes, e.g.:
this.index // name of component
this.name // full name of component including parents
this.template // path to template file
this.component
this.getTemplate()
this.hasTemplate()
CONFIGURATION AND FIRST LEVEL PROPERTIES
![Page 26: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/26.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
26
KNOCKOUT JS
Binding data to HTML Elements by data-bind Attribute
![Page 27: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/27.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
27
Declaring observable variables
KNOCKOUT JS
![Page 28: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/28.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
28
KNOCKOUT JS
Declaring observable variables
![Page 29: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/29.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
29
The uiCollection class (mainly) provides a lot of methods for handling of child components
HANDLING OF CHILDREN
![Page 30: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/30.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
30
The uiCollection class (mainly) provides a lot of methods for handling of child components
HANDLING OF CHILDREN
Called for every childcomponent
> Child is given as parameter
![Page 31: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/31.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
USEFUL FUNCTIONS AND PROPERTIES
31
The uiCollection class (mainly) provides a lot of methods for handling of child components
initElement(child) {}
this.elems()
this.containers
this.getChild(‘nameOfChild’) // UI component
this.hasChild(‘nameOfChild’) // boolean
this.insertChild(‘nameOfComponent’)
HANDLING OF CHILDREN
![Page 32: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/32.jpg)
Initialization processMAGENTO 2 UI COMPONENTS – THE JS PART
![Page 33: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/33.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
INITIALIZATION PROCESS
33
All the configurations are translated into json and added to the body
![Page 34: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/34.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
INITIALIZATION PROCESS
34
![Page 35: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/35.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
INITIALIZATION PROCESS
35
All the configurations are translated into json and added to the body
![Page 36: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/36.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
INITIALIZATION PROCESS
36
All the configurations are translated into json and added to the body
![Page 37: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/37.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
INITIALIZATION PROCESS
37
• The app calls Magento_Ui/js/core/renderer/layout and passes the UI component’s configuration into the layout
![Page 38: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/38.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
INITIALIZATION PROCESS
38
• layout.js creates instances of UI components and its child components
![Page 39: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/39.jpg)
Real life exampleMAGENTO 2 UI COMPONENTS – THE JS PART
![Page 40: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/40.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
REAL LIFE EXAMPLE
40
UI component„map-widget“
![Page 41: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/41.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
REAL LIFE EXAMPLE
41
UI component„map-widget“
![Page 42: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/42.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
REAL LIFE EXAMPLE
42
child UI component„productlist“
productlist could be used in other components as well
![Page 43: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/43.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
REAL LIFE EXAMPLE
43
UI ComponentsJS and Template
files
Initialization
![Page 44: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/44.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
REAL LIFE EXAMPLE
44
Parent component
Child component
![Page 45: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/45.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
REAL LIFE EXAMPLE
45
Parent extendsuiCollection
class
initElement(child) {}this.getChild(‘productlist’)
![Page 46: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/46.jpg)
Options for debuggingMAGENTO 2 UI COMPONENTS – THE JS PART
![Page 47: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/47.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
OPTIONS FOR DEBUGGING
47
Chrome Knockoutjs Context Debugger
click on DOM elementinside UI component scope
![Page 48: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/48.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
OPTIONS FOR DEBUGGING
48
Magento DevTools by MageSpecialist, with Chrome extension
list of all initialized UI components on the actual page with link to inspect theDOM element
![Page 49: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/49.jpg)
netz98 GmbH www.netz98.de [email protected]
MAGENTO 2 UI COMPONENTS – THE JS PART
CONCLUSION
49
Advantages
• easy teamwork – standardized programming
• common procedures and requirements have already been implemented
• configuring without inline scripting!
Disadvantages
• it takes time to get familiar with
• sometimes it feels to be restricted in frontend development
UI COMPONENTS – THE JS PART
![Page 50: MARIA KERN – NETZ98 GMBH MAGENTO 2 UI COMPONENTSuk.magetitans.com/wp-content/uploads/2017/06/Mage-Titans-Maria-Kerns.pdf · Maria Kern Senior Frontend Architect at netz98 GmbH @maja_kern](https://reader030.vdocuments.us/reader030/viewer/2022040714/5e1c2fcd71ab4a1f781d07ab/html5/thumbnails/50.jpg)
THANK YOU!
References:http://devdocs.magento.com/
Slideshttp://XXXXXXXXXXXXX/