30
Angular-ifying your Visualforce pages Abhinav Gupta @abhinavguptas Bringing productivity and fun of web development into Visualforce pages.

Dreamforce 2015 Session - Angular-ifying your visualforce pages

Embed Size (px)

Citation preview

Page 1: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Angular-ifying your

Visualforce pages

Abhinav Gupta

@abhinavguptas

Bringing productivity and fun of web development into Visualforce pages.

Page 2: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Safe harbor statement under the Private Securities Litigation Reform Act of 1995:

This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize

or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the

forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any

projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding

strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or

technology developments and customer contracts or use of our services.

The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for

our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate

of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with

completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability

to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our

limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential

factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year

and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are

available on the SEC Filings section of the Investor Information section of our Web site.

Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and

may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are

currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.

Safe Harbor

Page 3: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Salesforce MVP (5x) & Architect

Founder of Concretio Apps

@abhinavguptas

Speakers

Page 4: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Angular app structuring, industry standard guidelines from

Google’s Angular style guide.

Ionic template apps.

Angular App Structuring in “Salesforce” reviewed in 4 approaches with pros/cons.

Approach 1: Using couple of static resources and supporting VF pages per SPA.

Approach 2: Mavensmate resource bundles.

Approach 3: Aside.io zipped resource editing.

Approach 4: Welkin Suite zipped resource editing.

Live demos of above approaches in a Salesforce org.

Agenda

Page 5: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Angular App StructuringHow web in general understands Angular app structure

Page 6: Dreamforce 2015 Session - Angular-ifying your visualforce pages

App structure for simple app with 1 directive and 1 service.

sampleapp

├── app.css

├── app.js

├── app-controller.js

├── app-controller_test.js

├── components

│ └── foo

│ ├── foo.js

│ ├── foo-directive.js

│ ├── foo-directive_test.js

│ ├── foo-service_test.js

│ ├── foo-service_test.js

├── index.html

Google’s Angular Style Guidehttp://google.github.io/styleguide/angularjs-google-style.html

Page 7: Dreamforce 2015 Session - Angular-ifying your visualforce pages

App structure when service and directive are unrelatedsampleapp

├── app.css

├── app.js

├── app-controller.js

├── app-controller_test.js

├── components

│ └── foo

│ ├── foo.js

│ ├── foo-directive.js

│ ├── foo-directive_test.js

│ └── bar

│ ├── bar.js

│ ├── bar-directive.js

│ ├── bar-directive_test.js

├── index.html

Google’s Angular Style Guidehttp://google.github.io/styleguide/angularjs-google-style.html

Page 8: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Ionic’s structure for a sample “Tabs” apphttp://ionicframework.com/getting-started/

How it looks├── css

│ └── style.css

├── img

│ └── ionic.png

├── index.html

├── js

│ ├── app.js

│ ├── controllers.js

│ └── services.js

├── lib

│ └── ionic

│ ├── …(ionic dist)

└── templates

├── chat-detail.html

├── tab-account.html

├── tab-chats.html

├── tab-dash.html

└── tabs.html

Page 9: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Angular multi tabs SPA

in

“Salesforce”A simple tasks and events management app

Page 10: Dreamforce 2015 Session - Angular-ifying your visualforce pages

For quick glimpse and management of tasks and events.

Built using Angular and Ionic (UI)

Single Page app

Multiple tabs, like Dashboard, Tasks & Events

App Overview

Page 11: Dreamforce 2015 Session - Angular-ifying your visualforce pages

App Demo

Page 12: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Angular App Structuring

in

“Salesforce”How to port generalised ng app structures to visualforce pages ?

Page 13: Dreamforce 2015 Session - Angular-ifying your visualforce pages

├── classes

│ ├── RemoteTKController.cls

│ ├── TestRemoteTKController.cls

├── components

│ ├── RemoteTK.component

└── staticresources

├── ioniclib.resource

Shared Metadata

Page 14: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Approach 1 - Using multiple static resources and pageshttps://developer.salesforce.com/blogs/developer-relations/2014/04/building-beautiful-mobile-apps-in-visualforce-using-angularjs-and-ionic-part-1.html

Raja Rao DV

Developer Advocate @salesforce

@rajaraodv

Very good series of blogs with videos on creating SPAs in VF

Page 15: Dreamforce 2015 Session - Angular-ifying your visualforce pages

4 partial VF pages & 3 additional static resources needed for a simple app

├── pages

│ ├── myapp_index_html.page

