SlideShare a Scribd company logo
1 of 26
Download to read offline
CRUD with
Polymer 2.0 And Vaadin Elements
Manuel Carrasco Moñino
Vaadin Elements Team
CRUD Basis
- Create, Read, Update & Delete Entities
- Describes UI conventions that allow viewing,
searching and modifying information
- The most tedious part of App programming
(50-80% of Enterprise apps)
Typical CRUD View
- A list view
- Filtering
- Sorting
- Responsive
- An edit view
- Validation
- Responsive
- Dialog
- User Confirmation
Objective
Since CRUD is included in almost FW, let’s
create some nice helpers for Polymer 2
Strategy
- Write Re-usable classes or components
- Define CRUD views via Declarative Views
- Reliable Operations
- Dirty detection
- Confirmation
- Validation
- Good Looking UI
- Enterprise components & Themable
- Bound to any data source
The crud-view project
https://github.com/manolo/crud-view
Two ES6 mixins
- CrudListMixin ES6 class for the list view.
- CrudItemMixin ES6 class for the entity editor.
One Polymer 2 Element
- <crud-view> P2 element to enable dialogs
Contents of crud-view project
CrudListMixin API
CrudListMixin
Usage
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../bower_components/vaadin-grid/vaadin-grid.html">
<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
<link rel="import" href="../../bower_components/crud-view/crud-list-mixin.html">
<link rel="import" href="crud-user.html">
<dom-module id="crud-users">
<template>
<iron-ajax auto url="/dummy/users.json" handle-as="json" last-response="{{items}}"></iron-ajax>
<input value="{{search::input}}"></input> <button on-click="new">New Item</button>
<vaadin-grid id="grid" items="[[filter(items, search, items.*)]]" active-item="{{activeItem}}">
<vaadin-grid-column>
<template>[[item.email]]</template>
</vaadin-grid-column>
<vaadin-grid-column>
<template>[[item.name]] [[item.last]]</template>
</vaadin-grid-column>
</vaadin-grid>
<br>
<crud-user id="editor" item="[[item]]" on-save="save" on-delete="delete" on-close="close"></crud-user>
</template>
<script>
class CrudUsers extends window.CrudListMixin(Polymer.Element) {
static get is() {
return 'crud-users';
}
}
window.customElements.define(CrudUsers.is, CrudUsers);
</script>
</dom-module>
CrudItemMixin API
CrudItemMixin
Usage
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../bower_components/crud-view/crud-item-mixin.html">
<dom-module id="crud-user">
<template>
Email: <input value="{{item.email::input}}"></input>
First: <input value="{{item.name::input}}"></input>
Last: <input value="{{item.last::input}}"></input>
<button on-click="save" disabled="[[!dirty]]">Save</button>
<button on-click="cancel">Cancel</button>
<button on-click="delete" disabled="[[new]]">Delete</button>
</template>
<script>
class CrudUser extends window.CrudItemMixin(Polymer.Element) {
static get is() {
return 'crud-user';
}
}
window.customElements.define(CrudUser.is, CrudUser);
</script>
</dom-module>
<crud-view> API
<crud-view>
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel="import" href="../../bower_components/vaadin-grid/vaadin-grid.html">
<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
<link rel="import" href="../../bower_components/crud-view/crud-list-mixin.html">
<link rel="import" href="../../bower_components/crud-view/crud-view.html">
<link rel="import" href="crud-user.html">
<dom-module id="crud-users">
<template>
<iron-ajax auto url="/dummy/users.json" handle-as="json" last-response="{{items}}"></iron-ajax>
<crud-view editing="[[editing]]" >
<input slot="header" value="{{search::input}}"></input>
<button slot="header" on-click="new">New Item</button>
<vaadin-grid id="grid" slot="grid" items="[[filter(items, search, items.*)]]" active-item="{{activeItem}}">
<vaadin-grid-column>
<template>[[item.email]]</template>
</vaadin-grid-column>
<vaadin-grid-column>
<template>[[item.name]] [[item.last]]</template>
</vaadin-grid-column>
</vaadin-grid>
<br>
<crud-user id="editor" slot="editor" item="[[item]]" on-save="save" on-delete="delete" on-close="close"></crud-user>
</crud-view>
</template>
<script>
class CrudUsers extends window.CrudListMixin(Polymer.Element) {
static get is() {
return 'crud-users';
}
}
window.customElements.define(CrudUsers.is, CrudUsers);
</script>
</dom-module>
UI Elements
- Data listing (filtering, ordering)
- <vaadin-grid>
- Responsive form
- <vaadin-form-layout>
- Form fields
- Core elements: <vaadin-text-field> <vaadin-button> ...
- Dialogs
- <vaadin-dialog>
- Data retrieval & modification
- <iron-ajax> or <vaadin-pouchdb>
UI Elements
Vaadin
Core
Elements
<vaadin-form-layout>
<vaadin-text-field colspan="2" label="Login" value="{{item.email}}"></vaadin-text-field>
<br>
<vaadin-password-field colspan="2" label="Password"
value="{{item.password}}"></vaadin-password-field>
<br>
<vaadin-text-field label="Name" value="{{item.name}}"></vaadin-text-field>
<vaadin-text-field label="Surname" value="{{item.last}}"></vaadin-text-field>
<br>
<vaadin-combo-box label="Role" value="{{item.role}}"
items='["admin","operator","user"]'></vaadin-combo-box>
<vaadin-date-picker label="Birthday" value="{{item.birthday}}"></vaadin-date-picker>
</vaadin-form-layout>
<br>
<div class="buttons">
<vaadin-button on-click="save" theme="primary" disabled="[[!dirty]]">Save</vaadin-button>
<vaadin-button on-click="cancel">Cancel</vaadin-button>
<span style="flex: 1"></span>
<vaadin-button on-click="delete" theme="danger" disabled="[[new]]">Delete</vaadin-button>
</div>
Theming
Valo
Theme
<link rel="import" href="bower_components/vaadin-themes/valo/typography.html">
<link rel="import" href="bower_components/vaadin-themes/valo/color.html">
<link rel="import" href="bower_components/vaadin-themes/valo/sizing-and-spacing.html">
<link rel="import" href="bower_components/vaadin-themes/valo/style.html">
<link rel="import" href="bower_components/vaadin-themes/valo/icons.html">
<link rel="import" href="bower_components/vaadin-themes/valo/vaadin-button.html">
<link rel="import" href="bower_components/vaadin-themes/valo/vaadin-text-field.html">
<link rel="import" href="bower_components/vaadin-themes/valo/vaadin-checkbox.html">
<link rel="import" href="bower_components/vaadin-themes/valo/vaadin-date-picker.html">
<link rel="import" href="bower_components/vaadin-themes/valo/vaadin-form-layout.html">
<link rel="import" href="bower_components/vaadin-themes/valo/vaadin-form-item.html">
<link rel="import" href="bower_components/vaadin-themes/valo/vaadin-combo-box.html">
Material
Theme
<link rel="import" href="bower_components/vaadin-themes/material/typography.html">
<link rel="import" href="bower_components/vaadin-themes/material/color.html">
<link rel="import" href="bower_components/vaadin-themes/material/vaadin-button.html">
<link rel="import" href="bower_components/vaadin-themes/material/vaadin-text-field.html">
<link rel="import" href="bower_components/vaadin-themes/material/vaadin-date-picker.html">
Validation
Validation
<vaadin-form-layout style="padding: 10px">
<vaadin-text-field colspan="2" label="Login" value="{{item.email}}"
required pattern="[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,4}$"></vaadin-text-field>
<br>
<vaadin-password-field colspan="2" label="Password" value="{{item.password}}"
required pattern="(?=.*d)(?=.*[a-z])(?=.*[A-Z]).{6,}"></vaadin-password-field>
<br>
<vaadin-text-field label="Name" value="{{item.name}}"
required pattern=".{3,}"></vaadin-text-field>
<vaadin-text-field label="Surname" value="{{item.last}}"></vaadin-text-field>
<br>
<vaadin-combo-box label="Role" value="{{item.role}}"
items='["admin","operator","user"]' required></vaadin-combo-box>
<vaadin-date-picker label="Birthday" value="{{item.birthday}}"></vaadin-date-picker>
</vaadin-form-layout>
<br>
<div class="buttons">
<vaadin-button on-click="save" theme="primary" disabled="[[!dirty]]">Save</vaadin-button>
<vaadin-button on-click="cancel">Cancel</vaadin-button>
<span style="flex: 1"></span>
<vaadin-button on-click="delete" theme="danger" disabled="[[new]]">Delete</vaadin-button>
</div>
Persisting Data
iron-ajax
<iron-ajax auto url="/users.json" handle-as="json"
last-response="{{items}}"></iron-ajax>
pouchdb <vaadin-pouchdb dbname="demo" data="{{items}}"
remote="https://my-account.cloudant.com/demo"></vaadin-pouchdb>
Demo architecture
Vaadin Elem.
Polymer 2
PouchDB CouchDB
Serv. Worker HTTP
IndexedDB
crud-view
Demo steps
Follow the steps in repo https://github.com/manolo/crud-slides-demo/commits/master
- Step 1: polymer init and bower dependencies
- Step 2: CrudListMixin and <vaadin-grid> in the users view
- Step 3: CrudItemMixin in the user edit view
- Step 4: <crud-view> wrapping grid and editor
- Step 5: Add a search-bar to the users view
- Step 6: Add sort helpers to the grid
- Step 7: Replace native elements with vaadin ones
- Step 8: Import the vaadin valo theme
- Step 9: Configure field validation
- Step 10: Replace <iron-ajax> with <vaadin-pouchdb>
Thanks
Manuel Carrasco Moñino
+ManuelCarrascoMonino
manolo@vaadin.com
@dodotis

More Related Content

What's hot

Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022
NAVER D2
 
Google Web Toolkit (JUG Latvia)
Google Web Toolkit (JUG Latvia)Google Web Toolkit (JUG Latvia)
Google Web Toolkit (JUG Latvia)
Dmitry Buzdin
 
125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용
NAVER D2
 

What's hot (20)

Java EE 6 Aquarium Paris
Java EE 6 Aquarium ParisJava EE 6 Aquarium Paris
Java EE 6 Aquarium Paris
 
Web Space10 Overview
Web Space10 OverviewWeb Space10 Overview
Web Space10 Overview
 
Java EE 6
Java EE 6Java EE 6
Java EE 6
 
Web components with java by Haijian Wang
Web components with java by Haijian WangWeb components with java by Haijian Wang
Web components with java by Haijian Wang
 
Web Applications with AngularJS
Web Applications with AngularJSWeb Applications with AngularJS
Web Applications with AngularJS
 
GlassFish v3 Prelude Aquarium Paris
GlassFish v3 Prelude Aquarium ParisGlassFish v3 Prelude Aquarium Paris
GlassFish v3 Prelude Aquarium Paris
 
The WebKit project
The WebKit projectThe WebKit project
The WebKit project
 
GlassFish v3 : En Route Java EE 6
GlassFish v3 : En Route Java EE 6GlassFish v3 : En Route Java EE 6
GlassFish v3 : En Route Java EE 6
 
