Skip to content

Commit

Permalink
fix prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
yariksav committed Jun 16, 2020
1 parent ec34ead commit a9dd8b7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vuetify-dialog",
"version": "2.0.4",
"version": "2.0.5",
"description": "Dialog helper for vuetify.js",
"scripts": {
"build": "npm run build:umd & npm run build:es & npm run build:unpkg",
Expand Down
10 changes: 5 additions & 5 deletions src/components/DialogCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
:class="{'v-inner-scroll': innerScroll }"
>
<slot name="title">
<v-card-title v-if="title">
<div
:class="titleClass"
v-text="title"
/>
<v-card-title
v-if="title"
:class="titleClass"
>
{{ title }}
</v-card-title>
</slot>
<v-card-text>
Expand Down
47 changes: 33 additions & 14 deletions src/components/Prompt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
:handle="handleClick"
ref="card"
>
<v-text-field
ref="input"
required
v-model="editedValue"
:label="text"
@keypress.enter="$emit('submit', editedValue)"
/>
<v-form ref="form">
<v-text-field
ref="input"
v-model="editedValue"
:rules="rules"
:label="text"
v-bind="textField"
@keypress.enter="$emit('submit', editedValue)"
/>
</v-form>
</DialogCard>
</div>
</template>
Expand All @@ -21,32 +24,48 @@
import Confirmable from 'vuedl/src/mixins/confirmable'
import DialogCard from './DialogCard.vue'
import { VTextField } from 'vuetify/lib'
import { VTextField, VForm } from 'vuetify/lib'
export default {
components: {
DialogCard,
VTextField
VTextField,
VForm
},
layout: 'default',
mixins: [Confirmable],
props: {
value: String
value: String,
rules: Array,
textField: Object,
autofocus: {
type: Boolean,
default: true
}
},
data () {
return {
editedValue: this.value
}
},
mounted () {
setTimeout(() => {
this.$refs.input.focus()
}, 100)
if (this.autofocus) {
setTimeout(() => {
this.$refs.input.focus()
}, 100)
}
},
methods: {
handleClick (res, action) {
if (!action.key) {
this.$emit('submit', action.key)
}
const valid = this.rules ? this.$refs.form.validate() : true
if (!valid) {
this.$refs.input.focus()
return false
}
this.$emit('submit', action.key ? this.editedValue : action.key)
return false
}
}
}
Expand Down

0 comments on commit a9dd8b7

Please sign in to comment.