Insert new content block at correct position
This commit is contained in:
parent
872eb6efa5
commit
35a8184cd1
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="add-content">
|
<div class="add-content">
|
||||||
<a class="add-content__button" v-on:click="showModal">
|
<a class="add-content__button" v-on:click="addContentBlock">
|
||||||
<add-pointer class="add-content__icon"></add-pointer>
|
<add-pointer class="add-content__icon"></add-pointer>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -10,13 +10,18 @@
|
||||||
import AddPointer from '@/components/icons/AddPointer';
|
import AddPointer from '@/components/icons/AddPointer';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
props: ['after', 'parent'],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
AddPointer
|
AddPointer
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
showModal() {
|
addContentBlock() {
|
||||||
this.$store.dispatch('showModal');
|
this.$store.dispatch('addContentBlock', {
|
||||||
|
after: this.after,
|
||||||
|
parent: this.parent
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,24 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="chapter">
|
<div class="chapter">
|
||||||
<h3>{{chapter.title}}</h3>
|
<h3>{{chapter.title}} {{chapter.id}}</h3>
|
||||||
|
|
||||||
|
<add-content-block-button :parent="chapter.id"></add-content-block-button>
|
||||||
|
|
||||||
<content-block :contentBlock="contentBlock" :key="contentBlock.id" v-for="contentBlock in chapter.contentBlocks">
|
<content-block :contentBlock="contentBlock" :key="contentBlock.id" v-for="contentBlock in chapter.contentBlocks">
|
||||||
</content-block>
|
</content-block>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ContentBlock from '@/components/ContentBlock.vue';
|
import ContentBlock from '@/components/ContentBlock';
|
||||||
|
import AddContentBlockButton from '@/components/AddContentBlockButton';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['chapter'],
|
props: ['chapter'],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
ContentBlock
|
ContentBlock,
|
||||||
|
AddContentBlockButton
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="content-block__container">
|
<div class="content-block__container">
|
||||||
<add-content-block-button></add-content-block-button>
|
|
||||||
|
|
||||||
<div class="content-block" :class="specialClass">
|
<div class="content-block" :class="specialClass">
|
||||||
<div class="content-block__visibility-button">
|
<div class="content-block__visibility-button">
|
||||||
<eye-icon class="content-block__visibility-icon"></eye-icon>
|
<eye-icon class="content-block__visibility-icon"></eye-icon>
|
||||||
|
|
@ -17,6 +15,9 @@
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<add-content-block-button :after="contentBlock.id"></add-content-block-button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,12 @@
|
||||||
type: type
|
type: type
|
||||||
};
|
};
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
case 'text_block':
|
||||||
|
el = {
|
||||||
|
...el,
|
||||||
|
text: ''
|
||||||
|
};
|
||||||
|
break;
|
||||||
case 'link':
|
case 'link':
|
||||||
el = {
|
el = {
|
||||||
...el,
|
...el,
|
||||||
|
|
@ -123,6 +129,7 @@
|
||||||
this.elements.splice(index, 1, el);
|
this.elements.splice(index, 1, el);
|
||||||
},
|
},
|
||||||
hideModal() {
|
hideModal() {
|
||||||
|
this.$store.dispatch('resetContentBlock');
|
||||||
this.$store.dispatch('hideModal');
|
this.$store.dispatch('hideModal');
|
||||||
},
|
},
|
||||||
saveContentBlock() {
|
saveContentBlock() {
|
||||||
|
|
@ -134,12 +141,13 @@
|
||||||
title: this.title,
|
title: this.title,
|
||||||
contents: this.elements
|
contents: this.elements
|
||||||
},
|
},
|
||||||
after: 'Q29udGVudEJsb2NrTm9kZToxOQ=='
|
after: this.$store.state.contentBlockPosition.after,
|
||||||
|
parent: this.$store.state.contentBlockPosition.parent
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
update: () => {
|
update: () => {
|
||||||
this.$store.dispatch('updateContentBlocks');
|
this.$store.dispatch('updateContentBlocks');
|
||||||
this.$store.dispatch('hideModal');
|
this.hideModal();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ export default new Vuex.Store({
|
||||||
specialContainerClass: '',
|
specialContainerClass: '',
|
||||||
showFilter: true,
|
showFilter: true,
|
||||||
showModal: false,
|
showModal: false,
|
||||||
|
contentBlockPosition: {},
|
||||||
scrollPosition: 0,
|
scrollPosition: 0,
|
||||||
moduleSlug: 'mein-neues-umfeld',
|
moduleSlug: 'mein-neues-umfeld',
|
||||||
updateContentBlocks: false
|
updateContentBlocks: false
|
||||||
|
|
@ -27,15 +28,22 @@ export default new Vuex.Store({
|
||||||
setSpecialContainerClass({commit}, payload) {
|
setSpecialContainerClass({commit}, payload) {
|
||||||
commit('setSpecialContainerClass', payload);
|
commit('setSpecialContainerClass', payload);
|
||||||
},
|
},
|
||||||
hideModal({commit, state}) {
|
hideModal({commit}) {
|
||||||
document.body.classList.remove('no-scroll'); // won't get at the body any other way
|
document.body.classList.remove('no-scroll'); // won't get at the body any other way
|
||||||
commit('setModal', false);
|
commit('setModal', false);
|
||||||
},
|
},
|
||||||
|
resetContentBlock({commit}) {
|
||||||
|
commit('setContentBlockPosition', {});
|
||||||
|
},
|
||||||
|
addContentBlock({commit, dispatch}, payload) {
|
||||||
|
commit('setContentBlockPosition', payload);
|
||||||
|
dispatch('showModal');
|
||||||
|
},
|
||||||
showModal({commit}) {
|
showModal({commit}) {
|
||||||
document.body.classList.add('no-scroll'); // won't get at the body any other way
|
document.body.classList.add('no-scroll'); // won't get at the body any other way
|
||||||
commit('setModal', true);
|
commit('setModal', true);
|
||||||
},
|
},
|
||||||
updateContentBlocks({commit, dispatch}) {
|
updateContentBlocks({commit}) {
|
||||||
commit('updateContentBlocks', true);
|
commit('updateContentBlocks', true);
|
||||||
},
|
},
|
||||||
resetUpdateContentBlocksFlag({commit}) {
|
resetUpdateContentBlocksFlag({commit}) {
|
||||||
|
|
@ -61,6 +69,9 @@ export default new Vuex.Store({
|
||||||
},
|
},
|
||||||
updateContentBlocks(state, payload) {
|
updateContentBlocks(state, payload) {
|
||||||
state.updateContentBlocks = payload;
|
state.updateContentBlocks = payload;
|
||||||
|
},
|
||||||
|
setContentBlockPosition(state, payload) {
|
||||||
|
state.contentBlockPosition = payload;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue