-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.html
More file actions
213 lines (201 loc) · 7.67 KB
/
index.html
File metadata and controls
213 lines (201 loc) · 7.67 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form Renderer with AngularJS</title>
<style>
textarea {
width: 100%;
height: 100px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://form-builder.aidbox.app/static/aidbox-forms-renderer-webcomponent.js"></script>
</head>
<body ng-app="formRendererApp" ng-controller="FormRendererController">
<div class="flex flex-col h-screen w-full">
<header
class="sticky top-0 z-20 flex flex-shrink-0 h-16 w-full items-center justify-between bg-white px-4 shadow-sm md:px-6">
<nav class="flex items-center gap-6">
<button class="md:hidden text-2xl h-8 w-8 grid place-items-center leading-none rounded-full"
ng-click="toggleSidebar()"
ng-class="{'bg-gray-200': sidebarOpen}">
<div class="-mt-1.5">
☰
</div>
</button>
<a href="#" class="flex items-center gap-2 text-lg font-semibold md:text-base">
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="h-6 w-6"
>
<path d="M12 6v4"></path>
<path d="M14 14h-4"></path>
<path d="M14 18h-4"></path>
<path d="M14 8h-4"></path>
<path d="M18 12h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2"></path>
<path d="M18 22V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v18"></path>
</svg>
<span class="sr-only">Medical Care System</span>
</a>
<div class="hidden gap-6 text-sm font-medium md:flex">
<a class="font-bold" href="#">
Questionnaires
</a>
<a class="text-gray-500" href="#">
Clients
</a>
<a class="text-gray-500" href="#">
Questionnaire Responses
</a>
</div>
</nav>
<div class="flex items-center gap-2">
<button
class="inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground h-10 w-10 rounded-full">
<img
src="https://generated.vusercontent.net/placeholder.svg"
width="32"
height="32"
class="rounded-full"
alt="Avatar"
style="aspect-ratio: 32 / 32; object-fit: cover;"
/>
<span class="sr-only">Toggle user menu</span>
</button>
</div>
</header>
<div class="flex flex-1 relative">
<div class="flex flex-col bg-gray-100 p-4 w-[260px] z-10 max-w-full transition-all duration-100 top-0 bottom-0 absolute md:relative -left-full md:left-0"
ng-class="{'left-0 shadow-lg': sidebarOpen}">
<div class="mb-4 flex items-center justify-between">
<h3 class="text-lg font-semibold">Questionnaires</h3>
</div>
<div class="overflow-auto mb-4">
<nav class="grid gap-2">
<button
ng-repeat="questionnaire in questionnaires"
class="rounded-md bg-white p-2 text-sm font-medium transition-colors hover:bg-gray-200 text-left pr-4 relative"
ng-on-click="selectQuestionnaire(questionnaire.id)"
>
{{ questionnaire.title }}
<span
ng-if="questionnaire.id === id"
class="bg-red-500 outline outline-2 outline-red-200 w-2 h-2 rounded-full absolute right-3 top-1/2 -translate-y-1/2"
>
<span class="sr-only">Currently viewing</span>
</span>
</button>
</nav>
</div>
<button
class="mt-auto border rounded text-sm text-orange-600 hover:text-orange-500 hover:border-orange-500 active:bg-orange-600 active:text-white border-orange-600 p-2 pr-4"
ng-on-click="changeTheme()"
>
Apply custom theme
</button>
</div>
<main class="flex-1 grid grid-cols-2 gap-4 p-4" ng-class="{'brightness-50': sidebarOpen}">
<aidbox-form-renderer
id="renderer-1"
base-url="https://form-builder.aidbox.app"
style="width: 100%; border: none; align-self: stretch; display: flex"
questionnaire-id="{{ id }}"
config='{{ config }}'>
</aidbox-form-renderer>
<aidbox-form-renderer
id="renderer-2"
base-url="https://form-builder.aidbox.app"
style="width: 100%; border: none; align-self: stretch; display: flex"
questionnaire-id="{{ id }}"
config='{{ config }}'
>
</aidbox-form-renderer>
</main>
</div>
</div>
<script>
angular.module('formRendererApp', [])
.controller('FormRendererController', ['$scope', '$timeout', function ($scope, $timeout) {
$scope.questionnaires = [
{
"title": "Harris Hip Score panel",
"id": "100283-1"
},
{
"title": "Meat allergen panel",
"id": "100751-7"
},
{
"title": "Schmid fall risk",
"id": "101549-4"
},
];
$scope.id = $scope.questionnaires[0].id;
$scope.config = '';
$scope.sidebarOpen = false;
$scope.selectQuestionnaire = function (id) {
$scope.id = id;
$scope.sidebarOpen = false;
setOnFetchHandler(); // update handler after ID change
};
$scope.toggleSidebar = function () {
$scope.sidebarOpen = !$scope.sidebarOpen;
};
const theme = {
"base-font-size": "12px", // Base font size for the theme
background: {
"toolbar-color": "#2c3e50", // Background color of the toolbar
},
button: {
"accent-color": "#27ae60", // General accent color for buttons
},
};
$scope.changeTheme = function() {
$scope.config = JSON.stringify({ theme });
const [element] = document.querySelector('#renderer-1');
const parent = element.parentNode;
parent.removeChild(element);
setTimeout(() => {
parent.appendChild(element);
setOnFetchHandler(); // re-attach handler after remount
}, 0);
};
function setOnFetchHandler() {
$timeout(() => {
const renderer1 = document.querySelector('#renderer-1');
const renderer2 = document.querySelector('#renderer-2');
if (renderer1) {
renderer1.onFetch = async function(url, init) {
if (init.tag === "submit-response") {
alert('Renderer 1 intercepted a submit-response');
}
return null;
};
}
if (renderer2) {
renderer2.onFetch = async function(url, init) {
if (init.tag === "submit-response") {
alert('Renderer 2 intercepted a submit-response');
}
return null;
};
}
});
}
// Initial binding after DOM load
$timeout(setOnFetchHandler, 0);
}]);
</script>
</body>
</html>