Belgium has a long tradition of beer making. According to Wikipedia, the country counts over 1700 beers of various styles, including Trappist, Abbey, Saisons, Lambic, Gueuze, Fruit Beers, White, Double, Triple, Quadruple, etc.
As I was experimenting with the new Lightning Components, I thought it would be fun to build an app that lets users search and explore this list in different ways: by name, style, brewery, alcohol content, etc. I learned a ton: not only building the application, but also using it!
Check out the end result in this video:
https://www.youtube.com/watch?v=ZL3F_uYm__s
In this post, I’ll show how the application works and how to install it in your own org.
Architecture Highlights
- The data is imported in two custom objects: breweries and beers.
- The client side of the explorer is built as a Lightning Application that assembles different Lightning Components: SearchBar, Paginator, BeerList, and BeerListItem.
- These components communicate using Lightning events.
- The data is provided by an “Aura enabled” Apex controller.
Installing the Application in Your Own Org
Step 1: Install the Application
- Sign up for a new free developer environment here.
- Enable Lightning Components in your new Developer Org: In Setup, click Develop | Lightning Components, check the Enable Lightning Components checkbox, and click Save.
- Click this link to install the application using an unmanaged package, then click Continue, Next, Next, Install.
Step 2: Import Data
You currently have to disable Lightning Components for the Data Import Wizard to work correctly when importing csv files. To disable Lightning Components: In Setup, click Develop | Lightning Components, uncheck the Enable Lightning Components checkbox, and click Save.
Import Breweries
- Save breweries.csv on your local file system
- In Salesforce’s Setup Mode, select Administer | Data Management| Data Import Wizard
- Click Launch Wizard
- Click the Custom objects tab, select Breweries
- Click Add New Records
- Drag breweries.csv to the upload area, and select Unicode (UTF8)
- Click Next
- Click Map for the Id column
- Map the CSV’s Id field to the Custom Object BreweryId field
- Click Next, and Start Import
Import Beers
- Save beers.csv on your local file system
- In Salesforce’s Setup, select Administer | Data Management | Data Import Wizard
- Click Launch Wizard
- Click the Custom objects tab, select Beers
- Click Add New Records
- For Which Brewery field in your file specifies the Master/Detail relationship?, select Extenal ID.
- Drag beers.csv to the upload area, and select Unicode (UTF8)
- Click Next
- Click Map for the brewery_id column
- Map the CSV’s brewery_id field to the Custom Object’s Brewery field
- Click Next
Step 3: Explore the Application
- Re-enable Lightning Components: In Setup, click Develop | Lightning Components, check the Enable Lightning Components checkbox, and click Save
- Open the Developer Console
- Click File | Open Lightning Resources in the menu, select Explorer | APPLICATION in the dialog, and click the Open Selected button
- Click Preview in the code editor (upper right corner) for the Explorer application
Source Code
The source code for the application is available in this GitHub repository.
Resources
If you’d like to get started building your own Lightning Apps and Components, take a look at the new Lightning Components module in Trailhead. You’ll earn a new badge, and be able to show off your Lightning skills.
Follow @ccoenraets on Twitter