|
@@ -7,8 +7,8 @@
|
|
<span class='select_button_text'>Name of thread:</span>
|
|
<span class='select_button_text'>Name of thread:</span>
|
|
<fancy-input placeholder='Thread name' v-model='name' style='display: inline-block;'></fancy-input>
|
|
<fancy-input placeholder='Thread name' v-model='name' style='display: inline-block;'></fancy-input>
|
|
</div>
|
|
</div>
|
|
- <input-editor v-model='editor' :show='true' :hide-close='true' style='margin-top: 1rem'></input-editor>
|
|
|
|
- <button class='button button--green submit' @click='postThread'>Post thread</button>
|
|
|
|
|
|
+ <input-editor v-model='editor' :show='true' :hide-close='true' :error='errors.content' style='margin-top: 1rem'></input-editor>
|
|
|
|
+ <loading-button class='button--green submit' :loading='loading' @click='postThread'>Post thread</loading-button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -16,6 +16,7 @@
|
|
import InputEditor from '../InputEditor'
|
|
import InputEditor from '../InputEditor'
|
|
import FancyInput from '../FancyInput'
|
|
import FancyInput from '../FancyInput'
|
|
import SelectButton from '../SelectButton'
|
|
import SelectButton from '../SelectButton'
|
|
|
|
+ import LoadingButton from '../LoadingButton'
|
|
|
|
|
|
import AjaxErrorHandler from '../../assets/js/errorHandler'
|
|
import AjaxErrorHandler from '../../assets/js/errorHandler'
|
|
|
|
|
|
@@ -24,13 +25,15 @@
|
|
components: {
|
|
components: {
|
|
InputEditor,
|
|
InputEditor,
|
|
SelectButton,
|
|
SelectButton,
|
|
- FancyInput
|
|
|
|
|
|
+ FancyInput,
|
|
|
|
+ LoadingButton
|
|
},
|
|
},
|
|
data () {
|
|
data () {
|
|
return {
|
|
return {
|
|
selectedCategory: this.$store.state.category.selectedCategory,
|
|
selectedCategory: this.$store.state.category.selectedCategory,
|
|
editor: '',
|
|
editor: '',
|
|
name: '',
|
|
name: '',
|
|
|
|
+ loading: false,
|
|
|
|
|
|
errors: {
|
|
errors: {
|
|
content: '',
|
|
content: '',
|
|
@@ -45,6 +48,16 @@
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
postThread () {
|
|
postThread () {
|
|
|
|
+ if(!this.editor.trim().length) {
|
|
|
|
+ this.errors.content = 'Cannot be blank'
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.errors.content = ''
|
|
|
|
+ this.errors.name = ''
|
|
|
|
+
|
|
|
|
+ this.loading = true
|
|
|
|
+
|
|
this.axios.post('/api/v1/thread', {
|
|
this.axios.post('/api/v1/thread', {
|
|
name: this.name,
|
|
name: this.name,
|
|
category: this.selectedCategory
|
|
category: this.selectedCategory
|
|
@@ -54,8 +67,11 @@
|
|
content: this.editor
|
|
content: this.editor
|
|
})
|
|
})
|
|
}).then(res => {
|
|
}).then(res => {
|
|
|
|
+ this.loading = false
|
|
this.$router.push(`/thread/${res.data.Thread.slug}/${res.data.Thread.id}`)
|
|
this.$router.push(`/thread/${res.data.Thread.slug}/${res.data.Thread.id}`)
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
|
|
+ this.loading = false
|
|
|
|
+
|
|
AjaxErrorHandler(this.$store)(e, (error, errors) => {
|
|
AjaxErrorHandler(this.$store)(e, (error, errors) => {
|
|
let param = error.parameter
|
|
let param = error.parameter
|
|
|
|
|