esoolved comments @tirokk

This commit is contained in:
ogerly 2019-07-24 15:35:08 +02:00
parent 063479610e
commit 77f45c1508

View File

@ -10,7 +10,7 @@
/>
</hc-teaser-image>
<ds-input model="title" class="post-title" placeholder="Title" name="title" autofocus />
<small class="smallTag">{{ form.title.length }}/64</small>
<small class="smallTag">{{ form.title.length }}/{{formSchema.title.max }}</small>
<no-ssr>
<hc-editor
:users="users"
@ -18,7 +18,7 @@
:value="form.content"
@input="updateEditorContent"
/>
<small class="smallTag">{{ form.contentLength }}/2000</small>
<small class="smallTag">{{ form.contentLength }}/{{content_max }}</small>
</no-ssr>
<ds-space margin-bottom="xxx-large" />
<hc-categories-select
@ -97,13 +97,26 @@ export default {
},
formSchema: {
title: { required: true, min: 3, max: 64 },
content: { required: true, min: 3, max: 2007 },
content: [
/*{
validator(rule, value, callback, source, options) {
var errors = []
if (source.password !== value) {
errors.push(new Error(passwordMismatchMessage))
}
callback(errors)
},
},*/
{ required: true, }
],
},
id: null,
loading: false,
disabled: true,
slug: null,
users: [],
content_min: 3,
content_max: 2000,
hashtags: [],
}
@ -179,12 +192,18 @@ export default {
})
},
updateEditorContent(value) {
var n = 0
this.$refs.contributionForm.update('content', value)
// disable form
this.disabled = true
n = value.replace(/<\/?[^>]+(>|$)/gm, '').length
this.form.contentLength = n
if (n > this.formSchema.content.min && this.formSchema.content.max > n) {
// TODO: Do smth????? what is happening
this.$refs.contributionForm.update('content', value)
// filter HTML out of content value
const str = value.replace(/<\/?[^>]+(>|$)/gm, '')
// Set counter length of text
this.form.contentLength = str.length
//Enable save button if requirements are met
if ( str.length >= this.content_min &&
str.length <= this.content_max)
{
this.disabled = false
}
},