Skip to content

Commit

Permalink
Done!
Browse files Browse the repository at this point in the history
  • Loading branch information
chia030 committed Jun 2, 2021
1 parent 0b500a2 commit 074486a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ public void setMissing(boolean update) {

@PostMapping("update-appointment-report")
@ResponseBody
public void updateResult(@RequestParam(required = false) Integer appointment_id, @RequestParam(required = false) String result) {
if (result == null || appointment_id == null) {
return;
}
public void updateResult(@RequestParam(required = false) Integer appointment_id, @RequestParam(required = false) String status) {
// if (result == null || appointment_id == null) {
// return;
// }

reportService.updateAppointment(Appointment.Result.valueOf(result), appointment_id);
reportService.updateAppointment(Appointment.Result.valueOf(status), appointment_id);

}

Expand Down
84 changes: 27 additions & 57 deletions src/main/resources/templates/logging/secretary-landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h1 class="title" style="margin-bottom: 0px; margin-top: 20px;">Secretary Dashbo
<option th:data="${center.getCenterID()}" th:value="${center.getCenterID()}" th:each="center:${centerList}" th:text="${center.getCenterID()} +' - '+ ${center.address}">
</option>
</select>
<input id="display-booked" type="checkbox" name="booked-only" value="BOOKED"> Display today's BOOKED appointments only<br>
<input id="display-booked" type="checkbox" name="booked-only" value="BOOKED">Only recent BOOKED appointments<br>
<button id="filter-button" type="submit">Filter</button>
</form>
</div>
Expand All @@ -65,21 +65,6 @@ <h1 class="title" style="margin-bottom: 0px; margin-top: 20px;">Secretary Dashbo
</tr>
</thead>
<tbody id="appointment-table-body">
<!-- <th:block>-->
<!-- <tr th:if="${#lists.isEmpty(appointmentList)}">-->
<!-- <td colspan="5">No appointments to show...</td>-->
<!-- <tr th:each="appointment : ${appointmentList}">-->
<!-- <td th:text="${appointment.appointment_id}"></td>-->
<!-- <td th:text="${appointment.result}"></td>-->
<!-- <td th:text="${appointment.date}"></td>-->
<!-- <td th:text="${appointment.time}"></td>-->
<!-- <td th:text="${appointment.patient.getCPR()}"></td>-->
<!-- <td>-->
<!--
<!-- </td>-->
<!-- </tr>-->
<!-- </th:block>-->

</tbody>
</table>
</form>
Expand All @@ -90,24 +75,14 @@ <h1 class="title" style="margin-bottom: 0px; margin-top: 20px;">Secretary Dashbo
<script th:inline="javascript">

const filterForm = document.getElementById('filter');
// let select = document.getElementById('select-google-maps');

let inputCPR = 1111111111;
let selectedCenter = null;
let todaysBooked = false;

// filterForm.onsubmit = function() {
// document.getElementById('cpr-box').defaultValue = 1111111111;
// }


// $("#cpr-box").attr("value", 1111111111);


filterForm.addEventListener('submit', handleSubmit);

// filterForm.onsubmit(handleSubmit(e));

function handleSubmit(event){

if (document.getElementById('cpr-box').value !== "") {
Expand Down Expand Up @@ -168,6 +143,7 @@ <h1 class="title" style="margin-bottom: 0px; margin-top: 20px;">Secretary Dashbo

let app_id = document.createElement("td");
app_id.innerHTML = currentID;
app_id.value = currentID;
let app_status = document.createElement("td");

let appointmentDate = new Date(appointments[i].date);
Expand All @@ -179,7 +155,7 @@ <h1 class="title" style="margin-bottom: 0px; margin-top: 20px;">Secretary Dashbo
if (appointmentDate.getDate() <= today.getDate() && appointments[i].result === "BOOKED") {

let statusSelect = document.createElement("select");
statusSelect.id = "status-select";
statusSelect.className = "status-select";

let defaultOption = document.createElement("option");
defaultOption.value = null;
Expand All @@ -198,9 +174,7 @@ <h1 class="title" style="margin-bottom: 0px; margin-top: 20px;">Secretary Dashbo
statusSelect.appendChild(option);
}

}

else if (appointments[i].center.centerType === "COMIRNATY_VACCINE" || appointments[i].center.centerType === "MODERNA_VACCINE") {
} else if (appointments[i].center.centerType === "COMIRNATY_VACCINE" || appointments[i].center.centerType === "MODERNA_VACCINE") {

/*<![CDATA[*/

Expand All @@ -223,15 +197,28 @@ <h1 class="title" style="margin-bottom: 0px; margin-top: 20px;">Secretary Dashbo
option.text = vaccinated ? "VACCINATED" : "PARTIAL_VACCINE";

statusSelect.appendChild(option);

statusSelect.onchange = function() {
let selectedResult = statusSelect.options.selectedIndex.value;
console.log(statusSelect.value);
let selectedAppointmentID = currentID;
console.log(currentID);
$.ajax({
url: 'update-appointment-report',
type: 'post',
data: {appointment_id: currentID, status: statusSelect.value},
success: function (response) {
console.log("updated successfully");
console.log(currentID);
}
});
};
}

// statusSelect.addEventListener('change', handleChange);
app_status.appendChild(statusSelect);



}
else {
} else {
app_status.innerHTML = appointments[i].result;
}

Expand All @@ -254,35 +241,18 @@ <h1 class="title" style="margin-bottom: 0px; margin-top: 20px;">Secretary Dashbo

tableBody.appendChild(tr);



} catch (e) {
console.log(e);
}
}

document.getElementById('cpr-box').value = "";
// let selectedResult = document.getElementById('status-select').options[statusSelect.selectedIndex].value;
// let selectedResult = statusSelect.options[statusSelect.selectedIndex].value;
// // statusSelect.value = appointments[i].appointment_id;
// statusSelect.onchange = $.ajax({
// url: 'update-appointment-report',
// type: 'post',
// data: {currentID: currentID, selectedResult: selectedResult}
// });

//try making it work on change

// const saveButton = document.createElement("button");
// saveButton.className = "small-cta";
// saveButton.type = "submit";
// saveButton.name = "centerid";
// saveButton.value = response.appointment_id";
// saveButton.innerText = "Save Changes";
//
// table.appendChild(saveButton);


}
})

}

});

}catch (e) {
console.log(e)
Expand Down

0 comments on commit 074486a

Please sign in to comment.