Skip to content

Commit bd8fbd7

Browse files
authored
Merge pull request #254 from PrestaSafe/develop
3.1.1
2 parents a7aa3d8 + f5a3d04 commit bd8fbd7

File tree

20 files changed

+93
-48
lines changed

20 files changed

+93
-48
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

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

10-
Le premier page builder open conçu pour PrestaShop !
10+
Le premier page builder open source conçu pour PrestaShop !
1111

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

_dev/src/components/Block.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ const AddOnZOne = async (code) => {
5353
ajax_token: security_app.ajax_token,
5454
};
5555
let url = ajax_urls.block_action_urls;
56-
console.log(url, params)
5756
let data = await HttpClient.get(url, params);
5857
5958
prettyBlocksContext.emit("toggleModal");

_dev/src/components/LeftPanel.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ const deleteAllBlocks = async () => {
196196
197197
if (response.success) {
198198
toaster.show(response.message)
199-
prettyBlocksContext.reloadIframe()
199+
window.location.reload()
200200
}
201201
})
202202
.catch(error => console.error(error));

_dev/src/components/Modal.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ onBeforeUnmount(() => {
5454
})
5555
5656
57-
57+
/**
58+
* reload blocks after save settings
59+
*/
60+
prettyBlocksContext.on('afterSaveSettings', () => {
61+
getBlocksAvailable()
62+
})
5863
5964
const getBlocksAvailable = () => {
6065
HttpClient.get(ajax_urls.blocks_available)

_dev/src/components/PanelThemeSettings.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ HttpClient.post(ajax_urls.state, params)
7777
if (data.message) {
7878
prettyBlocksContext.displayMessage(data.message)
7979
prettyBlocksContext.reloadIframe()
80+
prettyBlocksContext.emit('afterSaveSettings')
8081
}
8182
})
8283
.catch(error => console.error(error));

_dev/src/scripts/eventHandler.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ export const eventHandler = async (event) => {
3333
current_url: custom_url
3434
}
3535
});
36+
prettyBlocksContext.changeUrl(custom_url)
3637
if(force_reload) {
3738
window.location.reload()
38-
}else{
39-
prettyBlocksContext.changeUrl(custom_url)
4039
}
4140
}
4241