│ ├── myapp_tab_dash_html.page

│ ├── myapp_tab_events_html.page

│ ├── myapp_tab_tasks_html.page

│ ├── myapp_tabs_html.page

└── staticresources

├── myapp_app_js.resource

├── myapp_controllers_js.resource

├── myapp_services_js.resource

Approach 1 - App Structure

Page 16: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Live demos

Live illustration of Approach 1

Angular app in a Salesforce

Org.

Page 17: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Approach 1 Review - GOOD & BAD parts

GOOD

Good for prototyping at rapid pace.

Less Conflicts: In case, multiple developers

are working on different views of the same

page.

BAD

Performance could be slow, because HTML

templates are loading from VF pages.

Grouping of related files is based on filename,

no clear structure.

Too much scattered metadata, when multiple

SPAs exists in a single Org, i.e. 5 extra pages

and 3 static resources for a single VF page.

Page 18: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Approach 2 - MavensMate Resource Bundleshttp://mavensmate.com/

http://www.joe-ferraro.com/2012/12/mavensmate-resource-bundles/

Page 19: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Approach 2 - App Structure

Maven’s ResourceBundle offering exploded

directory structure for StaticResource

“tabs_app_mavens”

├── resource-bundles

│ └── tabs_app_mavens.resource

│ ├── css

│ ├── img

│ ├── js

│ │ ├── app.js

│ │ ├── controllers.js

│ │ └── services.js

│ └── templates

│ ├── tab-dash.html

│ ├── tab-events.html

│ ├── tab-tasks.html

│ └── tabs.html

Just 1 StaticResource

for partials, styles and scripts

├── pages

│ ├── tabs_app_mavens.page

└── staticresources

├── tabs_app_mavens.resource

Page 20: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Live demos

Live illustration of

Approach 2 Angular

app in a Salesforce

Org.

Page 21: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Approach 2 - GOOD & BAD parts

GOOD

Familiar structure for new web developers

to productively code Angular apps in

Salesforce.

Limited metadata per VF page and SPA.

BAD

File conflicts when multiple developers

working on different views of same VF page or

SPA.

Mavensmate save speeds are slow at times,

which might be a big turn down. Aside.IO wins

here by huge margin.

Page 22: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Approach 3 - Aside.IO zipped static resourceshttps://www.aside.io/

Page 23: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Quite similar to Mavens, but all browser based

tabs_app_aside.resource

├── css

├── js

│ ├── app.js

│ ├── controller.js

│ └── services.js

└── templates

├── tab-dash.html

├── tab-events.html

├── tab-tasks.html

└── tabs.html

Approach 3 - App Structure

Just 1 StaticResource

for partials, styles and scripts

├── pages

│ ├── tabs_app_aside.page

└── staticresources

├── tabs_app_aside.resource

Page 24: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Live demos

Live illustration of

Approach 3

Angular app in a

Salesforce Org.

Page 25: Dreamforce 2015 Session - Angular-ifying your visualforce pages

BAD

Not able to save any file in zip apart from js,

css, txt and html

File conflicts when multiple developers

working on different views of same VF page or

SPA.

Approach 3 - GOOD & BAD parts

GOOD

Blazing fast SAVE speeds (biggest

advantage).

Some what familiar structure for new web

developers to productively code Angular

apps in Salesforce.

Limited metadata per VF page and SPA.

Page 26: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Approach 4 - Welkin Suite (Windows Users Only)http://welkinsuite.com/

Page 27: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Approach 4 - App Structure

Similar to MavensMate, could be nice option for VisualStudio lovers

Page 28: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Questions ? Happy to answer any related queries later via twitter @abhinavguptas

Page 29: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Session Code Sampleshttps://github.com/abhinavguptas/Dreamforce-2015-Session-Angular-ifying-your-

Visualforce-pages

Raja Rao’s Salesforce Bloghttps://developer.salesforce.com/blogs/developer-relations/2014/04/building-

beautiful-mobile-apps-in-visualforce-using-angularjs-and-ionic-part-1.html

Google Angular Style Guide http://google.github.io/styleguide/angularjs-google-style.html

MavensMate IDE http://mavensmate.com/

Using MavensMate

Resource Bundlehttp://www.joe-ferraro.com/2012/12/mavensmate-resource-bundles/

ASIDE IDE https://www.aside.io/

Welkin Suite IDE http://welkinsuite.com/

Resources

Source: placeholder

Page 30: Dreamforce 2015 Session - Angular-ifying your visualforce pages

Thank you