Turducken - Divide and Conquer large GWT apps with multiple teams
Turducken - Divide and Conquer large GWT apps with multiple teamsTurducken - Divide and Conquer large GWT apps with multiple teams
Turducken - Divide and Conquer large GWT apps with multiple teams
 
Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022
 
2013 04-02-server-side-backbone
2013 04-02-server-side-backbone2013 04-02-server-side-backbone
2013 04-02-server-side-backbone
 
WebGL For Game Development Spring 2013
WebGL For Game Development Spring 2013WebGL For Game Development Spring 2013
WebGL For Game Development Spring 2013
 
WPE WebKit for Android
WPE WebKit for AndroidWPE WebKit for Android
WPE WebKit for Android
 
30 JavaScript optimization tips
30 JavaScript optimization tips30 JavaScript optimization tips
30 JavaScript optimization tips
 
Google Web Toolkit (JUG Latvia)
Google Web Toolkit (JUG Latvia)Google Web Toolkit (JUG Latvia)
Google Web Toolkit (JUG Latvia)
 
Project Fuji/OpenESB Aquarium Paris
Project Fuji/OpenESB Aquarium ParisProject Fuji/OpenESB Aquarium Paris
Project Fuji/OpenESB Aquarium Paris
 
Reactjs Introduction - Virtual DOM
Reactjs Introduction - Virtual DOMReactjs Introduction - Virtual DOM
Reactjs Introduction - Virtual DOM
 
