Add form validation for new content block
This commit is contained in:
parent
639fa7665c
commit
6347fa07e1
|
|
@ -2,23 +2,35 @@
|
||||||
<div class="content-block-title-input">
|
<div class="content-block-title-input">
|
||||||
<input placeholder="Titel für Inhaltsblock erfassen"
|
<input placeholder="Titel für Inhaltsblock erfassen"
|
||||||
class="content-block-title-input__inputfield skillbox-input"
|
class="content-block-title-input__inputfield skillbox-input"
|
||||||
|
:class="{'skillbox-input--error': error}"
|
||||||
:value="title"
|
:value="title"
|
||||||
v-on:input="$emit('update-title', $event.target.value)">
|
v-on:input="$emit('update-title', $event.target.value)">
|
||||||
|
<div class="content-block-title-input__error" v-if="error">
|
||||||
|
Für Inhaltsblöcke muss zwingend ein Titel erfasst werden.
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: ['title']
|
props: ['title', 'error']
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import "@/styles/_variables.scss";
|
@import "@/styles/_variables.scss";
|
||||||
|
@import "@/styles/_functions.scss";
|
||||||
|
|
||||||
.content-block-title-input {
|
.content-block-title-input {
|
||||||
&__inputfield {
|
&__inputfield {
|
||||||
width: $modal-input-width;
|
width: $modal-input-width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__error {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: toRem(14px);
|
||||||
|
color: $color-accent-3-dark;
|
||||||
|
padding: 10px 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<modal>
|
<modal>
|
||||||
<content-block-title-input slot="header" v-on:update-title="updateTitle" :title="title"></content-block-title-input>
|
<content-block-title-input slot="header" v-on:update-title="updateTitle" :title="title" :error="error"></content-block-title-input>
|
||||||
<add-content-element class="new-content-block-wizard__add"
|
<add-content-element class="new-content-block-wizard__add"
|
||||||
v-on:add-element="addElement"
|
v-on:add-element="addElement"
|
||||||
:index="-1"
|
:index="-1"
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
return 'link-form';
|
return 'link-form';
|
||||||
case 'video_block':
|
case 'video_block':
|
||||||
return 'video-form';
|
return 'video-form';
|
||||||
case 'image':
|
case 'image_block':
|
||||||
return 'image-form';
|
return 'image-form';
|
||||||
case 'text_block':
|
case 'text_block':
|
||||||
return 'text-form';
|
return 'text-form';
|
||||||
|
|
@ -113,6 +113,7 @@
|
||||||
},
|
},
|
||||||
updateTitle(title) {
|
updateTitle(title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
this.error = false;
|
||||||
},
|
},
|
||||||
changeType(index, type) {
|
changeType(index, type) {
|
||||||
let el = {
|
let el = {
|
||||||
|
|
@ -153,13 +154,17 @@
|
||||||
this.$store.dispatch('hideModal');
|
this.$store.dispatch('hideModal');
|
||||||
},
|
},
|
||||||
saveContentBlock() {
|
saveContentBlock() {
|
||||||
|
if (!this.title) {
|
||||||
|
this.error = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
this.$apollo.mutate({
|
this.$apollo.mutate({
|
||||||
mutation: NEW_CONTENT_BLOCK_MUTATION,
|
mutation: NEW_CONTENT_BLOCK_MUTATION,
|
||||||
variables: {
|
variables: {
|
||||||
input: {
|
input: {
|
||||||
contentBlock: {
|
contentBlock: {
|
||||||
title: this.title,
|
title: this.title,
|
||||||
contents: this.elements
|
contents: this.elements.filter(value => Object.keys(value).length > 0)
|
||||||
},
|
},
|
||||||
after: this.$store.state.contentBlockPosition.after,
|
after: this.$store.state.contentBlockPosition.after,
|
||||||
parent: this.$store.state.contentBlockPosition.parent
|
parent: this.$store.state.contentBlockPosition.parent
|
||||||
|
|
@ -189,7 +194,8 @@
|
||||||
// type: 'video',
|
// type: 'video',
|
||||||
// url: 'https://vimeo.com/267384185'
|
// url: 'https://vimeo.com/267384185'
|
||||||
// }
|
// }
|
||||||
]
|
],
|
||||||
|
error: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
<video-icon class="content-block-element-chooser-widget__link-icon"></video-icon>
|
<video-icon class="content-block-element-chooser-widget__link-icon"></video-icon>
|
||||||
<div class="content-block-element-chooser-widget__link-title">Video</div>
|
<div class="content-block-element-chooser-widget__link-title">Video</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content-block-element-chooser-widget__link" v-on:click="$emit('change-type', index, 'image')">
|
<div class="content-block-element-chooser-widget__link" v-on:click="$emit('change-type', index, 'image_block')">
|
||||||
<image-icon class="content-block-element-chooser-widget__link-icon"></image-icon>
|
<image-icon class="content-block-element-chooser-widget__link-icon"></image-icon>
|
||||||
<div class="content-block-element-chooser-widget__link-title">Bild</div>
|
<div class="content-block-element-chooser-widget__link-title">Bild</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,10 @@
|
||||||
|
|
||||||
.skillbox-input {
|
.skillbox-input {
|
||||||
@include inputstyle;
|
@include inputstyle;
|
||||||
|
|
||||||
|
&--error {
|
||||||
|
border-color: $color-accent-3-dark;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.skillbox-textarea {
|
.skillbox-textarea {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue