Skip to content

Commit

Permalink
Merge pull request #33 from chia030/chiarasWork
Browse files Browse the repository at this point in the history
Done!
  • Loading branch information
chia030 authored Jun 2, 2021
2 parents 3ca7ece + 6804bb2 commit 60fe18f
Show file tree
Hide file tree
Showing 2 changed files with 34 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
86 changes: 29 additions & 57 deletions src/main/resources/templates/logging/secretary-landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ <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" class="cta" style="margin-left: 20px;">Filter</button>

</form>
</div>

Expand All @@ -70,21 +72,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 @@ -95,24 +82,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 @@ -173,6 +150,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 @@ -184,7 +162,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 @@ -203,9 +181,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 @@ -228,15 +204,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 @@ -259,35 +248,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 60fe18f

Please sign in to comment.