Make link form component reactive
This commit is contained in:
parent
48e88ddc45
commit
ab699291c0
|
|
@ -8,6 +8,8 @@
|
||||||
:class="{'new-content-block-wizard__chooser': type(element) === 'content-block-chooser-widget'}"
|
:class="{'new-content-block-wizard__chooser': type(element) === 'content-block-chooser-widget'}"
|
||||||
:element="element" :index="index"
|
:element="element" :index="index"
|
||||||
v-on:change-type="changeType"
|
v-on:change-type="changeType"
|
||||||
|
v-on:link-change-url="changeLinkUrl"
|
||||||
|
v-on:link-change-text="changeLinkText"
|
||||||
></component>
|
></component>
|
||||||
<a class="new-content-block-wizard__remove" v-on:click="removeElement(index)">
|
<a class="new-content-block-wizard__remove" v-on:click="removeElement(index)">
|
||||||
<trash-icon v-if="type(element) !== 'content-block-chooser-widget'"
|
<trash-icon v-if="type(element) !== 'content-block-chooser-widget'"
|
||||||
|
|
@ -68,6 +70,18 @@
|
||||||
}
|
}
|
||||||
return 'content-block-chooser-widget'
|
return 'content-block-chooser-widget'
|
||||||
},
|
},
|
||||||
|
changeLinkUrl(value, index) {
|
||||||
|
this.elements.splice(index, 1, {
|
||||||
|
...this.elements[index],
|
||||||
|
url: value
|
||||||
|
});
|
||||||
|
},
|
||||||
|
changeLinkText(value, index) {
|
||||||
|
this.elements.splice(index, 1, {
|
||||||
|
...this.elements[index],
|
||||||
|
text: value
|
||||||
|
});
|
||||||
|
},
|
||||||
removeElement(index) {
|
removeElement(index) {
|
||||||
this.elements.splice(index, 1);
|
this.elements.splice(index, 1);
|
||||||
},
|
},
|
||||||
|
|
@ -75,7 +89,20 @@
|
||||||
this.elements.splice(index + 1, 0, {})
|
this.elements.splice(index + 1, 0, {})
|
||||||
},
|
},
|
||||||
changeType(index, type) {
|
changeType(index, type) {
|
||||||
this.elements.splice(index, 1, {type: type});
|
let el = {
|
||||||
|
type: type
|
||||||
|
};
|
||||||
|
switch (type) {
|
||||||
|
case 'link':
|
||||||
|
el = {
|
||||||
|
...el,
|
||||||
|
text: '',
|
||||||
|
url: ''
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.elements.splice(index, 1, el);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,27 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="link-form">
|
<div class="link-form">
|
||||||
<div class="link-form__property">
|
<input placeholder="Name erfassen..." class="link-form__text skillbox-input" :value="text" v-on:input="$emit('link-change-text', $event.target.value, index)">
|
||||||
<input placeholder="Name erfassen..." class="link-form__input skillbox-input">
|
|
||||||
</div>
|
<input placeholder="URL einfügen..." class="link-form__url skillbox-input" :value="url" v-on:input="$emit('link-change-url', $event.target.value, index)">
|
||||||
<div class="link-form__property">
|
|
||||||
<input placeholder="URL einfügen..." class="link-form__input skillbox-input">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
export default {
|
||||||
|
props: ['text', 'url', 'index']
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import "@/styles/_variables.scss";
|
@import "@/styles/_variables.scss";
|
||||||
|
|
||||||
.link-form {
|
.link-form {
|
||||||
&__property {
|
display: grid;
|
||||||
display: flex;
|
grid-auto-rows: auto;
|
||||||
justify-content: space-between;
|
grid-row-gap: 11px;
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 11px;
|
&__text,
|
||||||
}
|
&__url {
|
||||||
&__input {
|
|
||||||
width: $modal-input-width;
|
width: $modal-input-width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue