-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(files): create folder-creation-form component
- Loading branch information
1 parent
286a5f8
commit 8e03fd8
Showing
9 changed files
with
207 additions
and
116 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
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
29 changes: 29 additions & 0 deletions
29
src/components/specific/files/folder-creation-form/FolderCreationForm.scss
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,29 @@ | ||
.folder-creation-form { | ||
padding: $spacing-unit; | ||
background-color: $color-white; | ||
|
||
display: flex; | ||
flex-wrap: wrap; | ||
|
||
&__title { | ||
width: 100%; | ||
display: flex; | ||
align-items: flex-end; | ||
gap: $spacing-unit/2; | ||
color: $color-primary; | ||
} | ||
|
||
&__input { | ||
width: 100%; | ||
margin: $spacing-unit * 2 0; | ||
font-size: 1rem; | ||
} | ||
|
||
&__btn-cancel { | ||
margin-left: auto; | ||
} | ||
|
||
&__btn-submit { | ||
margin-left: $spacing-unit; | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
src/components/specific/files/folder-creation-form/FolderCreationForm.vue
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,116 @@ | ||
<template> | ||
<div class="folder-creation-form"> | ||
<div class="folder-creation-form__title"> | ||
<BIMDataIcon name="addFolder" size="xs" /> | ||
<span>{{ $t("FolderCreationForm.creationFormTitle") }}</span> | ||
</div> | ||
<BIMDataInput | ||
ref="nameInput" | ||
class="folder-creation-form__input" | ||
:placeholder="$t('FolderCreationForm.nameInputPlaceholder')" | ||
v-model="name" | ||
:error="error" | ||
:errorMessage="$t('FolderCreationForm.nameInputErrorMessage')" | ||
@keyup.esc.stop="close" | ||
@keyup.enter.stop="submit" | ||
/> | ||
<BIMDataButton | ||
class="folder-creation-form__btn-cancel" | ||
width="80px" | ||
ghost | ||
radius | ||
@click="close" | ||
> | ||
{{ $t("FolderCreationForm.cancelButtonText") }} | ||
</BIMDataButton> | ||
<BIMDataButton | ||
class="folder-creation-form__btn-submit" | ||
width="80px" | ||
color="primary" | ||
fill | ||
radius | ||
@click="submit" | ||
> | ||
{{ $t("FolderCreationForm.submitButtonText") }} | ||
</BIMDataButton> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { onMounted, ref } from "vue"; | ||
import { useFiles } from "@/state/files"; | ||
// Components | ||
import BIMDataButton from "@bimdata/design-system/dist/js/BIMDataComponents/vue3/BIMDataButton.js"; | ||
import BIMDataIcon from "@bimdata/design-system/dist/js/BIMDataComponents/vue3/BIMDataIcon.js"; | ||
import BIMDataInput from "@bimdata/design-system/dist/js/BIMDataComponents/vue3/BIMDataInput.js"; | ||
export default { | ||
components: { | ||
BIMDataButton, | ||
BIMDataIcon, | ||
BIMDataInput | ||
}, | ||
props: { | ||
project: { | ||
type: Object, | ||
required: true | ||
}, | ||
folder: { | ||
type: Object, | ||
required: true | ||
} | ||
}, | ||
emits: ["close", "success", "error"], | ||
setup(props, { emit }) { | ||
const { createFolder } = useFiles(); | ||
const nameInput = ref(null); | ||
const name = ref(""); | ||
const error = ref(false); | ||
const reset = () => { | ||
name.value = ""; | ||
error.value = false; | ||
}; | ||
const submit = async () => { | ||
if (name.value) { | ||
try { | ||
await createFolder(props.project, { | ||
parentId: props.folder.id, | ||
name: name.value | ||
}); | ||
reset(); | ||
emit("success"); | ||
} catch (error) { | ||
emit("error", error); | ||
} | ||
} else { | ||
nameInput.value.focus(); | ||
error.value = true; | ||
} | ||
}; | ||
const close = () => { | ||
reset(); | ||
emit("close"); | ||
}; | ||
onMounted(() => { | ||
setTimeout(() => nameInput.value.focus(), 200); | ||
}); | ||
return { | ||
// References | ||
error, | ||
name, | ||
nameInput, | ||
// Methods | ||
close, | ||
submit | ||
}; | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped lang="scss" src="./FolderCreationForm.scss"></style> |
Oops, something went wrong.