Overlap Bugfix

If any entries overlaps with the Users entries from other Semesters, the users entries will be cut of
This commit is contained in:
AliGitGut
2023-06-10 00:01:53 +02:00
parent 092f7d3a8a
commit 43165d7756
2 changed files with 39 additions and 2 deletions
+37
View File
@@ -43,6 +43,7 @@ export default function CalenderView(p) {
let url = baseURL + "/entries?semesterid=" + localStorage.getItem("currentsid") +
"&daynumber=" + currentWeekStartDay + "&yearnumber=" + currentYear + "&sessionid=" + localStorage.getItem("sessionid");
let currentsid = localStorage.getItem("currentsid")
let userid = localStorage.getItem("userid")
try {
fetch(url).then(r => r.json()).then(en => {
@@ -109,6 +110,42 @@ export default function CalenderView(p) {
}
}
for (let i = 0; i < 6; i++) {
for (let k = 0; k < 20; k++) {
if (en[i][k] != null){
if (en[i][k].semesterid != currentsid)
{
for (let l = 0; l < 20; l++) {
if (en[i][l] != null && en[i][l].usercreatedbyid != userid) {
if (en[i][l].timestart <= en[i][k].timestart && en[i][l].timeend >= en[i][k].timeend) {
en[i][k] = null;
break
}
if (en[i][k].timestart <= en[i][l].timeend && en[i][k].timestart >= en[i][l].timestart) {
en[i][k].timestart = en[i][l].timeend
}
if (en[i][k].timeend >= en[i][l].timestart && en[i][k].timeend <= en[i][l].timeend) {
en[i][k].timeend = en[i][l].timestart
}
}
}
}
if (en[i][k] != null && en[i][k].usercreatedbyid != userid) {
for (let l = 0; l < 20; l++) {
if (en[i][l] != null && en[i][l].semesterid != currentsid) {
if (en[i][l].timestart <= en[i][k].timestart && en[i][l].timeend >= en[i][k].timeend) {
en[i][k] = null;
break
}
}
}
}
}
}
}
let j = 0;
for(let i = Math.round(((new Date(currentYear, 0, currentWeekStartDay) - new Date(currentYear, 0, 0)) / (1000 * 60 * 60 * 24))); i <= Math.round(((new Date(currentYear, 0, currentWeekStartDay + 5) - new Date(currentYear, 0, 0)) / (1000 * 60 * 60 * 24))); i++)
{
+2 -2
View File
@@ -1,2 +1,2 @@
// export const baseURL = "http://185.245.96.48:8080"
export const baseURL = "http://localhost:8080"
export const baseURL = "http://185.245.96.48:8080"
//export const baseURL = "http://localhost:8080"