In BlogPost, Fair Job Offer Project, Javascript

An AngularJS Bootstrap Tabs Example

Since the whole point of the Fair Offer Project was to allow me to compare job offers in an “apples-to-apples” way, I envisioned a user being able to “tab” through different offers.

angular-factories-services-providers

This meant when a user logged in, they should see tabs representing different offers. I wasn’t sure how to do this at first, but this post represents the step-by-step approach I took.

Step 1 – Find the plugins

I started searching Google for a plugin to cobble this together. I came across this post by K. Allen.

The post suggested using UI Bootstrap, a library specifically written to work with the Twitter Bootstrap CSS framework.

This was perfect as that’s exactly what I was using on the frontend. Thank you, Internet!

Step 2 – Install UI Bootstrap

In bower.json, I had to add these lines of code to add angular-bootstrap:

Next, I had to require the ui-bootstrap and the associated dependency ui-bootstrap-tpls.

To do this, in src/app/app.js, I had to add the following lines of code:

In the module.exports configuration, I had to add ui.bootstrap. You might even notice this is in such an “MVP” (minimum viable product) format that I didn’t bother to erase the commented lines of code.

Step 3 – Brainstorming the user interface features I wanted

The third step I took was to brainstorm the features I needed in the user interface.

I wanted:

  • Auto-summation: When a user adds a new dollar value (e.g., a one-time bonus), it should be added automatically into the total compensation package amount.
  • Tabbed workspaces: A user should be able to add a “new job offer” by clicking an “add new offer” type tab. This could be represented by a “+” symbol.
  • A user an create different compensation factors: The user can add a row containing a value and the type of compensation it is (401K matching, yearly bonus, etc.)
  • A user can choose between ongoing or one-time compensation features: Sometimes compensation might be a one-time event (e.g., sign-on bonus) or a recurring event (e.g., guaranteed vacation). The user should be able to identify what it is via select dropdown.

Step 4 – Add the UI markup to the view

The fourth step was to add all the necessary Angular markup to the HTML view. Take note of the uib-tabset and uib-tab directives provided by the UI Bootstrap library.

The markup code below is the latest version I released as of Tuesday, 1/17/2017.

Step 5 – Add the controller code

The controller code I’m showing below is an edited example to show the setup to make it work for saving the job offer information locally. You might notice that the saveBackend() function in the UI markup from Step 4 is not defined.

This is because we’re not at the point yet where we have a database backend to save the information too. To illustrate the concepts, I’ve chosen to show only a local storage implementation.

Summary

This was the 5 step approach I followed to create a tabbed workspace implementation to help compare job offers fairly.

Recent Posts