2018-03-12 17:42:47 +01:00
|
|
|
<template>
|
|
|
|
<el-dialog
|
|
|
|
title="New Toot"
|
|
|
|
:visible.sync="newTootModal"
|
|
|
|
width="400px"
|
2018-03-14 09:14:47 +01:00
|
|
|
class="new-toot-modal" v-on:submit.prevent="toot">
|
2018-03-12 17:42:47 +01:00
|
|
|
<el-form :model="tootForm">
|
2018-03-14 13:27:26 +01:00
|
|
|
<div class="status">
|
|
|
|
<textarea v-model="tootForm.status" ref="status" @keyup.ctrl.enter.exact="toot" @keyup.meta.enter.exact="toot"></textarea>
|
2018-03-13 02:04:07 +01:00
|
|
|
</div>
|
2018-03-12 17:42:47 +01:00
|
|
|
</el-form>
|
|
|
|
<span slot="footer" class="dialog-footer">
|
2018-03-14 13:27:26 +01:00
|
|
|
<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: {
|
2018-03-14 13:27:26 +01:00
|
|
|
status: ''
|
2018-03-12 17:42:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
newTootModal: {
|
|
|
|
get () {
|
2018-03-14 13:27:26 +01:00
|
|
|
return this.$store.state.TimelineSpace.NewTootModal.modalOpen
|
2018-03-12 17:42:47 +01:00
|
|
|
},
|
|
|
|
set (value) {
|
2018-03-14 13:27:26 +01:00
|
|
|
this.$store.commit('TimelineSpace/NewTootModal/changeModal', value)
|
2018-03-12 17:42:47 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-13 00:41:03 +01:00
|
|
|
},
|
2018-03-13 02:04:07 +01:00
|
|
|
updated () {
|
|
|
|
if (this.newTootModal) {
|
2018-03-14 13:27:26 +01:00
|
|
|
this.$refs.status.focus()
|
2018-03-13 02:04:07 +01:00
|
|
|
}
|
|
|
|
},
|
2018-03-13 00:41:03 +01:00
|
|
|
methods: {
|
|
|
|
close () {
|
2018-03-14 13:27:26 +01:00
|
|
|
this.$store.commit('TimelineSpace/NewTootModal/changeModal', false)
|
2018-03-13 00:41:03 +01:00
|
|
|
},
|
|
|
|
toot () {
|
2018-03-14 13:27:26 +01:00
|
|
|
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'
|
|
|
|
})
|
|
|
|
}
|
2018-03-14 13:27:26 +01:00
|
|
|
this.$store.dispatch('TimelineSpace/NewTootModal/postToot', this.tootForm)
|
2018-03-13 00:41:03 +01:00
|
|
|
.then(() => {
|
2018-03-14 13:27:26 +01:00
|
|
|
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>
|
|
|
|
|
2018-03-14 09:14:47 +01:00
|
|
|
<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;
|
|
|
|
|
2018-03-14 13:27:26 +01:00
|
|
|
.status {
|
2018-03-12 17:42:47 +01:00
|
|
|
textarea {
|
2018-03-13 02:04:07 +01:00
|
|
|
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;
|
2018-03-13 02:04:07 +01:00
|
|
|
border-radius: 4px;
|
2018-03-12 17:42:47 +01:00
|
|
|
resize: none;
|
|
|
|
height: 120px;
|
2018-03-13 02:04:07 +01:00
|
|
|
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>
|