Skip to content

Commit 714ef50

Browse files
authored
Sticky Notes Widget (#2502)
* Create READ Me.md * Update and rename READ Me.md to README.md * Add files via upload * Add files via upload * Update README.md * Create HTML.html * Create CSS-SCSS.css * Create Client Script.js * Create Server Side.js * Update HTML.html * Update Client Script.js * Update Server Side.js * Update README.md
1 parent d21c50d commit 714ef50

File tree

7 files changed

+133
-0
lines changed

7 files changed

+133
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.sticky-notes-widget {
2+
padding: 10px;
3+
}
4+
5+
.sticky-note {
6+
display: inline-block;
7+
width: 220px;
8+
min-height: 100px;
9+
margin: 8px;
10+
padding: 10px;
11+
border-radius: 6px;
12+
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
13+
vertical-align: top;
14+
font-size: 13px;
15+
white-space: pre-wrap;
16+
}
17+
18+
.note-toolbar {
19+
text-align: right;
20+
margin-bottom: 3px;
21+
}
22+
23+
.note-content {
24+
font-weight: 500;
25+
color: #333;
26+
}
27+
28+
.note-meta {
29+
margin-top: 6px;
30+
font-size: 11px;
31+
color: #666;
32+
}
33+
34+
.add-note-box {
35+
margin-top: 20px;
36+
}
37+
38+
.note-controls {
39+
display: flex;
40+
gap: 5px;
41+
margin-top: 5px;
42+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
api.controller=function($scope) {
2+
/* widget controller */
3+
var c = this;
4+
c.add =function(){
5+
c.data.action = "add";
6+
c.server.update().then(function(){
7+
c.data.action = undefined;
8+
c.data.newColor ="";
9+
c.data.text = "";
10+
})
11+
}
12+
c.remove =function(i){
13+
c.data.i =i;
14+
c.data.action = "remove";
15+
c.server.update().then(function(){
16+
c.data.action = undefined;
17+
})
18+
}
19+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<div class="container sticky-notes-widget">
2+
<h4><i class="fa fa-sticky-note"></i> My Sticky Notes</h4>
3+
<div class="sticky-note" ng-repeat="n in c.data.notes track by n.sys_id"
4+
ng-style="{'background-color': n.color}">
5+
<div class="note-toolbar">
6+
<button class="btn btn-xs btn-link text-danger" ng-click="c.remove(n.sys_id)">
7+
<i class="fa fa-trash"></i>
8+
</button>
9+
</div>
10+
<div class="note-content">{{n.text}}</div>
11+
<div class="note-meta">{{n.created_on | date:'short'}}</div>
12+
</div>
13+
<div class="add-note-box">
14+
<textarea ng-model="c.data.text" placeholder="Enter value..." class="form-control" />
15+
<br>
16+
<div class="note-controls">
17+
<select ng-model="c.data.newColor" class="form-control input-sm">
18+
<option value="#fff59d">Yellow</option>
19+
<option value="#b3e5fc">Blue</option>
20+
<option value="#c8e6c9">Green</option>
21+
<option value="#f8bbd0">Pink</option>
22+
</select>
23+
<button class="btn btn-primary" ng-click="c.add()"><i class="fa fa-floppy-o"></i> Add </button>
24+
</div>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Sticky Notes Widget
2+
3+
A Sticky Notes Widget allows users to create, view, delete and organize personal notes - just like physical sticky notes directly within Service Portal.
4+
5+
## Pre-requisite
6+
- Create new custom table Sticky Notes (u_sticky_notes)
7+
- Short Description - String (type)
8+
- Color - String (type)
9+
10+
## Demo table
11+
![A test image](table.png)
12+
13+
## Widget Output
14+
![A test image](demo.png)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(function() {
2+
if(input){
3+
if (input.action == "add") {
4+
if(!input.text){
5+
gs.addInfoMessage("Please enter value in text area");
6+
return;
7+
}
8+
var rec = new GlideRecord('u_sticky_notes');
9+
rec.initialize();
10+
rec.u_short_description = input.text;
11+
rec.u_color = input.newColor;
12+
rec.insert();
13+
}
14+
if (input.action == "remove") {
15+
var del = new GlideRecord('u_sticky_notes');
16+
if (del.get(input.i)) {
17+
del.deleteRecord();
18+
}
19+
}
20+
}
21+
22+
var gr = new GlideRecord('u_sticky_notes');
23+
gr.orderByDesc('sys_created_on');
24+
gr.query();
25+
data.notes = [];
26+
while(gr.next()){
27+
data.notes.push({
28+
sys_id: gr.getUniqueValue(),
29+
text: gr.getValue("u_short_description"),
30+
color: gr.getValue("u_color"),
31+
created_on: gr.getDisplayValue("sys_created_on")
32+
});
33+
}
34+
})();
27.8 KB
Loading
53 KB
Loading

0 commit comments

Comments
 (0)