Upgrading from PMACS Bootstrap to the new PMACS Frontend
Checklist
- Change Gem from
pmacs-bootstraptopmacs-frontend- Ensure that
pmacs-frontendis listed afterpmacs_app_resourcesin the Gemfile so that the error partials ofpmacs-frontendtake precedence.
- Ensure that
- Change
pmacs-bootstrapreferences topmacs-frontendin asset manifests:application.scssapplication.js
- Delete Old Layout Files
application.html.erbdevise.html.erberror.html.erb
- Precompile
on_readyassets- Even if you decide not to use this feature, you must create an empty
app/assets/javascripts/on_ready.jsfile - Optional: Transfer
$(document).readycode to aapp/assets/javascripts/on_readydirectory for end-of-DOM inclusion - Be wary that you'll still need to prefix some handlers with events, such as
$('turbolinks:load')
- Even if you decide not to use this feature, you must create an empty
- Use Hooks to set up things like the App Navigation, the Application Title, and the HTML <title> tag. The old Gem would let you set a lot of this directly in the layouts that you copied into each project. Hooks offer replacement configuration.
- Remove
pmacs-javascriptand address JS deprecation, if applicable - Upgrade individual Bootstrap 3 components and class-names to Bootstrap 4 equivalents. See migrating From Bootstrap 3 to 4
- Note that PMACS Bootstrap used Bootstrap 3 but cherry-picked some Bootstrap 4 components, such as cards.
- Upgrade from Poltergeist to Selenium for testing JS functionality. Refer to our Rails Skeleton for the latest compatible setup for CI.
- If you have any glyphicons hanging around from CUI 3, now is the time to ditch them. Jump in feet-first to the beautiful world of FontAwesome 5!
Once this is complete, you will need to click through all of your UIs and make sure everything looks good! It won't at first, but you can make it so!
Delete Old Layout Files
In PMACS Bootstrap, applications would wire up the page chrome by calling render 'bootstrap/layout' in the /app/views/layouts/application.html.erb file. Now, with PMACS Frontend, your application doesn't need an application layout file at all! The following layouts are included (and rendered) in Frontend, so delete them from your application:
application.html.erb- The first step to upgrading is to delete your
application.html.erblayout file altogether (as the gem supplies the layout). Your application simply uses the layout hooks as described above.
- The first step to upgrading is to delete your
devise.html.erb- PMACS Frontend now provides a default Devise layout, eliminating the need for every project to have a duplicate. If you have a
devise.htmlfile you should delete it.
- PMACS Frontend now provides a default Devise layout, eliminating the need for every project to have a duplicate. If you have a
error.html.erb- Additionally, if you specified an
errorfile to handle Devise errors, you should delete that as well.
- Additionally, if you specified an
See the Devise Views page for more information.
Check for usage of removed Javascript Gem
The Frontend is not bundled with pmacs-javascript and does not contain most of the custom JS that came packaged in PMACS Bootstrap. For a complete list of deprecated functionality, see the PMACS Javascript repository and PMACS Bootstrap assets.
The following list of functionality, while not exhaustive, is now excluded from the Frontend by default:
- Bootstrap Dialog Alert override: with
pmacs-javascript, elements withdata-confirmwould trigger a modal instead of a raw browser alert confirmation- If you are using
data-confirm, it is vital that you ensure that you are not manually includingpmacs-javascript, as this could silently break thedata-confirmfunctionality. Frontend offers a complete replacement for this with no changes to the API.
- If you are using
FileInputDecoration— automatically change a naked<input type='file'>into a bootstrap button. For file inputs that are part of longer forms, we recommend starting with Bootstrap 4's file input. If you want to roll that up into something custom, you can use Stimulus, like in this example of a file-upload form bundled into a button.SetActiveNav— highlight the active nav element on the sidebar. This is handled automatically by Frontend.- Hidden table headers—automatically hide empty tables if they had a
hide-headersclass. You can implement this in your project with a minimal Stimulus controller.
Upgrade From Poltergeist To Webdrivers/Selenium
Apps using Poltergeist may need to add a polyfill to allow for execution of ES6 (which Frontend uses) in tests. Better still, take this time upgrade away from the long-dead Poltergeist project and start using Selenium. Please refer to the Rails Skeleton for the current setup, which uses the webdrivers gem to manage Selenium and connect it to Capybara for tests.