-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3934633
commit c3d4cca
Showing
11 changed files
with
245 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
CloudDrive.Application.Abstraction/ViewModels/DirectorySelectBoxVM.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace CloudDrive.Application | ||
{ | ||
public class DirectorySelectBoxVM | ||
{ | ||
public string Text { get; set; } | ||
public Guid Value { get; set; } | ||
public Guid? ParentDirectoryId { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<template> | ||
<q-form class="q-gutter-md" @submit="tryAdd"> | ||
<p class="text-h5 q-mt-lg q-mb-xs">Dodawanie nowego folderu</p> | ||
<div class="row q-py-lg"> | ||
<div class="column q-mx-md form-field"> | ||
<q-input | ||
filled | ||
v-model="form.Name" | ||
label="Nazwa folderu" | ||
lazy-rules | ||
color="secondary" | ||
dark | ||
:rules="[ | ||
(val) => (val && val.length > 0) || 'Nazwa folderu jest wymagana!', | ||
]" | ||
dense | ||
/> | ||
</div> | ||
<div class="column q-mx-md form-field"> | ||
<q-select | ||
filled | ||
v-model="form.ParentDirectoryId" | ||
label="Folder nadrzędny" | ||
color="secondary" | ||
dark | ||
:options="directories" | ||
option-label="text" | ||
option-value="value" | ||
emit-value | ||
map-options | ||
dense | ||
clearable | ||
/> | ||
</div> | ||
<q-space /> | ||
<div class="column q-mx-md"> | ||
<q-btn label="Dodaj" text-color="secondary" outline type="submit" /> | ||
</div> | ||
</div> | ||
</q-form> | ||
</template> | ||
|
||
<script> | ||
import { useDirectoryStore } from "../stores/directory.js"; | ||
import { mapActions, mapWritableState } from "pinia"; | ||
export default { | ||
name: "DirectoryAddForm", | ||
data() { | ||
return { | ||
directories: [], | ||
}; | ||
}, | ||
computed: { | ||
...mapWritableState(useDirectoryStore, ["form"]), | ||
}, | ||
methods: { | ||
...mapActions(useDirectoryStore, [ | ||
"clearForm", | ||
"addDirectory", | ||
"getDirectoriesToSelectList", | ||
]), | ||
async tryAdd() { | ||
await this.addDirectory(); | ||
this.$q.notify({ | ||
type: "positive", | ||
message: "Folder został dodany pomyślnie!", | ||
}); | ||
this.$emit("close"); | ||
}, | ||
}, | ||
mounted() { | ||
this.getDirectoriesToSelectList().then((response) => { | ||
this.directories = response; | ||
}); | ||
}, | ||
beforeUnmount() { | ||
this.clearForm(); | ||
}, | ||
}; | ||
</script> | ||
<style lang="scss" scoped> | ||
.container-register { | ||
width: 350px; | ||
border-top: 4px solid $secondary; | ||
background-color: $dark; | ||
} | ||
.form-field { | ||
width: 36%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { defineStore } from "pinia"; | ||
import { api } from "src/boot/axios"; | ||
import { useAuthenticationStore } from "./authentication"; | ||
const authenticationStore = useAuthenticationStore(); | ||
|
||
export const useDirectoryStore = defineStore({ | ||
id: "directory", | ||
state: () => ({ | ||
form: { | ||
Name: "", | ||
ParentDirectoryId: "", | ||
}, | ||
}), | ||
actions: { | ||
async addDirectory() { | ||
await api.post("/File/addDirectory", this.form, { | ||
headers: { | ||
Authorization: `Bearer ${authenticationStore.currentUser.token}`, | ||
}, | ||
}); | ||
}, | ||
clearForm() { | ||
this.form.Name = ""; | ||
this.form.ParentDirectoryId = ""; | ||
}, | ||
getDirectoriesToSelectList() { | ||
if ( | ||
authenticationStore.currentUser && | ||
authenticationStore.currentUser.token | ||
) { | ||
return new Promise((resolve) => { | ||
api | ||
.get("/File/getDirectoriesToSelectList", { | ||
headers: { | ||
Authorization: `Bearer ${authenticationStore.currentUser.token}`, | ||
}, | ||
}) | ||
.then((response) => { | ||
resolve(response.data); | ||
}); | ||
}); | ||
} | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.