Angularjs practical project experiences with javascript development in a bank
Angularjs practical project experiences with javascript development in a bankAngularjs practical project experiences with javascript development in a bank
Angularjs practical project experiences with javascript development in a bank
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
 
125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용
 

Similar to CRUD with Polymer 2.0

Zend Framework 2 - presentation
Zend Framework 2 - presentationZend Framework 2 - presentation
Zend Framework 2 - presentation
yamcsha
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
Dilip Patel
 

Similar to CRUD with Polymer 2.0 (20)

Modular android Project
Modular android ProjectModular android Project
Modular android Project
 
Web Components for Java Developers
Web Components for Java DevelopersWeb Components for Java Developers
Web Components for Java Developers
 
Google Polymer Introduction
Google Polymer IntroductionGoogle Polymer Introduction
Google Polymer Introduction
 
07_UIAndroid.pdf
07_UIAndroid.pdf07_UIAndroid.pdf
07_UIAndroid.pdf
 
Introduction to UI Components in Magento 2
Introduction to UI Components in Magento 2Introduction to UI Components in Magento 2
Introduction to UI Components in Magento 2
 
AD Cmdlets
AD CmdletsAD Cmdlets
AD Cmdlets
 
Chapter 10
Chapter 10Chapter 10
Chapter 10
 
SeedStack feature tour
SeedStack feature tourSeedStack feature tour
SeedStack feature tour
 
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
 
Zotonic tutorial EUC 2013
Zotonic tutorial EUC 2013Zotonic tutorial EUC 2013
Zotonic tutorial EUC 2013
 
Angular2 + rxjs
Angular2 + rxjsAngular2 + rxjs
Angular2 + rxjs
 
Zend Framework 2 - presentation
Zend Framework 2 - presentationZend Framework 2 - presentation
Zend Framework 2 - presentation
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular U
 
Jsf
JsfJsf
Jsf
 
The Complementarity of React and Web Components
The Complementarity of React and Web ComponentsThe Complementarity of React and Web Components
The Complementarity of React and Web Components
 
The Rails Way
The Rails WayThe Rails Way
The Rails Way
 
Data Binding
Data BindingData Binding
Data Binding
 
QCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIQCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UI
 
Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?
 

More from Manuel Carrasco Moñino

Gwt seminario java_hispano_manolocarrasco
Gwt seminario java_hispano_manolocarrascoGwt seminario java_hispano_manolocarrasco
Gwt seminario java_hispano_manolocarrasco
Manuel Carrasco Moñino
 

More from Manuel Carrasco Moñino (20)

GWT Contributor Workshop
GWT Contributor WorkshopGWT Contributor Workshop
GWT Contributor Workshop
 
Building Components for Business Apps
Building Components for Business AppsBuilding Components for Business Apps
Building Components for Business Apps
 
Intro to Web Components, Polymer & Vaadin Elements
Intro to Web Components, Polymer & Vaadin ElementsIntro to Web Components, Polymer & Vaadin Elements
Intro to Web Components, Polymer & Vaadin Elements
 
Rock GWT UI's with Polymer Elements
Rock GWT UI's with Polymer ElementsRock GWT UI's with Polymer Elements
Rock GWT UI's with Polymer Elements
 
Introducing GWT Polymer (vaadin)
Introducing GWT Polymer (vaadin)Introducing GWT Polymer (vaadin)
Introducing GWT Polymer (vaadin)
 
Speed up your GWT coding with gQuery
Speed up your GWT coding with gQuerySpeed up your GWT coding with gQuery
Speed up your GWT coding with gQuery
 
Vaadin codemotion 2014
Vaadin codemotion 2014Vaadin codemotion 2014
Vaadin codemotion 2014
 
