mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
feat: new $prompt global method
This commit is contained in:
parent
493d0c4090
commit
b1f6a2f239
1 changed files with 12 additions and 2 deletions
|
@ -9,7 +9,9 @@ v-dialog(v-model='show'
|
||||||
@keydown.esc='cancel')
|
@keydown.esc='cancel')
|
||||||
v-card
|
v-card
|
||||||
v-card-title {{ title }}
|
v-card-title {{ title }}
|
||||||
v-card-text(v-show='!!message' v-html='message')
|
v-card-text(v-show='!!message')
|
||||||
|
span(v-html='message')
|
||||||
|
v-textarea(v-if='options.is_prompt' v-model='prompt')
|
||||||
v-card-actions
|
v-card-actions
|
||||||
v-spacer
|
v-spacer
|
||||||
v-btn(outlined color='error' @click='cancel') {{$t('common.cancel')}}
|
v-btn(outlined color='error' @click='cancel') {{$t('common.cancel')}}
|
||||||
|
@ -39,7 +41,9 @@ export default {
|
||||||
reject: null,
|
reject: null,
|
||||||
message: null,
|
message: null,
|
||||||
title: null,
|
title: null,
|
||||||
|
prompt: '',
|
||||||
options: {
|
options: {
|
||||||
|
is_prompt: false,
|
||||||
color: 'danger',
|
color: 'danger',
|
||||||
width: 450,
|
width: 450,
|
||||||
zIndex: 500
|
zIndex: 500
|
||||||
|
@ -60,8 +64,12 @@ export default {
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.$root.$confirm = this.open
|
this.$root.$confirm = this.open
|
||||||
|
this.$root.$prompt = this.openPrompt
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
openPrompt (message, options ) {
|
||||||
|
return this.open(message, { ...options, is_prompt: true })
|
||||||
|
},
|
||||||
open (message, options = {}) {
|
open (message, options = {}) {
|
||||||
this.dialog = true
|
this.dialog = true
|
||||||
this.title = options.title || this.$t('common.confirm')
|
this.title = options.title || this.$t('common.confirm')
|
||||||
|
@ -73,11 +81,13 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
agree () {
|
agree () {
|
||||||
this.resolve(true)
|
this.resolve(this.options.is_prompt ? this.prompt : true)
|
||||||
|
this.prompt = ''
|
||||||
this.dialog = false
|
this.dialog = false
|
||||||
},
|
},
|
||||||
cancel () {
|
cancel () {
|
||||||
this.resolve(false)
|
this.resolve(false)
|
||||||
|
this.prompt = ''
|
||||||
this.dialog = false
|
this.dialog = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue