added invalid input process
mellbacon committed
Aug 10, 2022 at 19:26 UTC
1acf49c970f92cfb5f1e00073bd462c93fc36f97
3 files changed
+12
-2
src/components/FileTree/TreeData.ts
+1
@@ -4,6 +4,7 @@ let parentname: string;
4
let dir;
5
export async function data() {
6
let dirname = await dialog.open({ directory: true }) as string;
7
+ if (dirname === null) return;
8
dir = dirname;
9
return await loadTree();
10
}
src/components/Menu/menu.ts
+3
-2
@@ -6,6 +6,7 @@ export const filemenu = [
6
{ option: "Open File...", shortcut: "Ctrl + O", onclick: () => { console.log("click"); } },
7
{ option: "Open Folder", shortcut: "Ctrl + K", onclick: async () => {
8
let treedata = await data();
9
+ if (treedata === undefined) return;
10
filetree.set(treedata);
11
workspacename.set(workspace());
12
}},
@@ -46,6 +47,6 @@ export const helpmenu = [
47
{ option: "View Commands", onclick: () => { console.log("click"); } },
48
{ option: "Toggle developer tools", onclick: () => { console.log("click"); } },
49
{ option: "Release Notes", onclick: () => { console.log("click"); }, divider: true },
49
- { option: "Check for Updates", onclick: () => { console.log("click"); } },
50
- { option: "About Editor", onclick: () => { console.log("click"); } },
50
+ { option: "Check for Updates", onclick: async() => { console.log("click"); } },
51
+ { option: "About Editor", onclick: async() => { console.log("click"); } },
52
];
\ No newline at end of file
src/components/Modal/RenameModel.svelte
+8
@@ -11,6 +11,7 @@
11
? filenameinput.split(".")[1]
12
: "-";
13
14
+ let invalid = false;
15
function getExt() {
16
extinput = filenameinput.split(".")[1];
17
if (extinput === undefined || extinput === "") {
@@ -33,10 +34,13 @@
34
</div>
35
<div class="input">
36
<Input
37
+ invalid={invalid}
38
bind:value={filenameinput}
39
labelText="Name:"
40
placeholder="Enter name..."
41
+ invalidText="Enter a name for your file"
42
on:input={() => {
43
+ invalid = false;
44
getExt();
45
}}
46
/>
@@ -53,6 +57,10 @@
57
<div
58
class="button"
59
on:click={async () => {
60
+ if (filenameinput === "" || undefined) {
61
+ invalid = true;
62
+ return;
63
+ }
64
let oldpath = path;
65
let newpath = path.split("\\");
66
newpath.pop();