{"id":11897,"date":"2022-08-16T09:42:41","date_gmt":"2022-08-16T14:42:41","guid":{"rendered":"https:\/\/www.mrc-productivity.com\/docs\/?post_type=ht_kb&#038;p=11897"},"modified":"2023-11-28T12:29:20","modified_gmt":"2023-11-28T18:29:20","slug":"notification-badges","status":"publish","type":"ht_kb","link":"https:\/\/www.mrc-productivity.com\/docs\/knowledge-base\/notification-badges","title":{"rendered":"Notification Badges"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"overview\">Overview<\/h2>\n\n\n\n<p>A common UI component found in all types of software is some type of notifications badge that displays to user a number, indicative of the number of items that require their attention. A few examples include mobile applications, banking system, or customer portals, where one is frequently alerted to any outstanding messages or actions that are awaiting attention or action. <\/p>\n\n\n\n<p>This documentation will cover creating a similar type of functionality in m-Power. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"implementation\">Implementation<\/h2>\n\n\n\n<p>The image below (Figure 1) contains a Multiple Row Data List retrieval that displays an end-user&#8217;s orders. The end goal will be to display a notification badge above the table output to notify the user how many un-read notifications they have. The notifications will pull from a different database table, which is also built over a retrieval template (Figure 2). <\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><a href=\"\/docs\/images\/notificationbadge1.jpg\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"\/docs\/images\/notificationbadge1.jpg\" alt=\"\"\/><\/a><figcaption class=\"wp-element-caption\"><strong><mark style=\"background-color:#fff\" class=\"has-inline-color has-theme-default-color\">Orders Retrieval<\/mark><\/strong><\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"\/docs\/images\/notificationbadge2.jpg\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"\/docs\/images\/notificationbadge2.jpg\" alt=\"\"\/><\/a><figcaption class=\"wp-element-caption\"><mark style=\"background-color:#fff\" class=\"has-inline-color\"><strong>Notifications Retrieval<\/strong><\/mark><\/figcaption><\/figure>\n<\/figure>\n\n\n\n<p>In the Orders Retrieval, the m-Painter editor will be utilized to insert the notification badge. Place the cursor at the desired badge location and type the desired text.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"\/docs\/vue-images\/badgeText.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"\/docs\/vue-images\/badgeText.jpg\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p>Highlight the text and from the right-side Element Panel, select &#8220;Insert Smartlink&#8221;. Choose the &#8220;Notification Badge&#8221; link type. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"\/docs\/vue-images\/badgeLink.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"\/docs\/vue-images\/badgeLink.jpg\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"\/docs\/vue-images\/badgeLinkType.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"\/docs\/vue-images\/badgeLinkType.jpg\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p>Next, select the application that contains the records you wish to serve as the notification count. Once the application has been selected, you have the option of mapping fields from the parent app to the notification app or any other additional parameters to filter the results. <\/p>\n\n\n\n<p>In my example, I only want to report the number of unread notifications. Therefore, I will pass the parameter val_READ_YN=N to the url.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"\/docs\/vue-images\/badgeURLParm.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"\/docs\/vue-images\/badgeURLParm.jpg\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p>Click &#8220;Next&#8221; to choose the Link Style and Target.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"\/docs\/vue-images\/badgeLinkStyle.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"\/docs\/vue-images\/badgeLinkStyle.jpg\" alt=\"\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">If looking to display the default notification badge, leave the Link Style set to the default &#8216;Link&#8217; option. If a button style notification is desired instead, select &#8216;Button&#8217;.<\/p>\n\n\n\n<p>By default, the number of notifications will always display as the first piece of text in the badge.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"\/docs\/vue-images\/badgeCompare.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"\/docs\/vue-images\/badgeCompare.jpg\" alt=\"\"\/><\/a><figcaption class=\"wp-element-caption\">m-Painter on the left, runtime on the right<\/figcaption><\/figure>\n\n\n\n<p>If you would like to change the location of the notification count, place your cursor in the badge at the desired location and type <code>{{number}}<\/code> in the badge directly. This logic will replace <code>{{number}}<\/code> with the number of returned notifications at runtime instead of the default behavior, which is to append the number to the beginning. Additionally, you may add icons if desired.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"\/docs\/vue-images\/badgeNumber.jpg\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"\/docs\/vue-images\/badgeNumber.jpg\" alt=\"\"\/><\/a><figcaption class=\"wp-element-caption\">m-Painter on the left, runtime on the right<\/figcaption><\/figure>\n\n\n\n<p>At runtime, an AJAX call is automatically made to the configured link URL to return only a row count. This is what provides the number of notifications. Clicking on the badge\/button will link out to the notifications retrieval. <\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">The link on the notification badge\/button can be made into a hover popup, popup dialog, or any other supported link type within the &#8220;Target&#8221; tab of the Insert\/Edit Link window. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"global-notifications\">Global Notifications<\/h2>\n\n\n\n<p>The above section will implement the notification badge into any one application of choice. However, for notifications that are global and not application-specific, it may be helpful to display this notification badge in the dictionary header, that way the notification is visible on every application page the user goes to within the data dictionary. <\/p>\n\n\n\n<p>To do this, copy the entire HTML code associated to the notification badge from the application it was inserted in. This code will be encompassed between two anchor (<code>&lt;a&gt;<\/code><code>&lt;\/a&gt;<\/code>) tags, as shown in the following example block:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;a class=\"mrc-notifications badge badge-warning\" href=\"UPD2022Q2.I00401s?slnk=1&amp;amp;READ_YN=N\">&lt;i class=\"fa fa-bell-o\">&lt;\/i>{{number}}&lt;\/a><\/code><\/pre>\n\n\n\n<p>Open the dictionary Header\/Footer HTML section from the Admin menu of the m-Power interface. To neatly display the notification badge in the header, wrap the code above within a <code>&lt;li class=\"nav-item\"&gt;&lt;\/li&gt;<\/code> tag, as shown here: <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"\/docs\/images\/notificationbadge7.jpg\" alt=\"\" width=\"668\" height=\"332\"\/><figcaption class=\"wp-element-caption\">Fig 7. The dictionary header file, mrc_servlet_head.html<\/figcaption><\/figure>\n\n\n\n<p>Code from Figure 7:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;li class=\"nav-item\">\n  &lt;a class=\"mrc-notifications badge badge-warning\"\n href=\"UPD2022Q2.I00401s?slnk=1&amp;amp;READ_YN=N\">&lt;i class=\"fa fa-bell-o\">&lt;\/i>{{number}}\n  &lt;\/a>\n&lt;\/li><\/code><\/pre>\n\n\n\n<p>At runtime, the notification badge will display next to the &#8220;Home&#8221; link.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"\/docs\/images\/notificationbadge8.jpg\" alt=\"\" width=\"668\" height=\"526\"\/><figcaption class=\"wp-element-caption\">Fig 8. The dictionary main menu at runtime<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"additional-notes\">Additional Notes<\/h2>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\">When inserting the notification badge, the default color of yellow is controlled by a CSS class <code>badge-warning<\/code>.  To change the color of the notification badge, this class can be changed to a different value. See <a href=\"https:\/\/getbootstrap.com\/docs\/4.0\/components\/badge\/#contextual-variations\" target=\"_blank\" rel=\"noreferrer noopener\">here <\/a>for more information.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Overview A common UI component found in all types of software is some type of notifications badge that displays to user a number, indicative of the number of items that require their attention. A few examples include mobile applications, banking system, or customer portals, where one is frequently alerted to&#8230;<\/p>\n","protected":false},"author":2,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[],"ht-kb-tag":[],"class_list":["post-11897","ht_kb","type-ht_kb","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/11897","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/comments?post=11897"}],"version-history":[{"count":30,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/11897\/revisions"}],"predecessor-version":[{"id":13530,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb\/11897\/revisions\/13530"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/media?parent=11897"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-category?post=11897"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/docs\/wp-json\/wp\/v2\/ht-kb-tag?post=11897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}