Skip to content

Commit dc88b6b

Browse files
committed
feat: Reject projects save request on empty project name field
1 parent aebf185 commit dc88b6b

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

pages/projects.vue

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Created Date: 2024-03-25 17:46:42
66
* Author: 3urobeat
77
*
8-
* Last Modified: 2024-04-21 18:47:22
8+
* Last Modified: 2024-04-21 19:53:59
99
* Modified By: 3urobeat
1010
*
1111
* Copyright (c) 2024 3urobeat <https://github.com/3urobeat>
@@ -45,13 +45,14 @@
4545
<div class="flex my-2.5 w-full" v-for="thisProject in storedProjects"> <!-- :key="thisProject.name" -->
4646

4747
<!-- Project select & name edit button -->
48-
<button class="flex w-full rounded-sm outline outline-border-secondary-light dark:outline-border-secondary-dark outline-2 hover:bg-bg-input-hover-light hover:dark:bg-bg-input-hover-dark hover:transition-all" @click="selectedProject = thisProject">
48+
<button :class="!thisProject.name ? 'outline-red-500' : 'outline-border-secondary-light dark:outline-border-secondary-dark'" class="flex w-full rounded-sm outline outline-2 hover:bg-bg-input-hover-light hover:dark:bg-bg-input-hover-dark hover:transition-all" @click="selectedProject = thisProject">
4949
<div class="relative">
5050
<span class="absolute text-lg font-bold -mt-1 ml-1 text-green-600" v-show="selectedProject.name == thisProject.name">|</span>
5151
</div>
5252
<input
5353
type="text"
54-
class="rounded-sm w-full px-1 mx-4 bg-bg-input-light dark:bg-bg-input-dark hover:bg-bg-input-hover-light hover:dark:bg-bg-input-hover-dark outline outline-border-secondary-light dark:outline-border-secondary-dark outline-2 hover:transition-all"
54+
:class="!thisProject.name ? 'outline-red-500' : 'outline-border-secondary-light dark:outline-border-secondary-dark'"
55+
class="rounded-sm w-full px-1 mx-4 bg-bg-input-light dark:bg-bg-input-dark hover:bg-bg-input-hover-light hover:dark:bg-bg-input-hover-dark outline outline-2 hover:transition-all"
5556
v-model.trim=thisProject.name
5657
>
5758
</button>
@@ -142,6 +143,20 @@
142143
143144
// Sends changes to the database
144145
async function saveChanges() {
146+
147+
// Check for missing name field
148+
if (storedProjects.value.some(e => !e.name)) {
149+
document.getElementById("color-border")?.classList.remove("border-transparent");
150+
document.getElementById("color-border")?.classList.add("border-red-500");
151+
152+
setTimeout(() => {
153+
document.getElementById("color-border")?.classList.remove("border-red-500");
154+
document.getElementById("color-border")?.classList.add("border-transparent");
155+
}, 750);
156+
157+
return;
158+
}
159+
145160
const success = await useFetch("/api/set-projects", {
146161
method: "POST",
147162
headers: {

pages/settings.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Created Date: 2024-03-25 17:46:47
66
* Author: 3urobeat
77
*
8-
* Last Modified: 2024-04-21 19:38:27
8+
* Last Modified: 2024-04-21 19:47:17
99
* Modified By: 3urobeat
1010
*
1111
* Copyright (c) 2024 3urobeat <https://github.com/3urobeat>
@@ -305,6 +305,8 @@
305305
document.getElementById("color-border")?.classList.remove("border-red-500");
306306
document.getElementById("color-border")?.classList.add("border-transparent");
307307
}, 750);
308+
309+
return;
308310
}
309311
310312

0 commit comments

Comments
 (0)