v0.5.4 - Created the "reservations in location" screen and added a location option when creating reservations.

This commit is contained in:
frederikpyt
2020-08-06 10:32:34 +02:00
parent 358e47b703
commit 4b0ad949ba
6 changed files with 103 additions and 11 deletions
@@ -97,8 +97,8 @@
}
function onDateSelect(date, dayHolder, datetext) {
console.log("Opdaterer selects");
let events;
let locationz;
let machinez;
let buttonz;
@@ -114,20 +114,47 @@
dayHolder.classList.add("selected");
let machine_id;
let location_id;
if(document.getElementById('washing-machines'))
machine_id = document.getElementById('washing-machines').value;
else
machine_id = 0;
if(document.getElementById('locations'))
location_id = document.getElementById('locations').value;
else
location_id = 0;
axios({
method: 'get',
url: '{{ route("washing-reservations.api") }}',
params: { 'date': date, 'machine_id': machine_id, 'datetext': datetext }
params: { 'date': date, 'machine_id': machine_id, 'datetext': datetext, 'location_id': location_id }
}).then(function (response) {
console.log(response.data["unavailable_times"]);
var data = response.data;
if(document.getElementById("locations") != undefined)
locationz = document.getElementById("locations");
else {
let span = document.createElement("span");
span.classList.add("events__title");
span.innerText = "Lokation";
let select = document.createElement("select");
select.classList.add("events__title");
select.id = "locations";
select.name = "location_id";
select.onchange = function() {
onDateSelect(date, dayHolder, datetext);
}
container.appendChild(span);
container.appendChild(select);
locationz = document.getElementById("locations");
}
if(document.getElementById("washing-machines") != undefined)
machinez = document.getElementById("washing-machines");
else {
@@ -180,6 +207,24 @@
buttonz = document.getElementById("events");
}
let locations = data["locations"];
locationz.innerHTML = "";
locationz.onchange = function () {
onDateSelect(date, dayHolder, datetext);
}
for (let i = 0; i < locations.length; i++) {
let option = document.createElement("option");
option.text = locations[i]["name"];
option.value = locations[i]["id"];
if(location_id == locations[i]["id"])
option.selected = "selected";
locationz.appendChild(option);
}
let machines = data["washingmachines"];
machinez.innerHTML = "";
@@ -213,7 +258,6 @@
let unavailable_times = data["unavailable_times"];
unavailable_times.forEach(function (item, index) {
console.log(item);
document.getElementById(item).remove();
});