-
Notifications
You must be signed in to change notification settings - Fork 0
/
taskDialog.html
308 lines (269 loc) · 10.5 KB
/
taskDialog.html
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
html {
line-height: 1.5;
font-family: Verdana;
}
output {
font-size: 200%;
font-family: Helvetica Neue,Helvetica,Arial,sans-serif;
}
div {
vertical-align: text-top;
padding: 5px;
}
input.disabled {
color: #D3D3D3;
}
input.enabled {
color: #000000;
}
input:required {
color: red;
}
.form input:required,
textarea:required {
border-color: green !important;
}
.form input:required,
textarea:invalid {
border-color: red !important;
}
label.disabled {
color: #D3D3D3;
}
label.enabled {
color: #000000;
}
span.red {
color: red;
}
.box {
display: flex;
flex-wrap: wrap;
}
.box-inner {
display: flex;
flex-wrap: wrap;
align-content: space-between;
padding: 5px;
}
.button {
background-color: #2980B9;
border: none;
border-radius: 15px;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.control-panel{
margin: auto; text-align: center;
}
.dataInput {
background: #f1f2ee;
padding: 5px;
border-radius: 15px;
margin: 5px;
border-style: solid;
border-width: 2px;
border-color: #c3d5d8;
}
.flex-inner {
display: flex;
flex-wrap: wrap;
align-items: center;
padding: 5px;
}
.messageOutput {
background: #00FA9A;
padding: 5px;
border-radius: 15px;
margin: 5px;
border-style: solid;
border-width: 2px;
border-color: #c3d5d8;
margin: auto; text-align: center;
}
.push {
margin-left: 25px;;
}
.tiny-message {
margin-left: 300px;
font-size: small;
text-align: right;
}
</style>
</head>
<body>
<div class="box">
<div>
<form class="form" id="itemForm">
<div>
<div class="tiny-message"><span class="red">*</span> indicated required</div>
<label for="itemTitle">Item to be discussed<span class="red">*</span> : </label><br>
<textarea id="itemTitle" name="itemTitle" rows="2" cols="60" required></textarea>
</div>
<div>
<label for="itemPoints">Points discussed<span class="red">*</span> : </label><br>
<textarea id="itemPoints" name="itemPoints" rows="7" cols="60" required></textarea>
</div>
<div>
<label for="itemAction">Action : </label><br>
<textarea id="itemAction" name="itemAction" rows="3" cols="60"></textarea>
</div>
<div class="box-inner">
<div class="push"></div>
<div>
<label id="lblitemDate" for="itemDate">Date of completion:</label><br>
<input type="date" id="itemDate" name="itemDate" value="" min="2020-01-01" max="2050-12-31"><br>
<input type="checkbox" id="Done" name="Done" onclick="checkboxDate(this.name)">
<input type="hidden" id="DoneHidden" name="DoneHidden" value="" >
<label id="lblDone" for="Done">Done</label>
<input type="checkbox" id="ASAP" name="ASAP" onclick="checkboxDate(this.name)">
<input type="hidden" id="ASAPHidden" name="ASAPHidden" value="" >
<label id="lblASAP" for="ASAP">ASAP</label>
</div>
<div class="push"></div>
<div>
<div><label for="itemLeadStaff">Lead staff :</label></div>
</div>
<select name="itemLeadStaff" id="itemLeadStaff" size="7" multiple ><br>
</select>
<div class="tiny-message">(multiple selections allowed)</div>
</div>
<div id="submitButton"></div>
<div class="control-panel">
<!--<input class="button" onclick="resetForm()" type="reset" value="Reset" id="reset" /> -->
<input class="button" onclick="resetForm()" type="reset" value="Reset" id="reset" />
<!-- <input class="button" onclick="formSubmit()" type="button" value="Save Item" id="saveItem" /> -->
<input class="button" onclick="submitAndSaveItem()" type="button" value="Submit" id="submit" />
<input class="button" onclick="google.script.host.close()" type="button" value="Close" id="close" />
</div>
</form>
</div>
</div>
</body>
<!--------------------------------- Code ---------------------------------------------------------------------->
<script type="text/javascript">
//runs automatically on load
google.script.run.withSuccessHandler(updateFormValues).getAllProperties();
// ------------------------- Updating Form Values ---------------
function updateFormValues(properties) {
//document.getElementById('itemTitle').value = properties.itemTitle;
//document.getElementById('itemPoints').value = properties.itemPoints;
//document.getElementById('itemAction').value = properties.itemAction;
var selectLeadStaff = document.getElementById("itemLeadStaff");
//based on the 7 Executive Roles
for (i=1;i < 8; i++){
//populate roles dropdown boxes; had to create two option elements
var optRole = properties['settingRole'+i];
var elRole = document.createElement("option");
elRole.textContent = optRole;
elRole.value = optRole;
selectLeadStaff.appendChild(elRole);
}
/*
document.getElementById('itemDate').value = properties.itemDate;
if((properties.itemDate == 'ASAP' || properties.itemDate == 'Done')){
document.getElementById(properties.itemDate).checked = true;
checkboxDate(properties.itemDate);
} else {
document.getElementById('itemDate').value = properties.itemDate;
}
//check and select if there's more than one name
if(properties.itemLeadStaff.indexOf(',') == -1){
document.getElementById('itemLeadStaff').value = properties.itemLeadStaff;
} else {
document.getElementById('itemLeadStaff').value = properties.itemLeadStaff;
//cycle through list of names in #itemLeadStaff and select those that match
Array.from(document.querySelector("#itemLeadStaff").options).forEach(function(option_element) {
let option_value = option_element.value;
if(properties.itemLeadStaff.indexOf(option_element.value) !== -1){
option_element.setAttribute('selected', 'selected');
}
});
}
*/
}
// ------------------------ Submitting Form --------------------
//function formSubmit() {
function submitAndSaveItem(){
var form = document.forms[0];
//Validate form
if ((form.itemTitle.value == null || form.itemTitle.value == "") || (form.itemPoints.value == null || form.itemPoints.value == "")) {
alert("Please fill all required fields.");
return false;
} else {
google.script.run.submitAndSaveItem(form);
document.getElementById('submitButton').innerHTML = "<div class='messageOutput'>Item Submitted</div>";
google.script.run.withSuccessHandler(hideSaved).waitSeconds();
}
}
// ------------------------ Wait Messagebox ---------------------
function hideSaved() {
document.getElementById('submitButton').innerHTML = "";
}
// ------------------------ Reset Form --------------------------
function resetForm() {
//reset checkboxes using logic from checkboxDate() function
document.getElementById("Done").checked = false;
checkboxDate('Done');
//reset dropdown by unselecting all items that are selected
Array.from(document.querySelector("#itemLeadStaff").options).forEach(function(option_element) {
let option_value = option_element.value;
let is_option_selected = option_element.selected;
if(is_option_selected === true){ option_element.removeAttribute('selected'); }
});
document.getElementById('submitButton').innerHTML = "<div class='messageOutput'>Form Reset</div>";
google.script.run.withSuccessHandler(hideSaved).waitSeconds();
}
// ---------------------- Checkbox Logic for Date --------------
function checkboxDate(name) {
// Get the checkbox
var dateDone = document.getElementById(name);
var inputNames = ['Done','ASAP','itemDate'];
// If the checkbox is checked, toggle
if (dateDone.checked == true){
inputNames.forEach((element) => {
//grey out the other options for date if checked
if(element != name){
document.getElementById(element).disabled = true;
document.getElementById("lbl"+element).className = "disabled";
document.getElementById(element).className = "disabled";
if(element != "itemDate"){
document.getElementById(element + "Hidden").value = false;
}
}else{
if(element != "itemDate"){
document.getElementById(element +"Hidden").value = true;
}
}
});
} else {
//make the other options for date visible if not checked
inputNames.forEach((element) => {
if(element != name){
document.getElementById(element).disabled = false;
document.getElementById("lbl"+element).className = "enabled";
document.getElementById(element).className = "enabled";
if(element != "itemDate"){
document.getElementById(element + "Hidden").value = false;
}
} else {
if(element != "itemDate"){
document.getElementById(element +"Hidden").value = false;
}
}
});
}
}
</script>
</html>