Skip to content

Commit

Permalink
Merge pull request #254 from PrestaSafe/develop
Browse files Browse the repository at this point in the history
3.1.1
  • Loading branch information
PrestaSafe authored Sep 10, 2024
2 parents a7aa3d8 + f5a3d04 commit bd8fbd7
Show file tree
Hide file tree
Showing 20 changed files with 93 additions and 48 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

![Téléchargements](https://img.shields.io/github/downloads/PrestaSafe/prettyblocks/total)

Le premier page builder open conçu pour PrestaShop !
Le premier page builder open source conçu pour PrestaShop !

La documentation technique est disponible ici : [https://prettyblocks.io/](https://prettyblocks.io/):

Expand Down
1 change: 0 additions & 1 deletion _dev/src/components/Block.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const AddOnZOne = async (code) => {
ajax_token: security_app.ajax_token,
};
let url = ajax_urls.block_action_urls;
console.log(url, params)
let data = await HttpClient.get(url, params);
prettyBlocksContext.emit("toggleModal");
Expand Down
2 changes: 1 addition & 1 deletion _dev/src/components/LeftPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const deleteAllBlocks = async () => {
if (response.success) {
toaster.show(response.message)
prettyBlocksContext.reloadIframe()
window.location.reload()
}
})
.catch(error => console.error(error));
Expand Down
7 changes: 6 additions & 1 deletion _dev/src/components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ onBeforeUnmount(() => {
})
/**
* reload blocks after save settings
*/
prettyBlocksContext.on('afterSaveSettings', () => {
getBlocksAvailable()
})
const getBlocksAvailable = () => {
HttpClient.get(ajax_urls.blocks_available)
Expand Down
1 change: 1 addition & 0 deletions _dev/src/components/PanelThemeSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ HttpClient.post(ajax_urls.state, params)
if (data.message) {
prettyBlocksContext.displayMessage(data.message)
prettyBlocksContext.reloadIframe()
prettyBlocksContext.emit('afterSaveSettings')
}
})
.catch(error => console.error(error));
Expand Down
3 changes: 1 addition & 2 deletions _dev/src/scripts/eventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ export const eventHandler = async (event) => {
current_url: custom_url
}
});
prettyBlocksContext.changeUrl(custom_url)
if(force_reload) {
window.location.reload()
}else{
prettyBlocksContext.changeUrl(custom_url)
}
}

