Merge pull request #503 from h3poteto/iss-482

closes #482 Add confirm modal when close new toot
This commit is contained in:
AkiraFukushima 2018-08-17 09:11:55 +09:00 committed by GitHub
commit 688eb928a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 4 deletions

View File

@ -121,7 +121,10 @@
"cw": "Write your warning here", "cw": "Write your warning here",
"status": "What is on your mind?", "status": "What is on your mind?",
"cancel": "Cancel", "cancel": "Cancel",
"toot": "Toot" "toot": "Toot",
"close_confirm": "Are you sure to close new toot?",
"close_confirm_ok": "OK",
"close_confirm_cancel": "Cancel"
}, },
"jump": { "jump": {
"jump_to": "Jump to..." "jump_to": "Jump to..."

View File

@ -121,7 +121,10 @@
"cw": "Écrivez votre avertissement ici", "cw": "Écrivez votre avertissement ici",
"status": "Qu'avez-vous en tête ?", "status": "Qu'avez-vous en tête ?",
"cancel": "Annuler", "cancel": "Annuler",
"toot": "Pouet!" "toot": "Pouet!",
"close_confirm": "Êtes-vous certain de vouloir fermer ce nouveau pouet ?",
"close_confirm_ok": "Oui",
"close_confirm_cancel": "Annuler"
}, },
"jump": { "jump": {
"jump_to": "Aller à..." "jump_to": "Aller à..."

View File

@ -121,7 +121,10 @@
"cw": "ここに警告を書いてください", "cw": "ここに警告を書いてください",
"status": "今なにしてる?", "status": "今なにしてる?",
"cancel": "キャンセル", "cancel": "キャンセル",
"toot": "トゥート!" "toot": "トゥート!",
"close_confirm": "本当に閉じますか?",
"close_confirm_ok": "閉じる",
"close_confirm_cancel": "キャンセル"
}, },
"jump": { "jump": {
"jump_to": "移動..." "jump_to": "移動..."

View File

@ -2,6 +2,7 @@
<el-dialog <el-dialog
:title="$t('modals.new_toot.title')" :title="$t('modals.new_toot.title')"
:visible.sync="newTootModal" :visible.sync="newTootModal"
:before-close="closeConfirm"
width="400px" width="400px"
class="new-toot-modal"> class="new-toot-modal">
<el-form v-on:submit.prevent="toot"> <el-form v-on:submit.prevent="toot">
@ -234,6 +235,22 @@ export default {
}, },
changeSensitive () { changeSensitive () {
this.$store.commit('TimelineSpace/Modals/NewToot/changeSensitive', !this.sensitive) this.$store.commit('TimelineSpace/Modals/NewToot/changeSensitive', !this.sensitive)
},
closeConfirm (done) {
if (this.status.length === 0) {
done()
} else {
this.$confirm(
this.$t('modals.new_toot.close_confirm'),
{
confirmButtonText: this.$t('modals.new_toot.close_confirm_ok'),
cancelButtonText: this.$t('modals.new_toot.close_confirm_cancel')
})
.then(_ => {
done()
})
.catch(_ => {})
}
} }
} }
} }

View File

@ -3,7 +3,7 @@
<textarea <textarea
v-model="status" v-model="status"
ref="status" ref="status"
v-shortkey="openSuggest ? {up: ['arrowup'], down: ['arrowdown'], enter: ['enter']} : {linux: ['ctrl', 'enter'], mac: ['meta', 'enter'], left: ['arrowleft'], right: ['arrowright']}" v-shortkey="openSuggest ? {up: ['arrowup'], down: ['arrowdown'], enter: ['enter'], esc: ['esc']} : {linux: ['ctrl', 'enter'], mac: ['meta', 'enter'], left: ['arrowleft'], right: ['arrowright']}"
@shortkey="handleKey" @shortkey="handleKey"
v-on:input="startSuggest" v-on:input="startSuggest"
:placeholder="$t('modals.new_toot.status')" :placeholder="$t('modals.new_toot.status')"
@ -140,6 +140,9 @@ export default {
case 'enter': case 'enter':
this.selectCurrentAccount() this.selectCurrentAccount()
break break
case 'esc':
this.closeSuggest()
break
case 'left': case 'left':
event.target.setSelectionRange(current - 1, current - 1) event.target.setSelectionRange(current - 1, current - 1)
break break