Add modal save action

This commit is contained in:
Ramon Wenger 2018-09-06 16:48:37 +02:00
parent ab699291c0
commit e4c576d26c
3 changed files with 37 additions and 8 deletions

View File

@ -9,7 +9,7 @@
</div> </div>
<div class="modal__footer"> <div class="modal__footer">
<slot name="footer"> <slot name="footer">
<a class="button button--active">Speichern</a> <!--<a class="button button&#45;&#45;active">Speichern</a>-->
<a class="button" v-on:click="hideModal">Abbrechen</a> <a class="button" v-on:click="hideModal">Abbrechen</a>
</slot> </slot>
</div> </div>

View File

@ -1,6 +1,9 @@
<template> <template>
<modal> <modal>
<content-block-title-input slot="header"></content-block-title-input> <content-block-title-input slot="header"></content-block-title-input>
<!--<div>-->
<!--<span v-for="(e, i) in elements" :key="i">{{e.text}}</span>-->
<!--</div>-->
<div v-for="(element, index) in elements" :key="index" class="new-content-block-wizard__element"> <div v-for="(element, index) in elements" :key="index" class="new-content-block-wizard__element">
<component <component
class="new-content-block-wizard__element-component" class="new-content-block-wizard__element-component"
@ -10,6 +13,7 @@
v-on:change-type="changeType" v-on:change-type="changeType"
v-on:link-change-url="changeLinkUrl" v-on:link-change-url="changeLinkUrl"
v-on:link-change-text="changeLinkText" v-on:link-change-text="changeLinkText"
v-on:video-change-url="changeVideoUrl"
></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'"
@ -21,6 +25,11 @@
:index="index" :index="index"
></add-content-element> ></add-content-element>
</div> </div>
<div slot="footer">
<a class="button" v-on:click="saveContentBlock">Speichern</a>
<a class="button" v-on:click="hideModal">Abbrechen</a>
</div>
</modal> </modal>
</template> </template>
@ -70,17 +79,20 @@
} }
return 'content-block-chooser-widget' return 'content-block-chooser-widget'
}, },
changeLinkUrl(value, index) { updateProperty(value, index, key) {
this.elements.splice(index, 1, { this.elements.splice(index, 1, {
...this.elements[index], ...this.elements[index],
url: value [key]: value
}); });
}, },
changeLinkUrl(value, index) {
this.updateProperty(value, index, 'url')
},
changeLinkText(value, index) { changeLinkText(value, index) {
this.elements.splice(index, 1, { this.updateProperty(value, index, 'text')
...this.elements[index], },
text: value changeVideoUrl(value, index) {
}); this.updateProperty(value, index, 'url')
}, },
removeElement(index) { removeElement(index) {
this.elements.splice(index, 1); this.elements.splice(index, 1);
@ -103,6 +115,14 @@
} }
this.elements.splice(index, 1, el); this.elements.splice(index, 1, el);
},
hideModal() {
this.$store.dispatch('hideModal');
},
saveContentBlock() {
this.$store.dispatch('saveContentBlock', {
elements: this.elements
});
} }
}, },

View File

@ -10,7 +10,8 @@ export default new Vuex.Store({
specialContainerClass: '', specialContainerClass: '',
showFilter: true, showFilter: true,
showModal: false, showModal: false,
scrollPosition: 0 scrollPosition: 0,
newContentBlock: {}
}, },
getters: {}, getters: {},
@ -32,6 +33,11 @@ export default new Vuex.Store({
showModal({commit}) { showModal({commit}) {
document.body.classList.add('no-scroll'); document.body.classList.add('no-scroll');
commit('setModal', true); commit('setModal', true);
},
saveContentBlock({commit}, payload){
console.log(payload);
commit('setNewContentBlock', payload);
commit('setModal', false);
} }
}, },
@ -47,6 +53,9 @@ export default new Vuex.Store({
}, },
setScrollPosition(state, payload) { setScrollPosition(state, payload) {
state.scrollPosition = payload; state.scrollPosition = payload;
},
setNewContentBlock(state, payload) {
state.newContentBlock = payload;
} }
} }
}) })