Expand Down
6 changes: 6 additions & 0 deletions _dev/src/store/pinia.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ export const usePrettyBlocksContext = defineStore('prettyBlocksContext', {
},
pushUrl(url) {
const currentUrl = new URL(window.location.href);

// Remove 'id' and 'endpoint' parameters if they exist
currentUrl.searchParams.delete('id');
currentUrl.searchParams.delete('endpoint');

currentUrl.searchParams.set('startup_url', this.updateFilteredURL(url));
window.history.replaceState({}, '', currentUrl.toString());
},
Expand All @@ -208,6 +213,7 @@ export const usePrettyBlocksContext = defineStore('prettyBlocksContext', {
} else if (!url.includes('prettyblocks')) {
url += '&prettyblocks=1';
}

return url;
},
reloadIframe(currentSrc = false) {
Expand Down
22 changes: 11 additions & 11 deletions _dev/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.24.8.tgz"
integrity sha512-WzfbgXOkGzZiXXCqk43kKwZjzwx4oulxZi3nq2TYL9mOjQv6kYwul9mz6ID36njuL7Xkp6nJEfok848Zj10j/w==

"@esbuild/darwin-arm64@0.21.5":
"@esbuild/linux-x64@0.21.5":
version "0.21.5"
resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz"
integrity sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==
resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz"
integrity sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==

"@headlessui/vue@^1.7.19":
version "1.7.22"
Expand Down Expand Up @@ -107,10 +107,15 @@
resolved "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz"
integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==

"@rollup/rollup-darwin-arm64@4.19.0":
"@rollup/rollup-linux-x64-gnu@4.19.0":
version "4.19.0"
resolved "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.19.0.tgz"
integrity sha512-emvKHL4B15x6nlNTBMtIaC9tLPRpeA5jMvRLXVbl/W9Ie7HhkrE7KQjvgS9uxgatL1HmHWDXk5TTS4IaNJxbAA==
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.19.0.tgz"
integrity sha512-HBndjQLP8OsdJNSxpNIN0einbDmRFg9+UQeZV1eiYupIRuZsDEoeGU43NQsS34Pp166DtwQOnpcbV/zQxM+rWA==

"@rollup/[email protected]":
version "4.19.0"
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.19.0.tgz"
integrity sha512-HxfbvfCKJe/RMYJJn0a12eiOI9OOtAUF4G6ozrFUK95BNyoJaSiBjIOHjZskTUffUrB84IPKkFG9H9nEvJGW6A==

"@swc/helpers@^0.2.13":
version "0.2.14"
Expand Down Expand Up @@ -698,11 +703,6 @@ fs.realpath@^1.0.0:
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

fsevents@~2.3.2, fsevents@~2.3.3:
version "2.3.3"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==

function-bind@^1.1.2:
version "1.1.2"
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz"
Expand Down
17 changes: 17 additions & 0 deletions classes/PrettyBlocksModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -970,8 +970,10 @@ public static function copyZone($zone_name, $zone_name_to_paste, $id_lang, $id_s
$query->where('zone_name = \'' . $zone_name . '\'');
$query->where('id_lang = ' . (int) $id_lang);
$query->where('id_shop = ' . (int) $id_shop);
$query->orderBy('position ASC');
$results = $db->executeS($query);
$result = true;
$lastPosition = self::getLastPosition($zone_name, $id_lang, $id_shop);

foreach ($results as $row) {
$model = new PrettyBlocksModel(null, $id_lang, $id_shop);
Expand All @@ -985,6 +987,8 @@ public static function copyZone($zone_name, $zone_name_to_paste, $id_lang, $id_s
$model->instance_id = $row['instance_id'];
$model->id_shop = (int) $id_shop;
$model->id_lang = (int) $id_lang;
$model->position = $row['position'] + $lastPosition;
++$lastPosition;
if (!$model->save()) {
$errors[] = $model;
}
Expand All @@ -993,6 +997,19 @@ public static function copyZone($zone_name, $zone_name_to_paste, $id_lang, $id_s
return $errors;
}

public static function getLastPosition($zone_name, $id_lang, $id_shop)
{
$db = Db::getInstance();
$query = new DbQuery();
$query->select('MAX(position)')
->from('prettyblocks')
->where('zone_name = \'' . $zone_name . '\'')
->where('id_lang = ' . (int) $id_lang)
->where('id_shop = ' . (int) $id_shop);

return (int) $db->getValue($query);
}

/**
* deleteBlocksFromZone
* delete all blocks from a zone
Expand Down
10 changes: 4 additions & 6 deletions prettyblocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function __construct()
{
$this->name = 'prettyblocks';
$this->tab = 'administration';
$this->version = '3.1.0';
$this->version = '3.1.1';
$this->author = 'PrestaSafe';
$this->need_instance = 1;
$this->js_path = $this->_path . 'views/js/';
Expand Down Expand Up @@ -283,7 +283,6 @@ public function hookdisplayBackOfficeHeader($params)
$this->context->controller->addJS($this->_path . 'views/js/back.js');
}
$this->context->controller->addCSS($this->_path . 'views/css/back.css');

}

public function install()
Expand Down Expand Up @@ -443,7 +442,8 @@ public function hookdisplayHeader($params)
// todo register css and js on iframe only from Hook
}
// load default blocks styles
if (!TplSettings::getSettings('remove_default_blocks')) {

if (!TplSettings::getSettings('remove_default_blocks', false)) {
$this->context->controller->registerStylesheet(
'tiny-slider-css',
'https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.4/tiny-slider.css',
Expand Down Expand Up @@ -677,7 +677,6 @@ public function hookActionRegisterThemeSettings()
'description' => $this->l('Remove default blocks (if you using yours custom blocks)'), // description to display
'tab' => 'Settings',
'default' => false, // default value (Boolean)
'private' => true,
],
];
}
Expand All @@ -694,8 +693,7 @@ public function hookActionRegisterBlock($params)
new PrettyBlocksCmsContentBlock($this),
new PrettyBlocksCategoryDescriptionBlock($this),
];

if (!TplSettings::getSettings('remove_default_blocks')) {
if (!TplSettings::getSettings('remove_default_blocks', false)) {
$defaultsBlocks[] = new PrettyBlocksTinySlider($this);
$defaultsBlocks[] = new PrettyBlocksCustomImage($this);
$defaultsBlocks[] = new PrettyBlocksFAQ($this);
Expand Down
2 changes: 1 addition & 1 deletion views/css/_dev/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@
left: 50%;
right: 50%;
transform: translateX(-50%);
}
}
2 changes: 1 addition & 1 deletion views/css/dist/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1652,4 +1652,4 @@
paint-order: markers;
}
}
}
}
1 change: 1 addition & 0 deletions views/css/iframe.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
border-radius: 4px;
}


/* [data-prettyblocks-zone].ondrag{
background-color: #646cff;
border: 1px solid #646cff;
Expand Down
10 changes: 7 additions & 3 deletions views/js/build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9092,10 +9092,11 @@ This will fail in production.`);
current_url: custom_url
}
});
console.log("changeUrl", custom_url);
console.log("force_reload", force_reload);
prettyBlocksContext.changeUrl(custom_url);
if (force_reload) {
window.location.reload();
} else {
prettyBlocksContext.changeUrl(custom_url);
}
}
if (event.data.type == "updateTitleComponent") {
Expand Down Expand Up @@ -9630,6 +9631,7 @@ This will fail in production.`);
this.sendPrettyBlocksEvents("getContext");
this.sendPrettyBlocksEvents("getZones");
this.hideLoader();
this.emit("iframeLoaded");
}, 100);
});
},
Expand All @@ -9644,6 +9646,7 @@ This will fail in production.`);
this.pushUrl(url);
this.showLoader();
this.setIframe();
this.emit("urlChanged", url);
},
showLoader() {
this.$patch((state) => {
Expand All @@ -9657,6 +9660,8 @@ This will fail in production.`);
},
pushUrl(url) {
const currentUrl = new URL(window.location.href);
currentUrl.searchParams.delete("id");
currentUrl.searchParams.delete("endpoint");
currentUrl.searchParams.set("startup_url", this.updateFilteredURL(url));
window.history.replaceState({}, "", currentUrl.toString());
},
Expand All @@ -9677,7 +9682,6 @@ This will fail in production.`);
if (currentSrc === false) {
currentSrc = url;
}
console.log("currentSrc", currentSrc);
this.iframe.domElement.src = "";
setTimeout(() => {
this.iframe.domElement.src = currentSrc;
Expand Down
27 changes: 19 additions & 8 deletions views/js/front.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
document.addEventListener('DOMContentLoaded', function () {
if (document.querySelectorAll('.prettyblocks-tns').length > 0) {
var sliders = document.querySelectorAll('.prettyblocks-tns');

sliders.forEach(function (slider) {
tns({
container: slider,
items: 1,
slideBy: 'page',
autoWidth: true,
center: true,
// autoHeight: true,
autoplay: true,
nav: false, // disable dots
controls: false, // disable controls
autoplayTimeout: 4000,
autoplayButtonOutput: false,
mouseDrag: true,
nav: false,
controls: false,
loop: true,
rewind: true,
autoplayTimeout: 4000,
gutter: 10,
autoWidth: false,
center: false,
autoHeight: false,
responsive: {
640: {
items: 1
},
768: {
items: 1
},
1024: {
items: 1
}
}
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*}

{if isset($category) && isset($category.description)}
<div class="{$block.classes}" {$block.styles}>
<div class="{$block.classes} {if $block.settings.default.container}container{/if}{if $block.settings.default.force_full_width}_force-full{/if}" {$block.styles}>
{$category.description nofilter}
</div>
{/if}
8 changes: 5 additions & 3 deletions views/templates/blocks/cms/cms_content_block.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaSafe
*}
{if isset($cms) && isset($cms.content)}
{$cms.content nofilter}
{/if}
<div class="{$block.classes} prettyblocks-cms-content {if $block.settings.default.container}container{/if}{if $block.settings.default.force_full_width}_force-full{/if}" {$block.styles}>
{if isset($cms) && isset($cms.content)}
{$cms.content nofilter}
{/if}
</div>
2 changes: 1 addition & 1 deletion views/templates/blocks/custom_text/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* International Registered Trademark & Property of PrestaSafe
*}
{if $block.settings.content}
<div class="{if $block.settings.default.container}container{else}_force-full{/if}">
<div class="{$block.classes} {if $block.settings.default.container}container{/if}{if $block.settings.default.force_full_width}_force-full{/if}" {$block.styles}>
{$block.settings.content nofilter}
</div>
{/if}
2 changes: 1 addition & 1 deletion views/templates/blocks/customimage/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* International Registered Trademark & Property of PrestaSafe
*}
{if $block.settings.image}
<div class="{if $block.settings.alignment}text-sm-{$block.settings.alignment}{/if} d-block w-full">
<div class="{if $block.settings.alignment}text-sm-{$block.settings.alignment}{/if} d-block w-full {if $block.settings.default.container}container{/if}{if $block.settings.default.force_full_width}_force-full{/if}" {$block.styles}>
<img class="img-flexible" src="{$block.settings.image.url}" />
</div>
{/if}
14 changes: 8 additions & 6 deletions views/templates/blocks/tinyslider/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaSafe
*}
<div class="prettyblocks-tns">
{foreach from=$block.states item=state}
<div>
<img src="{$state.image.url}" alt="{$state.alt_image}" />
<div class="{$block.classes} {if $block.settings.default.container}container{/if}{if $block.settings.default.force_full_width}_force-full{/if}" {$block.styles}>
<div class="prettyblocks-tns slider-container">
{foreach from=$block.states item=state}
<div class="slider-item">
<img src="{$state.image.url}" alt="{$state.alt_image}" />
</div>
{/foreach}
</div>
{/foreach}
</div>
</div>

0 comments on commit bd8fbd7

Please sign in to comment.