-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
118 lines (87 loc) · 4.05 KB
/
Copy pathindex.html
File metadata and controls
118 lines (87 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html>
<head>
<!-- This script loads the Appian Web components; change it to your Appian server's domain -->
<script src="https://cs-sandbox1.appiancloud.com/suite/tempo/ui/sail-client/embeddedBootstrap.nocache.js" id="appianEmbedded"></script>
<link rel="stylesheet" href="citi.css">
<script>
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const recordId = urlParams.get("recordId");
const recordStub = urlParams.get("recordStub");
</script>
</head>
<body>
<!-- This custom HTML element specifies an Appian report to embed on the HTML page -->
<div id="embeddedDiv"></div>
<script>
var embeddedRecordTag= 'embeddedRecord';
var embeddedMainViewTag= 'embeddedMainView';
var container = document.getElementById('embeddedDiv');
function recordLinkOpened(event) {
// Prevent the Appian default behavior of opening a new tab
event.preventDefault();
console.log('An Appian record link was clicked: ' + stringifyEvent(event));
//Create a debug tag
var debugStartTag = document.createTextNode("Debug Start");
var debugEndTag = document.createTextNode("Debug End");
// Create the appian-record embedded tag
var recordTag = document.createElement('appian-record-view');
recordTag.setAttribute('id', embeddedRecordTag);
recordTag.setAttribute('recordTypeUrlStub', event.detail.recordTypeUrlStub);
recordTag.setAttribute('recordViewUrlStub', event.detail.recordViewUrlStub);
recordTag.setAttribute('recordIdentifier', event.detail.recordIdentifier);
// Remove the appian-report tag and add the task tag in its place
var reportTag = document.getElementById(embeddedMainViewTag);
if (reportTag) {
reportTag.destroy();
container.removeChild(reportTag);
}
container.appendChild(debugStartTag);
container.appendChild(recordTag);
container.appendChild(debugEndTag);
console.log('Finished processing Record Link event');
}
function startProcessLinkOpened(event) {
// Prevent the Appian default behavior of opening a new tab
event.preventDefault();
console.log('An Appian Start Process link was clicked: ' + stringifyEvent(event));
}
function addMainViewReport() {
// Build the appian-report tag for the task report
var mainViewReportTag = document.createElement('appian-report');
mainViewReportTag.setAttribute('id', embeddedMainViewTag);
// Replace this URL stub with your report's URL Stub
mainViewReportTag.setAttribute('reportUrlStub', 'sdJaow');
// Listen for clicks on record links
mainViewReportTag.addEventListener("open-record-link", recordLinkOpened, false);
mainViewReportTag.addEventListener("open-startprocess-link", startProcessLinkOpened, false);
// Add the tag to the dom for display
container.appendChild(mainViewReportTag);
}
function stringifyEvent(e) {
const obj = {};
for (let k in e) {
obj[k] = e[k];
}
return JSON.stringify(obj, (k, v) => {
if (v instanceof Node) return 'Node';
if (v instanceof Window) return 'Window';
return v;
}, ' ');
}
if (recordId == null || recordId === null)
{
addMainViewReport();
}
</script>
<script>
//document.write("<H2>---" + recordId + "----</H2>");
if ( !(recordId == null || recordId === null || recordStub == null || recordStub === null))
{
document.write("<H1>Record ID: " + recordId + "</H1>");
document.write("<appian-record-view recordTypeUrlStub=\"" + recordStub + "\" recordIdentifier=\"" + recordId + "\" recordViewUrlStub=\"summary\"></appian-record-view>");
}
</script>
</body>
</html>