GwtQuery the perfect companion for GWT, GWT.create 2013
GwtQuery the perfect companion for GWT,  GWT.create 2013GwtQuery the perfect companion for GWT,  GWT.create 2013
GwtQuery the perfect companion for GWT, GWT.create 2013
 
Rapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWTRapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWT
 
Aprendiendo GWT
Aprendiendo GWTAprendiendo GWT
Aprendiendo GWT
 
GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011
 
Apache James/Hupa & GWT
Apache James/Hupa & GWTApache James/Hupa & GWT
Apache James/Hupa & GWT
 
GWT: Why GWT, GQuery, and RequestFactory
GWT: Why GWT, GQuery, and RequestFactoryGWT: Why GWT, GQuery, and RequestFactory
GWT: Why GWT, GQuery, and RequestFactory
 
Mod security
Mod securityMod security
Mod security
 
Gwt IV -mvp
Gwt IV -mvpGwt IV -mvp
Gwt IV -mvp
 
Gwt III - Avanzado
Gwt III - AvanzadoGwt III - Avanzado
Gwt III - Avanzado
 
Gwt II - trabajando con gwt
Gwt II - trabajando con gwtGwt II - trabajando con gwt
Gwt II - trabajando con gwt
 
Gwt I - entendiendo gwt
Gwt I - entendiendo gwtGwt I - entendiendo gwt
Gwt I - entendiendo gwt
 
Seguridad en redes de computadores
Seguridad en redes de computadoresSeguridad en redes de computadores
Seguridad en redes de computadores
 
Gwt seminario java_hispano_manolocarrasco
Gwt seminario java_hispano_manolocarrascoGwt seminario java_hispano_manolocarrasco
Gwt seminario java_hispano_manolocarrasco
 

Recently uploaded

Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Monica Sydney
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
ayvbos
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
JOHNBEBONYAP1
 
一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理
F
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
gajnagarg
 
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu DhabiAbu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Monica Sydney
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Monica Sydney
 
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.
 
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime BalliaBallia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Best SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency DallasBest SEO Services Company in Dallas | Best SEO Agency Dallas
Best SEO Services Company in Dallas | Best SEO Agency Dallas
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
 
Call girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girlsCall girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girls
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu DhabiAbu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
 
Mira Road Housewife Call Girls 07506202331, Nalasopara Call Girls
Mira Road Housewife Call Girls 07506202331, Nalasopara Call GirlsMira Road Housewife Call Girls 07506202331, Nalasopara Call Girls
Mira Road Housewife Call Girls 07506202331, Nalasopara Call Girls
 
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
 
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac RoomVip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
 
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
call girls in Anand Vihar (delhi) call me [🔝9953056974🔝] escort service 24X7
 

