Skip to content

Commit 0b11532

Browse files
committed
Get modal base logic all worked out
1 parent be7f7d8 commit 0b11532

File tree

6 files changed

+67
-19
lines changed

6 files changed

+67
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"jquery": "^3.3.1",
88
"lodash": "^4.17.11",
99
"socket.io-client": "^2.1.1",
10-
"vee-validate": "^2.1.0-beta.2",
10+
"vee-validate": "^2.1.7",
1111
"vue": "^2.6.4",
1212
"vue-axios": "^2.1.1",
1313
"vue-i18n": "^8.6.0",

resources/assets/scripts/components/core/Modal.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<transition name="modal">
33
<div class="modal-mask" v-show="show" v-on:click="close">
44
<div class="modal-container" @click.stop>
5-
<div v-on:click="close" v-if="dismissable">
5+
<div v-on:click="close" v-if="dismissable && showCloseIcon">
66
<Icon name="x"
77
class="absolute pin-r pin-t m-2 text-neutral-500 cursor-pointer"
88
aria-label="Close modal"
@@ -24,6 +24,7 @@
2424
components: {Icon},
2525
2626
props: {
27+
showCloseIcon: {type: Boolean, default: true},
2728
modalName: {type: String, default: 'modal'},
2829
show: {type: Boolean, default: false},
2930
closeOnEsc: {type: Boolean, default: true},

resources/assets/scripts/components/server/components/filemanager/modals/CreateFolderModal.vue

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
<template>
2-
<Modal :show="visible" v-on:close="visible = false">
3-
<div>
4-
<h2 class="font-medium text-neutral-900 mb-6">{{ fm.currentDirectory }}</h2>
2+
<Modal :show="visible" v-on:close="onModalClose" :showCloseIcon="false">
3+
<div class="flex items-end">
4+
<div class="flex-1">
5+
<label class="input-label">
6+
Folder Name
7+
</label>
8+
<input
9+
type="text" class="input" name="folder_name"
10+
ref="folderNameField"
11+
v-model="folderName"
12+
v-validate.disabled="'required'"
13+
v-validate="'alpha_dash'"
14+
data-vv-as="Folder Name"
15+
v-on:keyup.enter="submit"
16+
/>
17+
</div>
18+
<div class="ml-4">
19+
<button class="btn btn-primary btn-sm" type="submit" v-on:submit.prevent="submit">
20+
Create
21+
</button>
22+
</div>
523
</div>
24+
<p class="input-help error">
25+
{{ errors.first('folder_name') }}
26+
</p>
627
</Modal>
728
</template>
829

@@ -22,13 +43,39 @@
2243
data: function () {
2344
return {
2445
visible: false,
46+
folderName: '',
2547
};
2648
},
2749
2850
mounted: function () {
51+
/**
52+
* When we mark the modal as visible, focus the user into the input field on the next
53+
* tick operation so that they can begin typing right away.
54+
*/
2955
window.events.$on('server:files:open-directory-modal', () => {
3056
this.visible = true;
57+
this.$nextTick(() => {
58+
(this.$refs.folderNameField as HTMLInputElement).focus();
59+
});
3160
});
3261
},
62+
63+
methods: {
64+
submit: function () {
65+
this.$validator.validate().then((result) => {
66+
if (!result) {
67+
return;
68+
}
69+
70+
this.onModalClose();
71+
});
72+
},
73+
74+
onModalClose: function () {
75+
this.visible = false;
76+
this.folderName = '';
77+
this.$validator.reset();
78+
},
79+
}
3380
});
3481
</script>

resources/assets/scripts/helpers/ziggy.js

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const cssLoaders = [
113113
module.exports = {
114114
target: 'web',
115115
mode: process.env.NODE_ENV,
116-
devtool: isProduction ? false : 'inline-source-map',
116+
devtool: isProduction ? false : 'eval-source-map',
117117
performance: {
118118
hints: false,
119119
},

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7062,9 +7062,9 @@ vary@~1.1.2:
70627062
version "1.1.2"
70637063
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
70647064

7065-
vee-validate@^2.1.0-beta.2:
7066-
version "2.1.0-beta.2"
7067-
resolved "https://registry.yarnpkg.com/vee-validate/-/vee-validate-2.1.0-beta.2.tgz#b4a15f7aa0c4b1a9c78132d649b72a4dd4e2fa61"
7065+
vee-validate@^2.1.7:
7066+
version "2.1.7"
7067+
resolved "https://registry.yarnpkg.com/vee-validate/-/vee-validate-2.1.7.tgz#33984454d8a633cdc4825a2cf5857747d91bae67"
70687068

70697069
vendors@^1.0.0:
70707070
version "1.0.2"

0 commit comments

Comments
 (0)