forked from ckorpio/MongoRender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.html
52 lines (47 loc) · 1.97 KB
/
form.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
<html>
<head>
<title>Create Ticket</title>
</head>
<form action="/rest/ticket/"accept-charset="utf-8" id="ticket-form" method="POST">
id: <input type="text" name="id"><br>
created_at: <input type="text" name="created_at"><br>
updated_at: <input type="text" name="updated_at"><br>
type: <input type="text" name="type"><br>
subject: <input type="text" name="subject"><br>
description: <input type="text" name="description"><br>
priority: <input type="text" name="priority"><br>
status: <input type="text" name="status"><br>
recipient: <input type="text" name="recipient"><br>
submitter: <input type="text" name="submitter"><br>
assignee_id: <input type="text" name="assignee_id"><br>
follower_ids: <input type="text" name="follower_ids"><br>
<input type="submit" value="Submit">
</form>
<Script>
const form = document.querySelector('#ticket-form');
const path = window.location.pathname;
const id = path.split('/').slice(-1)[0];
if(id){
fetch(`/rest/ticket/%{id}`,{
method: 'PUT',
body: data
})
.then(response => response.json())
.then(data => {
form.querySelector('[name="id"]').value = data.id;
form.querySelector('[name="created_at"]').value = data.created_at;
form.querySelector('[name="updated_at"]').value = data.updated_at;
form.querySelector('[name="type"]').value = data.type;
form.querySelector('[name="subject"]').value = data.subject;
form.querySelector('[name="description"]').value = data.description;
form.querySelector('[name="priority"]').value = data.priority;
form.querySelector('[name="status"]').value = data.status;
form.querySelector('[name="recipient"]').value = data.recipient;
form.querySelector('[name="submitter"]').value = data.submitter;
form.querySelector('[name="assignee_id"]').value = data.assignee_id;
form.querySelector('[name="follower_ids"]').value = data.follower_ids;
})
.catch(error => console.error('Error recieving ticket:', error));
}
</Script>
</html>