CRUD with Polymer 2.0

  • 1. CRUD with Polymer 2.0 And Vaadin Elements Manuel Carrasco Moñino Vaadin Elements Team
  • 2. CRUD Basis - Create, Read, Update & Delete Entities - Describes UI conventions that allow viewing, searching and modifying information - The most tedious part of App programming (50-80% of Enterprise apps)
  • 3. Typical CRUD View - A list view - Filtering - Sorting - Responsive - An edit view - Validation - Responsive - Dialog - User Confirmation
  • 4. Objective Since CRUD is included in almost FW, let’s create some nice helpers for Polymer 2
  • 5. Strategy - Write Re-usable classes or components - Define CRUD views via Declarative Views - Reliable Operations - Dirty detection - Confirmation - Validation - Good Looking UI - Enterprise components & Themable - Bound to any data source
  • 7. Two ES6 mixins - CrudListMixin ES6 class for the list view. - CrudItemMixin ES6 class for the entity editor. One Polymer 2 Element - <crud-view> P2 element to enable dialogs Contents of crud-view project
  • 9. CrudListMixin Usage <link rel="import" href="../../bower_components/polymer/polymer-element.html"> <link rel="import" href="../../bower_components/vaadin-grid/vaadin-grid.html"> <link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html"> <link rel="import" href="../../bower_components/crud-view/crud-list-mixin.html"> <link rel="import" href="crud-user.html"> <dom-module id="crud-users"> <template> <iron-ajax auto url="/dummy/users.json" handle-as="json" last-response="{{items}}"></iron-ajax> <input value="{{search::input}}"></input> <button on-click="new">New Item</button> <vaadin-grid id="grid" items="[[filter(items, search, items.*)]]" active-item="{{activeItem}}"> <vaadin-grid-column> <template>[[item.email]]</template> </vaadin-grid-column> <vaadin-grid-column> <template>[[item.name]] [[item.last]]</template> </vaadin-grid-column> </vaadin-grid> <br> <crud-user id="editor" item="[[item]]" on-save="save" on-delete="delete" on-close="close"></crud-user> </template> <script> class CrudUsers extends window.CrudListMixin(Polymer.Element) { static get is() { return 'crud-users'; } } window.customElements.define(CrudUsers.is, CrudUsers); </script> </dom-module>
  • 11. CrudItemMixin Usage <link rel="import" href="../../bower_components/polymer/polymer-element.html"> <link rel="import" href="../../bower_components/crud-view/crud-item-mixin.html"> <dom-module id="crud-user"> <template> Email: <input value="{{item.email::input}}"></input> First: <input value="{{item.name::input}}"></input> Last: <input value="{{item.last::input}}"></input> <button on-click="save" disabled="[[!dirty]]">Save</button> <button on-click="cancel">Cancel</button> <button on-click="delete" disabled="[[new]]">Delete</button> </template> <script> class CrudUser extends window.CrudItemMixin(Polymer.Element) { static get is() { return 'crud-user'; } } window.customElements.define(CrudUser.is, CrudUser); </script> </dom-module>
  • 13. <crud-view> <link rel="import" href="../../bower_components/polymer/polymer-element.html"> <link rel="import" href="../../bower_components/vaadin-grid/vaadin-grid.html"> <link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html"> <link rel="import" href="../../bower_components/crud-view/crud-list-mixin.html"> <link rel="import" href="../../bower_components/crud-view/crud-view.html"> <link rel="import" href="crud-user.html"> <dom-module id="crud-users"> <template> <iron-ajax auto url="/dummy/users.json" handle-as="json" last-response="{{items}}"></iron-ajax> <crud-view editing="[[editing]]" > <input slot="header" value="{{search::input}}"></input> <button slot="header" on-click="new">New Item</button> <vaadin-grid id="grid" slot="grid" items="[[filter(items, search, items.*)]]" active-item="{{activeItem}}"> <vaadin-grid-column> <template>[[item.email]]</template> </vaadin-grid-column> <vaadin-grid-column> <template>[[item.name]] [[item.last]]</template> </vaadin-grid-column> </vaadin-grid> <br> <crud-user id="editor" slot="editor" item="[[item]]" on-save="save" on-delete="delete" on-close="close"></crud-user> </crud-view> </template> <script> class CrudUsers extends window.CrudListMixin(Polymer.Element) { static get is() { return 'crud-users'; } } window.customElements.define(CrudUsers.is, CrudUsers); </script> </dom-module>
  • 15. - Data listing (filtering, ordering) - <vaadin-grid> - Responsive form - <vaadin-form-layout> - Form fields - Core elements: <vaadin-text-field> <vaadin-button> ... - Dialogs - <vaadin-dialog> - Data retrieval & modification - <iron-ajax> or <vaadin-pouchdb> UI Elements
  • 16. Vaadin Core Elements <vaadin-form-layout> <vaadin-text-field colspan="2" label="Login" value="{{item.email}}"></vaadin-text-field> <br> <vaadin-password-field colspan="2" label="Password" value="{{item.password}}"></vaadin-password-field> <br> <vaadin-text-field label="Name" value="{{item.name}}"></vaadin-text-field> <vaadin-text-field label="Surname" value="{{item.last}}"></vaadin-text-field> <br> <vaadin-combo-box label="Role" value="{{item.role}}" items='["admin","operator","user"]'></vaadin-combo-box> <vaadin-date-picker label="Birthday" value="{{item.birthday}}"></vaadin-date-picker> </vaadin-form-layout> <br> <div class="buttons"> <vaadin-button on-click="save" theme="primary" disabled="[[!dirty]]">Save</vaadin-button> <vaadin-button on-click="cancel">Cancel</vaadin-button> <span style="flex: 1"></span> <vaadin-button on-click="delete" theme="danger" disabled="[[new]]">Delete</vaadin-button> </div>
  • 18. Valo Theme <link rel="import" href="bower_components/vaadin-themes/valo/typography.html"> <link rel="import" href="bower_components/vaadin-themes/valo/color.html"> <link rel="import" href="bower_components/vaadin-themes/valo/sizing-and-spacing.html"> <link rel="import" href="bower_components/vaadin-themes/valo/style.html"> <link rel="import" href="bower_components/vaadin-themes/valo/icons.html"> <link rel="import" href="bower_components/vaadin-themes/valo/vaadin-button.html"> <link rel="import" href="bower_components/vaadin-themes/valo/vaadin-text-field.html"> <link rel="import" href="bower_components/vaadin-themes/valo/vaadin-checkbox.html"> <link rel="import" href="bower_components/vaadin-themes/valo/vaadin-date-picker.html"> <link rel="import" href="bower_components/vaadin-themes/valo/vaadin-form-layout.html"> <link rel="import" href="bower_components/vaadin-themes/valo/vaadin-form-item.html"> <link rel="import" href="bower_components/vaadin-themes/valo/vaadin-combo-box.html">
  • 19. Material Theme <link rel="import" href="bower_components/vaadin-themes/material/typography.html"> <link rel="import" href="bower_components/vaadin-themes/material/color.html"> <link rel="import" href="bower_components/vaadin-themes/material/vaadin-button.html"> <link rel="import" href="bower_components/vaadin-themes/material/vaadin-text-field.html"> <link rel="import" href="bower_components/vaadin-themes/material/vaadin-date-picker.html">
  • 21. Validation <vaadin-form-layout style="padding: 10px"> <vaadin-text-field colspan="2" label="Login" value="{{item.email}}" required pattern="[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,4}$"></vaadin-text-field> <br> <vaadin-password-field colspan="2" label="Password" value="{{item.password}}" required pattern="(?=.*d)(?=.*[a-z])(?=.*[A-Z]).{6,}"></vaadin-password-field> <br> <vaadin-text-field label="Name" value="{{item.name}}" required pattern=".{3,}"></vaadin-text-field> <vaadin-text-field label="Surname" value="{{item.last}}"></vaadin-text-field> <br> <vaadin-combo-box label="Role" value="{{item.role}}" items='["admin","operator","user"]' required></vaadin-combo-box> <vaadin-date-picker label="Birthday" value="{{item.birthday}}"></vaadin-date-picker> </vaadin-form-layout> <br> <div class="buttons"> <vaadin-button on-click="save" theme="primary" disabled="[[!dirty]]">Save</vaadin-button> <vaadin-button on-click="cancel">Cancel</vaadin-button> <span style="flex: 1"></span> <vaadin-button on-click="delete" theme="danger" disabled="[[new]]">Delete</vaadin-button> </div>
  • 23. iron-ajax <iron-ajax auto url="/users.json" handle-as="json" last-response="{{items}}"></iron-ajax> pouchdb <vaadin-pouchdb dbname="demo" data="{{items}}" remote="https://my-account.cloudant.com/demo"></vaadin-pouchdb>
  • 24. Demo architecture Vaadin Elem. Polymer 2 PouchDB CouchDB Serv. Worker HTTP IndexedDB crud-view
  • 25. Demo steps Follow the steps in repo https://github.com/manolo/crud-slides-demo/commits/master - Step 1: polymer init and bower dependencies - Step 2: CrudListMixin and <vaadin-grid> in the users view - Step 3: CrudItemMixin in the user edit view - Step 4: <crud-view> wrapping grid and editor - Step 5: Add a search-bar to the users view - Step 6: Add sort helpers to the grid - Step 7: Replace native elements with vaadin ones - Step 8: Import the vaadin valo theme - Step 9: Configure field validation - Step 10: Replace <iron-ajax> with <vaadin-pouchdb>