forked from event-modeling/slice-company
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwork-entry.html
195 lines (190 loc) · 7.64 KB
/
work-entry.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Work Entry</title>
<style>
body {
background-color: #121212;
color: #E0E0E0;
}
.menu-item {
color: #BB86FC;
}
.tab, form {
background-color: #333333;
color: #E0E0E0;
}
.tab-btn {
background-color: #BB86FC;
color: #121212;
border: none;
}
form input, form select {
background-color: #333333;
color: #E0E0E0;
border: 1px solid #BB86FC;
}
body {
font-family: Arial, sans-serif;
}
form textarea {
background-color: #333333;
color: #E0E0E0;
border: 1px solid #BB86FC;
}
.menu-item {
display: inline-block;
margin-right: 10px;
font-weight: bold;
padding: 5px;
}
.menu-item.active {
text-decoration: underline;
}
.tab {
display: none;
padding: 20px;
border: 1px solid #ccc;
margin-top: 20px;
}
.tab.active {
display: block;
}
.tab-btn {
margin: 10px 5px;
padding: 5px 10px;
cursor: pointer;
}
form {
display: flex;
flex-direction: column;
width: 300px;
}
form label, form input, form select, form button {
margin-bottom: 10px;
}
form input, form select, form button {
padding: 5px;
}
</style>
</head>
<body>
<div>
<span class="menu-item active">Work Entry</span>|
<span class="menu-item">Invoicing</span>|
<span class="menu-item">Reports</span>|
<span class="menu-item">Logout</span>
</div>
<h1 style="display: inline;">Work Entry</h1>
<div>
<button id="enterSliceTab" class="tab-btn">Enter Slice</button>
<button id="enterHoursTab" class="tab-btn">Enter Hours</button>
</div>
<div id="enterSlice" class="tab active">
<h2>Enter the slice you completed:</h2>
<form action="add-work" method="POST">
<label for="type">Type:</label>
<select name="type" id="type">
<option value="stateView">State View</option>
<option value="stateChange">State Change</option>
</select>
<label for="client">Client:</label>
<!-- TODO: populate this with data from the back end -->
<select name="client" id="client">
<option value="uber">Uber</option>
<option value="fedex">FedEx</option>
<option value="spotify">Spotify</option>
</select>
<label for="projectInput">Project:</label>
<input type="hidden" name="submission-type" display="none" value="slice">
<input type="text" id="projectInput" name="projectInput">
<label for="notes">Notes:</label>
<textarea id="notes" name="notes" rows="5" cols="50"></textarea>
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<div style="display: flex; align-items: center;">
<label for="date" style="margin-right: 10px;">Date:</label>
<input type="date" class="date-input" name="date" id="dateInput" pattern="\d{4}-\d{2}-\d{2}" value="{{today}}" style="margin-right: 10px;">
<span id="dayOfWeek"></span>
</div>
<input type="submit" value="Save">
</form>
</div>
<div id="enterHours" class="tab">
<h2>Enter the hours you worked</h2>
<form action="add-work" method="post">
<label for="project">Project:</label>
<select name="project" id="project">
<option value="development">Development</option>
<option value="design">Design</option>
<option value="testing">Testing</option>
</select>
<label for="hours">Hours:</label>
<input type="hidden" name="submission-type" value="hours">
<input type="number" id="hours" name="hours" min="0.25" max="24" step="0.25">
<div style="display: flex; align-items: center;">
<label for="date" style="margin-right: 10px;">Date:</label>
<input type="date" class="date-input" name="date" id="dateInputHours" pattern="\d{4}-\d{2}-\d{2}" value="{{today}}" style="margin-right: 10px;">
<span id="dayOfWeekHours"></span>
</div>
<input type="submit" value="Save">
</form>
<!-- Content for Enter Hours will go here -->
</div>
<script>
document.getElementById("enterSliceTab").addEventListener("click", function() {
document.getElementById("enterSlice").classList.add("active");
document.getElementById("enterHours").classList.remove("active");
});
document.getElementById("enterHoursTab").addEventListener("click", function() {
document.getElementById("enterHours").classList.add("active");
document.getElementById("enterSlice").classList.remove("active");
});
// Added functionality for scrolling to adjust hours
document.getElementById("hours").addEventListener("wheel", function(event) {
event.preventDefault();
let currentHours = parseFloat(this.value) || 0;
if (event.shiftKey) {
// Increment in 0.25 hours if shift is held down
this.value = event.deltaY < 0 ? currentHours + 0.25 : currentHours - 0.25;
} else {
// Increment in 1 hour otherwise
this.value = event.deltaY < 0 ? currentHours + 1 : currentHours - 1;
}
});
// Added functionality for scrolling to adjust date
document.querySelectorAll(".date-input").forEach(function(input) {
input.addEventListener("wheel", function(event) {
event.preventDefault();
let currentDate = new Date(this.value);
currentDate.setDate(currentDate.getDate() + (event.deltaY < 0 ? 1 : -1));
this.value = currentDate.toISOString().split('T')[0];
updateDayOfWeek(this.id);
});
});
// Set default date to today for date inputs and display day of the week
const today = new Date().toISOString().split('T')[0];
document.querySelectorAll(".date-input").forEach(function(input) {
input.value = today;
updateDayOfWeek(input.id);
});
// Function to update the day of the week
function updateDayOfWeek(inputId) {
const input = document.getElementById(inputId);
const date = new Date(input.value);
const dayOfWeekSpan = inputId === "dateInput" ? document.getElementById("dayOfWeek") : document.getElementById("dayOfWeekHours");
const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
dayOfWeekSpan.textContent = days[date.getDay()];
}
// Event listeners for date inputs to update day of the week on change
document.getElementById("dateInput").addEventListener("change", function() {
updateDayOfWeek(this.id);
});
document.getElementById("dateInputHours").addEventListener("change", function() {
updateDayOfWeek(this.id);
});
</script>
</body>
</html>