Merge pull request 'project-data-fix' (#35) from project-data-fix into master

Reviewed-on: #35
This commit is contained in:
Rohit Pai 2023-06-26 18:13:40 +01:00
commit be5e047f51
6 changed files with 16 additions and 14 deletions

View File

@ -64,7 +64,7 @@ class projectData
if ($isMainProject === "true")
{
$stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0;");
$stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0 WHERE isMainProject = 1;");
$stmtMainProject->execute();
}
@ -129,7 +129,7 @@ class projectData
$conn = dbConn();
if ($isMainProject === "true")
{
$stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0;");
$stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0 WHERE isMainProject = 1;");
$stmtMainProject->execute();
}
@ -173,7 +173,7 @@ class projectData
// update the database with the new image location
$conn = dbConn();
$stmt = $conn->prepare("UPDATE projects SET imgLocation = :imgLocation WHERE ID = :ID");
$stmt->bindParam(":imgLocation", $targetFile);
$stmt->bindParam(":imgLocation", $targetFile["imgLocation"]);
$stmt->bindParam(":ID", $ID);
$stmt->execute();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -64,7 +64,7 @@ class projectData
if ($isMainProject === "true")
{
$stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0;");
$stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0 WHERE isMainProject = 1;");
$stmtMainProject->execute();
}
@ -129,7 +129,7 @@ class projectData
$conn = dbConn();
if ($isMainProject === "true")
{
$stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0;");
$stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0 WHERE isMainProject = 1;");
$stmtMainProject->execute();
}
@ -173,7 +173,7 @@ class projectData
// update the database with the new image location
$conn = dbConn();
$stmt = $conn->prepare("UPDATE projects SET imgLocation = :imgLocation WHERE ID = :ID");
$stmt->bindParam(":imgLocation", $targetFile);
$stmt->bindParam(":imgLocation", $targetFile["imgLocation"]);
$stmt->bindParam(":ID", $ID);
$stmt->execute();

View File

@ -18,9 +18,10 @@
class="fa fa-caret-right"></i></a></li>
<li class="dropdown">
<ul>
<li><a href="#" id="goToAddPost" class="active"><span>&lt;</span>Add Blog Post<span>&gt;</span></a>
<li><a href="#" id="goToAddPost"><span>&lt;</span>Add Blog Post<span>&gt;</span></a>
</li>
<li><a href="#" id="goToEditPost"><span>&lt;</span>Edit Blog Post<span>&gt;</span></a></li>
<li><a href="#" id="goToEditPost" class="active"><span>&lt;</span>Edit Blog
Post<span>&gt;</span></a></li>
</ul>
</li>
<li><a href="#" id="logout"><span>&lt;</span>Logout<span>&gt;</span></a></li>
@ -205,6 +206,8 @@
<input type="submit" value="Add new blog post" class="btn btnPrimary boxShadowIn boxShadowOut">
</form>
</section>
</main>
<script src="js/editor.js"></script>

View File

@ -56,7 +56,7 @@ document.addEventListener('DOMContentLoaded', () =>
{
json.forEach(item =>
{
addProject(item["ID"], (item["isMainProject"] === "1" ? "true" : "false"), (item["imgLocation"] === "") ? "../imgs/placeholder.png" : item["imgLocation"], item["title"], item["information"], item["projectLink"], item["gitLink"]);
addProject(item["ID"], (item["isMainProject"] === 1 ? "true" : "false"), (item["imgLocation"] === "") ? "../imgs/placeholder.png" : item["imgLocation"], item["title"], item["information"], item["projectLink"], item["gitLink"]);
})
return;
}
@ -353,7 +353,6 @@ document.querySelector("#projError .close").addEventListener("click", () =>
document.querySelector("#addPostError .close").addEventListener("click", () =>
document.querySelector("#addPostError").classList.toggle("hidden"));
document.querySelector("#addPostSuccess .close").addEventListener("click", () =>
document.querySelector("#addPostSuccess").classList.toggle("hidden"));
@ -777,7 +776,7 @@ function updateProjectItem(id, e)
{
window.location.href = "./";
return;
}ujh
}
document.querySelector(`#projError${id}`).classList.remove("hidden");
document.querySelector(`#projError${id} div`).innerHTML = updatedProjectImage.error;
@ -856,7 +855,7 @@ function addProject(id , isMainProject, imgLocation, title, information, project
</div>
<div class="formControl isMainProject">
<label class="checkContainer" for="isMainProject${id}">Is It The Main Project
<input type="checkbox" id="isMainProject${id}" name="isMainProject${id}" ${(isMainProject === "true" ? "checked" : "")}>
<input type="checkbox" id="isMainProject${id}" name="isMainProject${id}" ${(isMainProject === "true" ? "checked=''" : "")}>
<span class="checkmark"></span>
</label>
</div>