Skip to content

Commit

Permalink
Merge branch '1.7.7.x' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jolelievre committed Oct 19, 2020
2 parents ee6a2b0 + b3d2282 commit 587c566
Show file tree
Hide file tree
Showing 192 changed files with 10,366 additions and 847 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: UI tests
name: UI tests code checks

on:
pull_request:
Expand All @@ -10,9 +10,9 @@ defaults:

jobs:

linter:
ESLint:
runs-on: ubuntu-latest
name: Linter
name: ESLint
if: contains(github.event.pull_request.labels.*.name, 'TE')

steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export default {
productsTablePaginationNumberSelector: '#orderProductsTablePaginationNumberSelector',
productsTableRow: (productId) => `#orderProduct_${productId}`,
productsTableRowEdited: (productId) => `#editOrderProduct_${productId}`,
productsTableRows: 'tr.cellProduct',
productsCellLocation: 'tr .cellProductLocation',
productsCellRefunded: 'tr .cellProductRefunded',
productsCellLocationDisplayed: 'tr:not(.d-none) .cellProductLocation',
Expand Down
19 changes: 13 additions & 6 deletions admin-dev/themes/new-theme/js/pages/order/create/cart-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,20 @@ export default class CartEditor {
* Changes cart free shipping value
*
* @param {Number} cartId
* @param {Boolean} value
*/
setFreeShipping(cartId, value) {
$.post(this.router.generate('admin_carts_set_free_shipping', {cartId}), {
freeShipping: value,
}).then((cartInfo) => EventEmitter.emit(eventMap.cartFreeShippingSet, cartInfo))
.catch((response) => window.showErrorMessage(response.responseJSON.message));
updateDeliveryOptions(cartId) {
const freeShippingEnabled = $(createOrderMap.freeShippingSwitch)[1].checked;
const isAGiftEnabled = $(createOrderMap.isAGiftSwitchValue).val() === '1';
const useRecycledPackagingEnabled = $(createOrderMap.recycledPackagingSwitchValue).val() === '1';
const giftMessage = $(createOrderMap.giftMessageField).val();

$.post(this.router.generate('admin_carts_set_delivery_settings', {cartId}), {
freeShipping: freeShippingEnabled,
isAGift: isAGiftEnabled,
useRecycledPackaging: useRecycledPackagingEnabled,
giftMessage,
}).then((cartInfo) => EventEmitter.emit(eventMap.cartDeliverySettingChanged, cartInfo))
.catch((response) => showErrorMessage(response.responseJSON.message));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ export default {
deliveryOptionSelect: '#delivery-option-select',
totalShippingField: '.js-total-shipping-tax-inc',
freeShippingSwitch: '.js-free-shipping-switch',
recycledPackagingSwitch: '.js-recycled-packaging-switch',
recycledPackagingSwitchValue: '.js-recycled-packaging-switch:checked',
isAGiftSwitch: '.js-is-gift-switch',
isAGiftSwitchValue: '.js-is-gift-switch:checked',
giftMessageField: '#cart_gift_message',

// selectors related to cart block
cartBlock: '#cart-block',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export default class CreateOrderPage {
listenForCartEdit() {
this.onCartAddressesChanged();
this.onDeliveryOptionChanged();
this.onFreeShippingChanged();
this.onDeliverySettingChanged();
this.addCartRuleToCart();
this.removeCartRuleFromCart();
this.onCartCurrencyChanged();
Expand All @@ -211,7 +211,25 @@ export default class CreateOrderPage {
this.$container.on(
'change',
createOrderMap.freeShippingSwitch,
(e) => this.cartEditor.setFreeShipping(this.cartId, e.currentTarget.value),
(e) => this.cartEditor.updateDeliveryOptions(this.cartId),
);

this.$container.on(
'change',
createOrderMap.recycledPackagingSwitch,
(e) => this.cartEditor.updateDeliveryOptions(this.cartId),
);

this.$container.on(
'blur',
createOrderMap.giftMessageField,
(e) => this.cartEditor.updateDeliveryOptions(this.cartId),
);

this.$container.on(
'change',
createOrderMap.isAGiftSwitch,
(e) => this.cartEditor.updateDeliveryOptions(this.cartId),
);

this.$container.on(
Expand Down Expand Up @@ -310,12 +328,12 @@ export default class CreateOrderPage {
}

/**
* Listens for cart free shipping update event
* Listens for cart delivery setting update event
*
* @private
*/
onFreeShippingChanged() {
EventEmitter.on(eventMap.cartFreeShippingSet, (cartInfo) => {
onDeliverySettingChanged() {
EventEmitter.on(eventMap.cartDeliverySettingChanged, (cartInfo) => {
this.cartRulesRenderer.renderCartRulesBlock(cartInfo.cartRules, cartInfo.products.length === 0);
this.shippingRenderer.render(cartInfo.shipping, cartInfo.products.length === 0);
this.summaryRenderer.render(cartInfo);
Expand Down
4 changes: 2 additions & 2 deletions admin-dev/themes/new-theme/js/pages/order/create/event-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default {
cartAddressesChanged: 'OrderCreateCartAddressesChanged',
// when cart delivery option has been changed
cartDeliveryOptionChanged: 'OrderCreateCartDeliveryOptionChanged',
// when cart free shipping value has been changed
cartFreeShippingSet: 'OrderCreateCartFreeShippingSet',
// when cart delivery setting has been changed
cartDeliverySettingChanged: 'OrderCreateCartDeliverySettingChangedSet',
// when cart rules search action is done
cartRuleSearched: 'OrderCreateCartRuleSearched',
// when cart rule is removed from cart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export default class ProductManager {
}

const $searchRequest = $.get(
this.router.generate('admin_products_search'),
this.router.generate('admin_orders_products_search'),
params,
);
this.activeSearchRequest = $searchRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export default class ShippingRenderer {
this.renderDeliveryOptions(shipping.deliveryOptions, shipping.selectedCarrierId);
this.renderTotalShipping(shipping.shippingPrice);
this.renderFreeShippingSwitch(shipping.freeShipping);
this.renderRecycledPackagingSwitch(shipping.recycledPackaging);
this.renderGiftMessageField(shipping.giftMessage);
this.renderGiftSwitch(shipping.gift);
this.showForm();
this.showContainer();
}
Expand All @@ -84,6 +87,45 @@ export default class ShippingRenderer {
});
}

/**
* @param useRecycledPackaging
*
* @private
*/
renderRecycledPackagingSwitch(useRecycledPackaging) {
$(createOrderMap.recycledPackagingSwitch).each((key, input) => {
if (input.value === '1') {
input.checked = useRecycledPackaging;
} else {
input.checked = !useRecycledPackaging;
}
});
}

/**
* @param isAGift
*
* @private
*/
renderGiftSwitch(isAGift) {
$(createOrderMap.isAGiftSwitch).each((key, input) => {
if (input.value === '1') {
input.checked = isAGift;
} else {
input.checked = !isAGift;
}
});
}

/**
* @param giftMessage
*
* @private
*/
renderGiftMessageField(giftMessage) {
$(createOrderMap.giftMessageField).val(giftMessage);
}

/**
* Show warning message that no carriers are available and hide form block
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class OrderProductAutocomplete {
this.activeSearchRequest.abort();
}

this.activeSearchRequest = $.get(this.router.generate('admin_products_search', params));
this.activeSearchRequest = $.get(this.router.generate('admin_orders_products_search', params));
this.activeSearchRequest
.then((response) => this.updateResults(response))
.always(() => {
Expand Down
28 changes: 15 additions & 13 deletions admin-dev/themes/new-theme/js/pages/order/view/order-view-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class OrderViewPage {
EventEmitter.on(OrderViewEventMap.productAddedToOrder, (event) => {
const $tablePagination = $(OrderViewPageMap.productsTablePagination);
const numRowsPerPage = $tablePagination.data('numPerPage');
const numProducts = parseInt($(OrderViewPageMap.productsCount).html(), 10);
const initialNumProducts = parseInt($(OrderViewPageMap.productsCount).html(), 10);

this.orderProductRenderer.addOrUpdateProductToList(
$(`#${$(event.newRow).find('tr').attr('id')}`),
Expand All @@ -137,26 +137,28 @@ export default class OrderViewPage {
this.listenForProductEdit();
this.resetToolTips();

if ($(OrderViewPageMap.productsTable).find('tr[id^="orderProduct_"]:not(.d-none)').length >= numRowsPerPage) {
// Update pagination
let numPages = $tablePagination.data('numPages');
if (numProducts % numRowsPerPage === 0) {
numPages += 1;
this.orderProductRenderer.paginationAddPage(numPages);
}
// Move to last page
EventEmitter.emit(OrderViewEventMap.productListPaginated, {
numPage: numPages,
});
const newNumProducts = $(OrderViewPageMap.productsTableRows).length;
const initialPagesNum = Math.ceil(initialNumProducts / numRowsPerPage);
const newPagesNum = Math.ceil(newNumProducts / numRowsPerPage);

// Update pagination
if (newPagesNum > initialPagesNum) {
this.orderProductRenderer.paginationAddPage(newPagesNum);
}
this.orderProductRenderer.updateNumProducts(numProducts + 1);

this.orderProductRenderer.updateNumProducts(newNumProducts);
this.orderProductRenderer.resetAddRow();
this.orderPricesRefresher.refreshProductPrices(event.orderId);
this.orderPricesRefresher.refresh(event.orderId);
this.orderDiscountsRefresher.refresh(event.orderId);
this.orderInvoicesRefresher.refresh(event.orderId);
this.orderDocumentsRefresher.refresh(event.orderId);
this.orderProductRenderer.moveProductPanelToOriginalPosition();

// Move to last page to see the added product
EventEmitter.emit(OrderViewEventMap.productListPaginated, {
numPage: newPagesNum,
});
});
}

Expand Down
5 changes: 5 additions & 0 deletions admin-dev/themes/new-theme/public/theme.rtlfix
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,8 @@
transform: scaleX(-1);
animation: showcase-img-appearance-rtl .4s;
}

/* Align order status dropdown correctly */
.adminorders .dropdown-menu {
right: inherit;
}
16 changes: 16 additions & 0 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
*/

use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShopBundle\Kernel\ModuleRepositoryFactory;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -82,6 +84,20 @@ public function registerBundles()
return $bundles;
}

/**
* {@inheritdoc}
*/
public function reboot($warmupDir)
{
parent::reboot($warmupDir);

// We have classes to access the container from legacy code, they need to be cleaned after reboot
Context::getContext()->container = null;
SymfonyContainer::resetStaticCache();
// @todo: do not want to risk right now but maybe Context::getContext()->controller->container needs refreshing
// but only if it is a Symfony container (do not override front legacy container)
}

/**
* {@inheritdoc}
*/
Expand Down
2 changes: 1 addition & 1 deletion app/Resources/translations/default/AdminActions.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@
<trans-unit id="656c3be690ee43df4b845bd2a2ebe587">
<source>New product</source>
<target>New product</target>
<note>Line: 372</note>
<note>Line: 368</note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
<trans-unit id="60e3ee398aa0ee3498c68914b5d5fb1a">
<source>Back office connection from %ip%</source>
<target>Back office connection from %ip%</target>
<note>Line: 214</note>
<note>Line: 237</note>
</trans-unit>
</body>
</file>
Expand Down
2 changes: 1 addition & 1 deletion app/Resources/translations/default/AdminCatalogHelp.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ File: admin-dev/themes/default/template/controllers/categories/helpers/form/form
<trans-unit id="cc2ac103a9c1411fd67952983e25978a">
<source>Create a new product: CTRL+P</source>
<target>Create a new product: CTRL+P</target>
<note>Line: 374</note>
<note>Line: 370</note>
</trans-unit>
</body>
</file>
Expand Down
Loading

0 comments on commit 587c566

Please sign in to comment.