Notification Bubble for Staff

notificaitons_v3_00.jpgOne of the worst things to hear was how someone tried to get connected at church and never heard back from the staff or volunteers. Oof! Rock goes a long way to helping with this, but we wanted to leverage what people are used to seeing every day (notification bubbles) to make sure items awaiting their attention were not overlooked, tucked away on a page they may not visit daily. Let's put these notifications into a format that people are used to seeing as "needing attention" and give them a red bubble with a notifications count in it. (Yes, I'm aware some monsters out there have 24,563 unread messages in their gmail app with an atrociously ignored notification bubble... you know who you are... this won't help you... call a therapist).

Prerequisite: Rock v18+

This is where light/dark modes and the new "RockNextGen" Theme came into play. If you are on a previous version of Rock, consider V2 of this recipe here: https://community.rockrms.com/recipes/413/notification-bubble-for-connection-requests-and-tasks-v2-up-to-rock-v17

Let's Build!

1) We're going to start by adding a new block to the Header Zone, that is visible across the entire Site. On the left, choose "Admin Tools" and "Settings" to enter the Settings area. From there, choose "CMS" and "Pages". Choose "Internal Homepage" and then change the zone to "Header" in the dropdown box.

notificaitons_v3_01.jpg
notificaitons_v3_02.jpg
notificaitons_v3_03.jpg

2) Click the "Add Block to Zone" button and enter "Action Required Notifications" as the name. Type should be HTML Content, and then choose "Site (Rock RMS)" as the "Add To" option to ensure this shows across the entire internal Rock site and not only this page. Click "Save" when done.

notificaitons_v3_04.jpg
notificaitons_v3_05.jpg

3) Optionally drag the three lines on the left of that item to the top of the stack if you want the icon to be the far right (closest to the user's name at the top right). If you want it on the left (closest to the search box), you can skip this.

notificaitons_v3_06.jpg

4) Now click the edit HTML button and copy and paste the following code (this box scrolls down) into the code editor view of this block (you should see line numbers on the left, if you don't press the code editor button to the left of the "Bold" text button) and press Save.

notificaitons_v3_07.jpg
notificaitons_v3_08.jpg

5) Next we need to allow some security permissions for this block to run the SQL and Entity Commands and assign it a CSS Class so it will format and appear properly for mobile devices. Click on the "Block Properties" icon, enable "Rock Entity" and "SQL" lava commands in the first tab, then click on the "Advanced Settings" tab and give it a CSS class of "notifications-bubble" and press Save.

notificaitons_v3_09.jpg
notificaitons_v3_10.jpg
notificaitons_v3_11.jpg

End Result

If all has gone as expected, you should now see NOTHING! Well... unless you have any Tasks or Connection Requests assigned to you. If you do, then you'll see something like the photos below (desktop and mobile menu). If you click it, you'll be taken to your "My Connections" page where you should see a matching number of items awaiting your attention.

Desktop View (shown in both light and dark modes):

notificaitons_v3_12.jpg
notificaitons_v3_13.jpg

Mobile View:

notificaitons_v3_14.jpg

NOTE:

By default, this notification will always appear in the top bar, even on narrow screens (mobile devices). While we prefer this to make sure staff see it without opening the menu, I understand you may not. If you want to NOT have that on the top bar on mobile devices and you want it to only show when the menu is opened (similar to the other two round icons), you can edit the HTML of the block and replace:

with:

notificaitons_v3_15.jpg

V1 - Thanks to Courtney Cooksey and David Axelson for help with some of the original code!

V2 - This code has bene completely re-written to:
- use more efficient SQL (one call instad of two)
- use the users's local timezone when determining which tasks are due (defaults to EST if not specified, so feel free to adjust line 26 as needed if you aren't EST)
- add a tooltip on the notification now that shows a breakdown of "Connections: # and Tasks: #" with a dynamic width

V3 - Rebuilt for V18+ with style and format adapted to NextGen theming:
- converted from fontawesome to tabler icon
- added light/dark modes support
- removed "ul" and "li" elements for displaying the badge
- give options on where to display the badge on mobile devices (narrow screens)