blob: f371664f6ea5130753ee3284216e21293f7efb95 (
plain)
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
|
const baseFormFields = `<form id="tableForm" action="/api/update" method="post">
<div class="formRow">
<div class="formRow-label">service_id</div>
<div class="formRow-input"><input type="text" name="service_id" class="formInput" id="formServiceId" readonly="readonly"></div>
</div>
<div class="formRow">
<div class="formRow-label"> servtype </div>
<div class="formRow-input">
<input type="text" name="servtype" class="formInput">
</div>
</div>
<div class="formRow">
<div class="formRow-label"> subtype </div>
<div class="formRow-input">
<input type="text" name="subtype" class="formInput">
</div>
</div>
<div class="formRow">
<div class="formRow-label"> user_id </div>
<div class="formRow-input">
<input type="text" name="user_id" class="formInput">
</div>
</div>
<div class="formRow">
<div class="formRow-label"> referrer_user_id </div>
<div class="formRow-input">
<input type="text" name="referrer_user_id" class="formInput">
</div>
</div>
<div class="formRow">
<div class="formRow-label"> state </div>
<div class="formRow-input">
<select name="state">
<option>N</option>
<option>A</option>
<option>S</option>
<option>D</option>
<option>O</option>
</select>
</div>
</div>
<div class="formRow">
<div class="formRow-label"> creation_date </div>
<div class="formRow-input">
<input type="date" name="creation_date" class="formInput">
</div>
</div>
<div class="formRow">
<div class="formRow-label"> creation_time </div>
<div class="formRow-input">
<input type="time" name="creation_time" class="formInput">
</div>
</div>
<div class="formRow">
<div class="formRow-label"> creation_request_sent_date </div>
<div class="formRow-input" style="display: flex; flex-direction: row">
<input type="date" name="creation_request_sent_date" class="formInput" style="width: 50%;">
<input type="time" name="creation_request_sent_time" class="formInput" style="width: 50%;">
</div>
</div>
<div class="formRow">
<div class="formRow-label"> notified_about_expiration </div>
<div class="formRow-input">
<input type="text" name="notified_about_expiration" class="formInput">
</div>
</div>
</form>`;
const formCreateButtons = `<div class="formButtons">
<button type="button" onclick="hideForm()">Cancel</button>
<button type="submit">Create</button>
</div>`;
const formEditButtons = `<div class="formButtons">
<button type="button" onclick="hideForm()">Cancel</button>
<button type="submit">Update</button>
</div>`;
function showContentBox() {
let elem = document.getElementById('backgroundTint');
elem.classList.remove('hidden');
elem.classList.add('shown');
elem = document.getElementById('contentBox');
elem.classList.remove('hidden');
elem.classList.add('shown');
}
function hideContentBox() {
let elem = document.getElementById('backgroundTint');
elem.classList.remove('shown');
elem.classList.add('hidden');
elem = document.getElementById('contentBox');
elem.classList.remove('shown');
elem.classList.add('hidden');
}
function showForm() {
let newEntryBtn = document.getElementById('newEntryBtn');
newEntryBtn.style.display = 'none';
showContentBox();
let contentBox = document.getElementById('contentBox');
while (contentBox.firstChild)
contentBox.removeChild(contentBox.firstChild);
contentBox.appendChild(elementFromHTML(baseFormFields));
return contentBox;
}
function hideForm() {
let newEntryBtn = document.getElementById('newEntryBtn');
newEntryBtn.style.display = 'inline';
let contentBox = document.getElementById('contentBox');
while (contentBox.firstChild)
contentBox.removeChild(contentBox.firstChild);
hideContentBox();
}
function showEditForm() {
let contentBox = showForm();
contentBox.firstChild.appendChild(elementFromHTML(formEditButtons));
contentBox.firstChild.action = '/api/update';
}
function showCreateForm() {
let contentBox = showForm();
contentBox.firstChild.appendChild(elementFromHTML(formCreateButtons));
contentBox.firstChild.action = '/api/add';
document.getElementById('formServiceId').disabled = false;
}
|