-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestTemplate.hbs
70 lines (63 loc) · 1.93 KB
/
testTemplate.hbs
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
<section class='testPage'>
<section class='adminSection adminSection--buttons'>
<div class='classes__buttons'>
<form action='{{deleteLink}}' method='post' class='deleteForm'>
<input type='submit' class='btn btn--full btn--primary btn--lg' value='Delete'/>
</form>
</div>
</section>
<div class='adminSection'>
<div class='adminItem'>
<div class='adminItem__title'>
<h2>Test Template - {{ name }}</h2>
{{> button style='full' colour='primary' content='Edit' size='lg' addClasses='editButton'}}
</div>
<div>
<div>
Maximum mark: <span class='hl'>{{maxMark}}</span>
</div>
</div>
<div class='formContainer'>
<form class='editForm' method='post' action='{{editLink}}' style='display: none' >
<label>
Maximum Mark
<input type='number' name='maxMark' id='maxMark' min=0 max=4294967295 value='{{maxMark}}' placeholder='Max mark' required/>
</label>
<label>
Template name
<input type='text' name='name' id='name' value='{{name}}' placeholder='Template name' required/>
</label>
<input type='submit' value='Submit' class='btn btn--primary btn--full'/>
</form>
</div>
</div>
</div>
<div class='adminSection'>
<div class='adminItem'>
<h2>Tests based on this template</h2>
<div class='adminTable'>
{{> testTable tests=basedTests full=true }}
</div>
</div>
</div>
</section>
<script>
document.querySelector('.editButton').addEventListener(touchEvent, (e) => {
e.preventDefault();
const form = document.querySelector('.editForm');
const path = e.path || (e.composedPath && e.composedPath());
const link = path[0];
link.innerText =
(form.style.display === 'none')
? 'Hide edit'
: 'Edit';
form.style.display =
(form.style.display === 'none')
? 'grid'
: 'none';
});
document.querySelector('.deleteForm').addEventListener('submit', (e) => {
if (!confirm('Delete test template?'))
e.preventDefault();
});
</script>