update model value

This commit is contained in:
2024-07-01 12:36:49 +02:00
parent 6d9857ab59
commit de80d14c64
2 changed files with 33 additions and 39 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "magico-pagebuilder", "name": "magico-pagebuilder",
"version": "0.0.4", "version": "0.0.5",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View File

@@ -27,7 +27,7 @@
<li> <li>
<a <a
@click.prevent=" @click.prevent="
modalLoad = !modalLoad; modalLoad = !modalLoad
pageType = { name: null } pageType = { name: null }
" "
class="dropdown-item" class="dropdown-item"
@@ -38,7 +38,7 @@
<li> <li>
<a <a
@click.prevent=" @click.prevent="
modalSave = !modalSave; modalSave = !modalSave
pageType = { name: null } pageType = { name: null }
" "
class="dropdown-item" class="dropdown-item"
@@ -47,13 +47,7 @@
> >
</li> </li>
<li v-if="descriptionAllegro"> <li v-if="descriptionAllegro">
<a <a @click.prevent="pasteAllegro" class="dropdown-item" href="#"
@click.prevent="
pasteAllegro
"
class="dropdown-item"
href="#"
>Wklej opis <i>Allegro</i></a >Wklej opis <i>Allegro</i></a
> >
</li> </li>
@@ -71,7 +65,7 @@
@start="drag = true" @start="drag = true"
item-key="d" item-key="d"
@end=" @end="
drag = false; drag = false
onChange() onChange()
" "
> >
@@ -147,7 +141,7 @@
<!-- <textarea style="display:none" :name="namex">{{ comps }}</textarea> --><button <!-- <textarea style="display:none" :name="namex">{{ comps }}</textarea> --><button
class="btn btn-block btn-primary mt-4" class="btn btn-block btn-primary mt-4"
@click.prevent=" @click.prevent="
modalAddSection = !modalAddSection; modalAddSection = !modalAddSection
optionx = false optionx = false
" "
> >
@@ -211,7 +205,7 @@ export default {
} }
}, },
computed: { computed: {
descriptionAllegro: function(){ descriptionAllegro: function () {
return localStorage.getItem('description_clipboard') return localStorage.getItem('description_clipboard')
} }
}, },
@@ -264,42 +258,42 @@ export default {
this.pageType.body = this.pageType.source this.pageType.body = this.pageType.source
this.changeBody() this.changeBody()
}, },
pasteAllegro: function(){ pasteAllegro: function () {
let sections = this.descriptionAllegro; let sections = this.descriptionAllegro
try { try {
sections = JSON.parse(sections); sections = JSON.parse(sections)
} catch (e) { } catch (e) {
if (e instanceof SyntaxError) { if (e instanceof SyntaxError) {
sections = [{ name: 'Tekst', cols: [{ type: 'text', value: sections, size: 12 }] }]; sections = [{ name: 'Tekst', cols: [{ type: 'text', value: sections, size: 12 }] }]
} }
} }
const pagebuilder = sections.map(item => { const pagebuilder = sections.map((item) => {
const columns = []; const columns = []
if (item.cols && Array.isArray(item.cols)) { if (item.cols && Array.isArray(item.cols)) {
item.cols.forEach(col => { item.cols.forEach((col) => {
const column = { const column = {
type: 'container',
type:"container", items: [
items: [ {
{ name: col.type === 'img' ? 'core_section_image' : 'core_section_textarea',
name: (col.type === 'img' ? 'core_section_image' : 'core_section_textarea'), text: col.value
text: col.value,
}
]
};
if (col.type === 'img' && col.figcaption) {
column.items[0]['figcaption'] = col.figcaption;
} }
columns.push(column); ]
}); }
if (col.type === 'img' && col.figcaption) {
column.items[0]['figcaption'] = col.figcaption
}
columns.push(column)
})
} }
return { columns,label:'',name:'' }; return { columns, label: '', name: '' }
}); })
return this.comps = pagebuilder; this.comps = pagebuilder
this.onChange()
}, },
changeBody() { changeBody() {
var t = this var t = this