Whalebird-desktop-client-ma.../src/renderer/components/TimelineSpace/NewTootModal.vue

122 lines
2.6 KiB
Vue
Raw Normal View History

2018-03-12 17:42:47 +01:00
<template>
<el-dialog
title="New Toot"
:visible.sync="newTootModal"
width="400px"
class="new-toot-modal" v-on:submit.prevent="toot">
2018-03-12 17:42:47 +01:00
<el-form :model="tootForm">
<div class="status">
<textarea v-model="tootForm.status" ref="status" @keyup.ctrl.enter.exact="toot" @keyup.meta.enter.exact="toot"></textarea>
</div>
2018-03-12 17:42:47 +01:00
</el-form>
<span slot="footer" class="dialog-footer">
<span class="text-count">{{ 500 - tootForm.status.length }}</span>
2018-03-13 00:41:03 +01:00
<el-button @click="close">Cancel</el-button>
<el-button type="primary" @click="toot">Toot</el-button>
2018-03-12 17:42:47 +01:00
</span>
</el-dialog>
</template>
<script>
export default {
name: 'new-toot-modal',
data () {
return {
tootForm: {
status: ''
2018-03-12 17:42:47 +01:00
}
}
},
computed: {
newTootModal: {
get () {
return this.$store.state.TimelineSpace.NewTootModal.modalOpen
2018-03-12 17:42:47 +01:00
},
set (value) {
this.$store.commit('TimelineSpace/NewTootModal/changeModal', value)
2018-03-12 17:42:47 +01:00
}
}
2018-03-13 00:41:03 +01:00
},
updated () {
if (this.newTootModal) {
this.$refs.status.focus()
}
},
2018-03-13 00:41:03 +01:00
methods: {
close () {
this.$store.commit('TimelineSpace/NewTootModal/changeModal', false)
2018-03-13 00:41:03 +01:00
},
toot () {
if (this.tootForm.status.length <= 0 || this.tootForm.status.length >= 500) {
2018-03-13 02:52:28 +01:00
return this.$message({
message: 'Toot length should be 1 to 500',
type: 'error'
})
}
this.$store.dispatch('TimelineSpace/NewTootModal/postToot', this.tootForm)
2018-03-13 00:41:03 +01:00
.then(() => {
this.tootForm.status = ''
2018-03-13 00:41:03 +01:00
this.$message({
message: 'Toot',
type: 'success'
})
})
.catch(() => {
this.$message({
message: 'Could not toot',
type: 'error'
})
})
}
2018-03-12 17:42:47 +01:00
}
}
</script>
<style lang="scss" scoped>
.new-toot-modal /deep/ {
2018-03-12 17:42:47 +01:00
.el-dialog__header {
background-color: #4a5664;
.el-dialog__title {
color: #ebeef5;
}
}
.el-dialog__body {
padding: 0;
.status {
2018-03-12 17:42:47 +01:00
textarea {
display: block;
padding: 5px 15px;
line-height: 1.5;
box-sizing: border-box;
width: 100%;
font-size: inherit;
color: #606266;
background-color: #ffffff;
background-image: none;
2018-03-12 17:42:47 +01:00
border: 0;
border-radius: 4px;
2018-03-12 17:42:47 +01:00
resize: none;
height: 120px;
transition: border-color .2s cubic-bezier(.645,.045,.355,1);
}
textarea:focus {
outline: 0;
2018-03-12 17:42:47 +01:00
}
}
}
.el-dialog__footer {
background-color: #f2f6fc;
2018-03-13 02:52:28 +01:00
.text-count {
padding-right: 24px;
color: #909399;
}
2018-03-12 17:42:47 +01:00
}
}
</style>