Skip to content

Commit 56653db

Browse files
Image Icon Menu Item Widget (#2286)
* README.md * pdfletter.js * Delete Server-Side Components/Business Rules/PdfletterGeneration directory * README.md * removeuser.js * Delete Specialized Areas/Fix scripts/Delete User Groups directory * README.md * Server.js * Update README.md * client.js * Update Server.js * Update Server.js * iconmenu.html * iconmenu.css * iconWidgetinstance.js * Add files via upload * Add files via upload
1 parent f1e32cd commit 56653db

File tree

9 files changed

+180
-0
lines changed

9 files changed

+180
-0
lines changed
9.08 KB
Loading
60.2 KB
Loading
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# contribution
2+
3+
Developed a custom Service Portal widget named "Image Icon Menu" to display Quick Links.
4+
This widget features icon-based navigation for key actions such as "Rewards & Recognition" and "Knowledge Article Creation".
5+
6+
7+
Function:
8+
-----------
9+
10+
The widget displays a customizable image-based icon menu with links to various resources like "Rewards & Recognition" or "Knowledge Article Creation." Menu items are dynamically populated based on configuration.
11+
12+
Widget Structure:
13+
--------------------
14+
15+
The widget is composed of the following components:
16+
17+
HTML template for structure - Dynamically renders up to 2 menu items, each showing: An image (img), A title (span), A hyperlink which Opens the target link.
18+
19+
CSS for styling - Applies flexbox to align icons and titles, Uses brand color (#01b8f2) and bold font for titles.
20+
21+
Client-side script for interactive behavior
22+
23+
Server-side script for backend data handling.Populates data object with:
24+
25+
Header image and title.
26+
27+
Titles, images, URLs, and targets for up to 2 menu items, based on widget options.
28+
29+
30+
31+
32+
33+
34+
35+
36+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//Serverside code for Menu Item -
2+
3+
4+
5+
(function() {
6+
7+
8+
var userID = gs.getUserID(); //Logged in user
9+
var gr = new GlideRecord('sn_hr_core_profile');
10+
gr.addQuery('user', userID);
11+
gr.query();
12+
13+
if (gr.next()) {
14+
data.saltype = gr.getValue('employee_class').toString();
15+
console.log(data.saltype);
16+
}
17+
18+
// Widget Header Stuff
19+
20+
data.imgImage = options.header_image;
21+
data.imgTitle = options.header_title;
22+
23+
// Menu Item 1
24+
25+
data.item_1_TITLE = options.item_1_title;
26+
data.item_1_IMG = options.item_1_img;
27+
data.item_1_URL = options.item_1_url;
28+
data.item_1_TARGET = options.item_1_target;
29+
30+
31+
// Menu Item 2
32+
33+
data.item_2_TITLE = options.item_2_title;
34+
data.item_2_IMG = options.item_2_img;
35+
data.item_2_URL = options.item_2_url;
36+
data.item_2_TARGET = options.item_2_target;
37+
38+
39+
40+
})();
41+
42+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
api.controller=function() {
2+
/* widget controller */
3+
var c = this;
4+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
      "header_image": {
3+
            "value": "image_icon.png",
4+
            "displayValue": "image_icon.png"
5+
      },
6+
      "header_title": {
7+
            "value": "Quick Links",
8+
            "displayValue": "Quick Links"
9+
      },
10+
     
11+
     
12+
      "item_1_title": {
13+
            "value": "Request Knowledge Articles",
14+
            "displayValue": "Request Knowledge Articles"
15+
      },
16+
      "item_1_img": {
17+
            "value": "request_ka_icon.png",
18+
            "displayValue": "request_ka_icon.png"
19+
      },
20+
      "item_1_url": {
21+
            "value": "?id=sc_cat_item&sys_id=657498bf1b00c5d0fd4899f4bd4bcb1e",
22+
            "displayValue": "?id=sc_cat_item&sys_id=657498bf1b00c5d0fd4899f4bd4bcb1e"
23+
      },
24+
     
25+
      
26+
      "item_1_target": {
27+
            "value": "_blank",
28+
            "displayValue": "_blank"
29+
      },
30+
      "item_2_target": {
31+
            "value": "_blank",
32+
            "displayValue": "_blank"
33+
      },
34+
     
35+
    
36+
37+
"item_2_title": {
38+
            "value": "Rewards & Recognitions",
39+
            "displayValue": "Rewards & Recognitions"
40+
      },
41+
      "item_2_img": {
42+
            "value": "achv_icon.png",
43+
            "displayValue": "achv_icon.png"
44+
      },
45+
      "item_2_url": {
46+
            "value": "https://xyz.achievers.com/recent_activity",
47+
            "displayValue": "https://xyz.achievers.com/recent_activity"
48+
49+
},
50+
51+
52+
53+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.header-image, .image-icon-item {
2+
width: 56px;
3+
height: 56px;
4+
object-fit: contain;
5+
margin-right: 1rem;
6+
}
7+
8+
.header-title {
9+
font-size: 20px;
10+
}
11+
12+
a.list-group-item {
13+
display: flex;
14+
align-items: center;
15+
}
16+
17+
.image-icon-title {
18+
color: #01b8f2;
19+
font-weight: bold;
20+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<div class="panel b panel-default">
2+
<div class="panel-heading">
3+
<h4 style="margin-top: 0; margin-bottom: 0;">
4+
<span ng-if="::data.imgTitle">
5+
<img ng-src="{{data.imgImage}}" class="header-image" />
6+
</span>
7+
<span class="header-title">{{data.imgTitle || "Image Icon Menu"}}</span>
8+
</h4>
9+
</div>
10+
<div class="list-group">
11+
<a class="list-group-item no-border" href="{{data.item_1_URL}}" target="{{data.item_1_TARGET}}">
12+
<img ng-src="{{data.item_1_IMG}}" class="image-icon-item" />
13+
<span class="image-icon-title">{{data.item_1_TITLE}}</span>
14+
</a>
15+
16+
17+
<a class="list-group-item no-border" href="{{data.item_2_URL}}" target="{{data.item_2_TARGET}}">
18+
<img ng-src="{{data.item_2_IMG}}" class="image-icon-item" />
19+
<span class="image-icon-title">{{data.item_2_TITLE}}</span>
20+
</a>
21+
22+
23+
</div>
24+
</div>
25+
22.6 KB
Loading

0 commit comments

Comments
 (0)