Oracle JET Custom Component for displaying Notifications
-Me. Again.
Yes, pizzas are tasty and they are one of the few things that can't be waited for. Our monthly salary too, just can't wait for a month to have it :). Be it pizza or salary, we are notified when they arrive. Such notifications can never be missed. And yes, notifications should never be missed, as they have something special, not all the time though, like pizzas and salary... again.
Web applications are a platform, for executing things from Salary payment till connecting with friends and many more. Be it developers or users of the web application, we are a team, always. Within a team, notifications play a important role. May be a thought for outing, or cinema, everyone in a team, friendly enough, should be present. This presence is only possible, when one gets notified, thus Notifications. Let's see how we actually implement a notification feature using Oracle JET framework.
Notifications happen between two parties, one publishes and the other subscribes. To mimic this, we have a custom component here, which is a subscriber, and a Parent HTML, index.html, which publishes notifications.
Rather than going through each line in the code, lets jump into the core.
The View Model: main.js
The View: index.html
The HTML of the custom component
The generated notification list is fed into the custom component, as the attribute "notftcn-obj" value. Other attributes are meant to trigger methods to delete a single or all notifications
Running the Application
Right top corner we see the Custom Component rendered. Buttons are from the index.html page
Clicking on the buttons, and the clicking on the bell icon, the list is presented in an <oj-list-view>
And when we have all in place, and finally serve the application, we can see three buttons. They are the source of notifications. In real world apps we may have many other things generating notifications, but here we see buttons mimicked as notification generators. As buttons get clicked, we can see the notification count gets updated, and even the bell gets animated. When clicked on the bell, we see the notifications listed , and user can go ahead deleting a single or all notifications.
Above methods do simple things. They just dispatch custom events, and these dispatched events are caught and addressed at the index.html page.
Thus, we also saw how Signals and Custom Events help establish two way communication, between the Parent, index.html, and the child, the custom component
Next step, is just we get the application downloaded or checked out. Below is the repo link. Please build the application accordingly, as node_modules and web are not part of the folder.
https://github.com/pandurangsp/S_JET_Notification_Component
More details here
https://github.com/pandurangsp/S_JET_Notification_Component/blob/main/README.md
Comments and suggestions are whole heartedly welcome :)
How to do it in vbcs
ReplyDelete