Skip to content

Commit

Permalink
Merge pull request #511 from alma/release/v4.1.2
Browse files Browse the repository at this point in the history
Release v4.1.2
  • Loading branch information
Benjamin-Freoua-Alma authored Jul 16, 2024
2 parents d083180 + ed1b683 commit 5c849c5
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ jobs:

- name: Run unit Tests and Coverage
if: ${{ !contains(github.event.pull_request.labels.*.name, 'hotfix') }}
run: task test:coverage
run: task test
env:
XDEBUG_MODE: coverage
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## v4.1.2 - 2024-07-16

### Changes

### 🐛 Bug Fixes

- fix: Avoid change quantity with module pscartdropdown for insurance (#510)
- fix: Issue PS Account with PS 8.1.7 (#506)
- fix: Issue quantity insurance if we change quantity in cart (#508)
- fix: Issue insurance for product not eligible created after import (#509)

#### Contributors

@Benjamin-Freoua-Alma, @carine-bonnafous and @github-actions

## v4.1.1 - 2024-07-10

### Changes
Expand Down
54 changes: 38 additions & 16 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,40 @@ tasks:
cmds:
- task -l

brew:
preconditions:
- sh: brew -v
msg: 'This task requires `brew`. Please refer to this documentation: https://brew.sh/'

pre-commit:
desc: Install pre-commit tool
internal: true
deps: [brew]
status:
- pre-commit --version
cmds:
- brew install pre-commit

pre-commit:install:
desc: Install and set up pre-commit hooks
deps: [pre-commit]
cmds:
- pre-commit install --hook-type pre-commit --hook-type commit-msg

tools:install:
desc: Composer install of tools
sources:
- alma/composer.json
- alma/composer.lock
cmds:
- composer install --optimize-autoloader --working-dir=alma

docker:build:
desc: Build prestashop docker image
cmds:
- docker compose build prestashop

test:coverage:
test:
desc: Execute Unit Tests with coverage
deps:
- docker:build
Expand All @@ -35,14 +63,6 @@ tasks:
cmds:
- rm -rf ./dist

install-tools:
desc: Composer install of tools
sources:
- alma/composer.json
- alma/composer.lock
cmds:
- composer install --optimize-autoloader --working-dir=alma

lint:ci:
desc: Run linter within docker-compose for the CI
deps:
Expand All @@ -53,7 +73,7 @@ tasks:
lint:
desc: Run linter
deps:
- install-tools
- tools:install
cmds:
- php alma/vendor/bin/php-cs-fixer fix --dry-run --diff alma
# Search for variables in smarty templates that are not escaped
Expand All @@ -66,7 +86,7 @@ tasks:
lint:fix:
desc: Run linter and apply fix
deps:
- install-tools
- tools:install
cmds:
- php alma/vendor/bin/php-cs-fixer fix alma
# Execute autoindex to add index in all folders
Expand All @@ -78,7 +98,7 @@ tasks:
php-compatibility:
desc: Check compatibility code
deps:
- install-tools
- tools:install
cmds:
- php ./alma/vendor/bin/phpcs -p alma --standard=PHPCompatibility -s --runtime-set testVersion 5.6-8.1 --ignore=\*/vendor/\*

Expand Down Expand Up @@ -119,10 +139,11 @@ tasks:
desc: Create a release pull request
cmds:
- gh workflow run release-pull-request.yml
- sleep 2
- cmd: sleep 2
silent: true
- cmd: echo "Release pull request created, check out https://github.com/alma/{{.REPOSITORY}}/pulls?q=is%3Aopen+is%3Apr+label%3Arelease"
silent: true
- cmd: echo "If no pull request is created, check out https://github.com/alma/{{.REPOSITORY}}/actions/workflows/release-pull-request.yml."
- cmd: echo "If no pull request is created, check out https://github.com/alma/{{.REPOSITORY}}/actions/workflows/release-pull-request.yml"
silent: true
- cmd: echo "Please, review and merge the pull request."
silent: true
Expand All @@ -140,10 +161,11 @@ tasks:
Please provide a changelog message. Example: `task hotfix CHANGELOG_MESSAGE='This is a message'`.
cmds:
- gh workflow run hotfix-pull-request.yml -F changelog-message='{{.CHANGELOG_MESSAGE}}'
- sleep 2
- cmd: sleep 2
silent: true
- cmd: echo "Hotfix pull request created, check out https://github.com/alma/{{.REPOSITORY}}/pulls?q=is%3Aopen+is%3Apr+label%3Ahotfix"
silent: true
- cmd: echo "If no pull request is created, check out https://github.com/alma/{{.REPOSITORY}}/actions/workflows/hotfix-pull-request.yml."
- cmd: echo "If no pull request is created, check out https://github.com/alma/{{.REPOSITORY}}/actions/workflows/hotfix-pull-request.yml"
silent: true
- cmd: echo "Please, review and merge the pull request."
silent: true
Expand Down
4 changes: 2 additions & 2 deletions alma/alma.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

class Alma extends PaymentModule
{
const VERSION = '4.1.1';
const VERSION = '4.1.2';

public $_path;
public $local_path;
Expand Down Expand Up @@ -83,7 +83,7 @@ public function __construct()
{
$this->name = 'alma';
$this->tab = 'payments_gateways';
$this->version = '4.1.1';
$this->version = '4.1.2';
$this->author = 'Alma';
$this->need_instance = false;
$this->bootstrap = true;
Expand Down
4 changes: 3 additions & 1 deletion alma/config/admin/services.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
services:
_defaults:
public: true

#####################
# PS Account
Expand All @@ -10,4 +12,4 @@ services:
alma.ps_accounts_facade:
class: 'PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts'
arguments:
- '@alma.ps_accounts_installer'
- '@alma.ps_accounts_installer'
10 changes: 7 additions & 3 deletions alma/controllers/hook/FrontHeaderHookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ protected function manageAssetVersionForPrestashopBefore17()
*/
public function manageInsuranceAssetsAfter17()
{
$scripts = '';

if (
$this->insuranceHelper->isInsuranceAllowedInProductPage()
&& $this->iAmInProductPage()
Expand All @@ -337,7 +339,7 @@ public function manageInsuranceAssetsAfter17()
"modules/$this->moduleName/" . ConstantsHelper::INSURANCE_PRODUCT_CSS_PATH
);

return $this->urlScriptInsuranceModal();
$scripts .= $this->urlScriptInsuranceModal();
}

if (
Expand All @@ -352,7 +354,7 @@ public function manageInsuranceAssetsAfter17()
);

if ($this->insuranceHelper->isInsuranceAllowedInCartPage()) {
return $this->urlScriptInsuranceModal();
$scripts .= $this->urlScriptInsuranceModal();
}
}

Expand All @@ -365,7 +367,9 @@ public function manageInsuranceAssetsAfter17()

$this->controller->addJS($this->module->_path . ConstantsHelper::INSURANCE_SCRIPT_PATH);

return $this->almaInsuranceIdInHeader();
$scripts .= $this->almaInsuranceIdInHeader();

return $scripts;
}

/**
Expand Down
9 changes: 4 additions & 5 deletions alma/views/js/alma-cart-insurance.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
if (window.prestashop != null && window.prestashop.on != null) {
prestashop.on("updatedCart", onloadInsuranceItemCartAlma);
}
window.addEventListener('message', (e) => {
handleAddInsuranceProductFromWidget(e);
});
});
})(jQuery);

Expand Down Expand Up @@ -182,10 +185,6 @@ function onloadInsuranceClickEvents() {
});

});

window.addEventListener('message', (e) => {
handleAddInsuranceProductFromWidget(e);
});
}

function handleAddInsuranceProductFromWidget(e) {
Expand Down Expand Up @@ -218,7 +217,7 @@ function handleAddInsuranceProductFromWidget(e) {
}
}
if (e.data.type === 'almaEligibilityAnswer') {
if (e.data.eligibilityCallResult.length > 0) {
if (e.data.eligibilityCallResponseStatus.response.eligibleProduct && e.data.eligibilityCallResult.length > 0) {
$('#' + e.data.iFrameIdForProductWidget).show();
}
}
Expand Down
22 changes: 22 additions & 0 deletions alma/views/js/alma-insurance.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/**
* 2018-2024 Alma SAS
*
* THE MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* @author Alma SAS <[email protected]>
* @copyright 2018-2024 Alma SAS
* @license https://opensource.org/licenses/MIT The MIT License
*/
(function ($) {
$(function () {
loadInsuranceMiniCart();
Expand Down
9 changes: 6 additions & 3 deletions alma/views/js/alma-product-insurance.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ let selectedAlmaInsurance = null;
let addToCartFlow = false;
let productDetails = null;
let quantity = 1;
let almaEligibilityAnswer = false;

(function ($) {
$(function () {
Expand Down Expand Up @@ -97,8 +98,9 @@ function onloadAddInsuranceInputOnProductAlma() {

window.addEventListener('message', (e) => {
if (e.data.type === 'almaEligibilityAnswer') {
almaEligibilityAnswer = e.data.eligibilityCallResponseStatus.response.eligibleProduct;
btnLoaders('stop');
if (e.data.eligibilityCallResponseStatus.response.eligibleProduct === true) {
if (almaEligibilityAnswer) {
let heightIframe = e.data.widgetSize.height;
let stringHeightIframe = heightIframe + 'px';
if (heightIframe <= 45) {
Expand All @@ -108,7 +110,7 @@ function onloadAddInsuranceInputOnProductAlma() {
document.getElementById('alma-widget-insurance-product-page').style.height = stringHeightIframe;
} else {
let addToCart = document.querySelector('.add-to-cart');
addToCart.removeEventListener("click",insuranceListener)
addToCart.removeEventListener("click", insuranceListener)
}
}
if (e.data.type === 'getSelectedInsuranceData') {
Expand Down Expand Up @@ -204,8 +206,9 @@ function removeInputInsurance() {
}

function addModalListenerToAddToCart() {
if (settings.isAddToCartPopupActivated === true) {
if (settings.isAddToCartPopupActivated === true && almaEligibilityAnswer) {
let addToCart = document.querySelector('.add-to-cart');
// If we change the quantity the DOM is reloaded then we need to remove and add the listener again
addToCart.removeEventListener("click",insuranceListener)
addToCart.addEventListener("click", insuranceListener);
}
Expand Down

0 comments on commit 5c849c5

Please sign in to comment.