From 9fe3b379a897374ce06d39d12acadfa213c59f4c Mon Sep 17 00:00:00 2001 From: szymon Date: Mon, 1 Jul 2024 12:23:03 +0200 Subject: [PATCH] allegro copy descritpion --- src/components/MagicoPagebuilder.vue | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/components/MagicoPagebuilder.vue b/src/components/MagicoPagebuilder.vue index baa5aa5..17a2187 100644 --- a/src/components/MagicoPagebuilder.vue +++ b/src/components/MagicoPagebuilder.vue @@ -46,6 +46,17 @@ >Zapisz jako szablon +
  • + Wklej opis Allegro +
  • @@ -199,6 +210,11 @@ export default { ] } }, + computed: { + descriptionAllegro: function(){ + return localStorage.getItem('description_clipboard') + } + }, created: function () { if (this.name) this.namex = this.name else this.namxe = 'body' @@ -248,6 +264,42 @@ export default { this.pageType.body = this.pageType.source this.changeBody() }, + pasteAllegro: function(){ + let sections = this.descriptionAllegro; + try { + sections = JSON.parse(sections); + } catch (e) { + if (e instanceof SyntaxError) { + sections = [{ name: 'Tekst', cols: [{ type: 'text', value: sections, size: 12 }] }]; + } + } + + const pagebuilder = sections.map(item => { + const columns = []; + + if (item.cols && Array.isArray(item.cols)) { + item.cols.forEach(col => { + const column = { + name: 'col-md-' + col.size, + items: [ + { + name: (col.type === 'img' ? 'core_section_image' : 'core_section_textarea'), + text: col.value, + } + ] + }; + if (col.type === 'img' && col.figcaption) { + column.items[0]['figcaption'] = col.figcaption; + } + columns.push(column); + }); + } + + return { columns }; + }); + + return this.comps = pagebuilder; + }, changeBody() { var t = this var value = this.pageType.body