_dev/src/store/pinia.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ export const usePrettyBlocksContext = defineStore('prettyBlocksContext', {
196196
},
197197
pushUrl(url) {
198198
const currentUrl = new URL(window.location.href);
199+
200+
// Remove 'id' and 'endpoint' parameters if they exist
201+
currentUrl.searchParams.delete('id');
202+
currentUrl.searchParams.delete('endpoint');
203+
199204
currentUrl.searchParams.set('startup_url', this.updateFilteredURL(url));
200205
window.history.replaceState({}, '', currentUrl.toString());
201206
},
@@ -208,6 +213,7 @@ export const usePrettyBlocksContext = defineStore('prettyBlocksContext', {
208213
} else if (!url.includes('prettyblocks')) {
209214
url += '&prettyblocks=1';
210215
}
216+
211217
return url;
212218
},
213219
reloadIframe(currentSrc = false) {

_dev/yarn.lock

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.24.8.tgz"
1313
integrity sha512-WzfbgXOkGzZiXXCqk43kKwZjzwx4oulxZi3nq2TYL9mOjQv6kYwul9mz6ID36njuL7Xkp6nJEfok848Zj10j/w==
1414

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

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

110-
"@rollup/rollup-darwin-arm64@4.19.0":
110+
"@rollup/rollup-linux-x64-gnu@4.19.0":
111111
version "4.19.0"
112-
resolved "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.19.0.tgz"
113-
integrity sha512-emvKHL4B15x6nlNTBMtIaC9tLPRpeA5jMvRLXVbl/W9Ie7HhkrE7KQjvgS9uxgatL1HmHWDXk5TTS4IaNJxbAA==
112+
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.19.0.tgz"
113+
integrity sha512-HBndjQLP8OsdJNSxpNIN0einbDmRFg9+UQeZV1eiYupIRuZsDEoeGU43NQsS34Pp166DtwQOnpcbV/zQxM+rWA==
114+
115+
"@rollup/rollup-linux-x64-musl@4.19.0":
116+
version "4.19.0"
117+
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.19.0.tgz"
118+
integrity sha512-HxfbvfCKJe/RMYJJn0a12eiOI9OOtAUF4G6ozrFUK95BNyoJaSiBjIOHjZskTUffUrB84IPKkFG9H9nEvJGW6A==
114119

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

701-
fsevents@~2.3.2, fsevents@~2.3.3:
702-
version "2.3.3"
703-
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
704-
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
705-
706706
function-bind@^1.1.2:
707707
version "1.1.2"
708708
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz"

classes/PrettyBlocksModel.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,10 @@ public static function copyZone($zone_name, $zone_name_to_paste, $id_lang, $id_s
970970
$query->where('zone_name = \'' . $zone_name . '\'');
971971
$query->where('id_lang = ' . (int) $id_lang);
972972
$query->where('id_shop = ' . (int) $id_shop);
973+
$query->orderBy('position ASC');
973974
$results = $db->executeS($query);
974975
$result = true;
976+
$lastPosition = self::getLastPosition($zone_name, $id_lang, $id_shop);
975977

976978
foreach ($results as $row) {
977979
$model = new PrettyBlocksModel(null, $id_lang, $id_shop);
@@ -985,6 +987,8 @@ public static function copyZone($zone_name, $zone_name_to_paste, $id_lang, $id_s
985987
$model->instance_id = $row['instance_id'];
986988
$model->id_shop = (int) $id_shop;
987989
$model->id_lang = (int) $id_lang;
990+
$model->position = $row['position'] + $lastPosition;
991+
++$lastPosition;
988992
if (!$model->save()) {
989993
$errors[] = $model;
990994
}
@@ -993,6 +997,19 @@ public static function copyZone($zone_name, $zone_name_to_paste, $id_lang, $id_s
993997
return $errors;
994998
}
995999

1000+
public static function getLastPosition($zone_name, $id_lang, $id_shop)
1001+
{
1002+
$db = Db::getInstance();
1003+
$query = new DbQuery();
1004+
$query->select('MAX(position)')
1005+
->from('prettyblocks')
1006+
->where('zone_name = \'' . $zone_name . '\'')
1007+
->where('id_lang = ' . (int) $id_lang)
1008+
->where('id_shop = ' . (int) $id_shop);
1009+
1010+
return (int) $db->getValue($query);
1011+
}
1012+
9961013
/**
9971014
* deleteBlocksFromZone
9981015
* delete all blocks from a zone

prettyblocks.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function __construct()
7272
{
7373
$this->name = 'prettyblocks';
7474
$this->tab = 'administration';
75-
$this->version = '3.1.0';
75+
$this->version = '3.1.1';
7676
$this->author = 'PrestaSafe';
7777
$this->need_instance = 1;
7878
$this->js_path = $this->_path . 'views/js/';
@@ -283,7 +283,6 @@ public function hookdisplayBackOfficeHeader($params)
283283
$this->context->controller->addJS($this->_path . 'views/js/back.js');
284284
}
285285
$this->context->controller->addCSS($this->_path . 'views/css/back.css');
286-
287286
}
288287

289288
public function install()
@@ -443,7 +442,8 @@ public function hookdisplayHeader($params)
443442
// todo register css and js on iframe only from Hook
444443
}
445444
// load default blocks styles
446-
if (!TplSettings::getSettings('remove_default_blocks')) {
445+
446+
if (!TplSettings::getSettings('remove_default_blocks', false)) {
447447
$this->context->controller->registerStylesheet(
448448
'tiny-slider-css',
449449
'https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.4/tiny-slider.css',
@@ -677,7 +677,6 @@ public function hookActionRegisterThemeSettings()
677677
'description' => $this->l('Remove default blocks (if you using yours custom blocks)'), // description to display
678678
'tab' => 'Settings',
679679
'default' => false, // default value (Boolean)
680-
'private' => true,
681680
],
682681
];
683682
}
@@ -694,8 +693,7 @@ public function hookActionRegisterBlock($params)
694693
new PrettyBlocksCmsContentBlock($this),
695694
new PrettyBlocksCategoryDescriptionBlock($this),
696695
];
697-
698-
if (!TplSettings::getSettings('remove_default_blocks')) {
696+
if (!TplSettings::getSettings('remove_default_blocks', false)) {
699697
$defaultsBlocks[] = new PrettyBlocksTinySlider($this);
700698
$defaultsBlocks[] = new PrettyBlocksCustomImage($this);
701699
$defaultsBlocks[] = new PrettyBlocksFAQ($this);

0 commit comments

Comments
 (0)