Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPD-47563 Create Fragment for Currency Selection #5978

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
054407e
LPD-48683 New finder
monaco-fabio Feb 21, 2025
f3006c3
LPD-48683 Currency item selector
monaco-fabio Feb 17, 2025
faaabcc
LPD-48683 Commerce Channel Currency pages
monaco-fabio Feb 17, 2025
d202078
LPD-47567 Multicurrency support RELEASE FF
gianmarcobrunialti Feb 18, 2025
82477a7
LPD-48683 Semantic version
monaco-fabio Feb 27, 2025
546f55d
LPD-48683 Add Integration test
monaco-fabio Feb 18, 2025
bb6cf9c
LPD-48683 Add functional test
monaco-fabio Feb 18, 2025
58f5754
LPD-48683 Autogenerated Code (buildService)
monaco-fabio Feb 17, 2025
3a0e439
LPD-48683 Autogenerated Code (buildLang)
gianmarcobrunialti Feb 26, 2025
6e07628
LPD-47563 GET currencies by channel
michelevigilante Feb 18, 2025
c1f7457
LPD-47563 Add get in yaml
michelevigilante Feb 18, 2025
69a6c7a
LPD-47563 Add CurrencySelector component
michelevigilante Feb 18, 2025
8b9034b
LPD-47563 Add dependencies
michelevigilante Feb 18, 2025
e664e68
LPD-47563 Add resolvePath in ServiceProvider
michelevigilante Feb 18, 2025
c4b6d67
LPD-47563 Currency Selector completion
gianmarcobrunialti Feb 20, 2025
d60b41b
LPD-47563 Currency Selector fragment renderer categorization
gianmarcobrunialti Feb 27, 2025
b92d667
LPD-47563 Currency Selector tests
gianmarcobrunialti Feb 27, 2025
0b50141
LPD-47563 Remove unecessary dependency
michelevigilante Feb 19, 2025
35e23ee
LPD-47563 Autogenerated code (buildRest)
michelevigilante Feb 18, 2025
2ca8ed2
LPD-47563 Override delete method in commercechannelrel
michelevigilante Feb 20, 2025
4998517
LPD-47563 Centralize order detail URL resolution
gianmarcobrunialti Feb 20, 2025
b2ed5fa
LPD-47563 Adapt unit tests
gianmarcobrunialti Feb 27, 2025
6d58800
LPD-47564 Update Classic accelerator with Currency Selector
gianmarcobrunialti Feb 20, 2025
a59746f
LPD-47563 Exposed currencyCode on cart updates
gianmarcobrunialti Feb 24, 2025
625ab36
LPD-47563 Updated language keys
gianmarcobrunialti Feb 24, 2025
043a734
LPD-49601 Fix playwright test
michelevigilante Feb 27, 2025
3244c0c
LPD-47563 Autogenerated Code (buildLang)
gianmarcobrunialti Feb 27, 2025
e2b07ca
f get api
michelevigilante Feb 28, 2025
7602580
LPD-47563 Semantic version
michelevigilante Feb 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/apps/commerce/commerce-api/bnd.bnd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Bundle-Name: Liferay Commerce API
Bundle-SymbolicName: com.liferay.commerce.api
Bundle-Version: 94.1.2
Bundle-Version: 95.0.0
Export-Package:\
com.liferay.commerce.address,\
com.liferay.commerce.checkout.helper,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public CommerceOrder fetchCommerceOrderByUuidAndGroupId(
String uuid, long groupId)
throws PortalException;

public String getCommerceCartBaseURL(HttpServletRequest httpServletRequest)
throws PortalException;

public String getCommerceCartPortletURL(
HttpServletRequest httpServletRequest)
throws PortalException;
Expand Down Expand Up @@ -59,6 +62,10 @@ public CommerceOrder getCurrentCommerceOrder(
HttpServletRequest httpServletRequest)
throws PortalException;

public boolean hasCommerceOrderPortlet(
HttpServletRequest httpServletRequest, String portletKey)
throws PortalException;

public boolean isGuestCheckoutEnabled(HttpServletRequest httpServletRequest)
throws PortalException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version 10.0.0
version 11.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class CommerceChannelFDSNames {
public static final String CHANNEL_QUALIFIER_ACCOUNTS =
CPPortletKeys.COMMERCE_CHANNELS + "-channelQualifierAccounts";

public static final String COMMERCE_CURRENCIES =
CPPortletKeys.COMMERCE_CHANNELS + "-commerceCurrencies";

public static final String PAYMENT_METHOD =
CPPortletKeys.COMMERCE_CHANNELS + "-paymentMethod";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
*/
public class CommerceChannelScreenNavigationConstants {

public static final String
CATEGORY_KEY_COMMERCE_CHANNEL_COMMERCE_CURRENCIES = "currencies";

public static final String CATEGORY_KEY_COMMERCE_CHANNEL_COUNTRIES =
"countries";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/**
* SPDX-FileCopyrightText: (c) 2025 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/

package com.liferay.commerce.channel.web.internal.display.context;

import com.liferay.commerce.channel.web.internal.item.selector.criterion.CommerceCurrencyItemSelectorCriterion;
import com.liferay.commerce.product.display.context.helper.CPRequestHelper;
import com.liferay.commerce.product.model.CommerceChannel;
import com.liferay.commerce.product.model.CommerceChannelRelModel;
import com.liferay.commerce.product.service.CommerceChannelRelService;
import com.liferay.commerce.product.service.CommerceChannelService;
import com.liferay.frontend.taglib.clay.servlet.taglib.util.CreationMenu;
import com.liferay.item.selector.ItemSelector;
import com.liferay.item.selector.ItemSelectorCriterion;
import com.liferay.item.selector.criteria.UUIDItemSelectorReturnType;
import com.liferay.petra.function.transform.TransformUtil;
import com.liferay.petra.string.StringPool;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
import com.liferay.portal.kernel.portlet.RequestBackedPortletURLFactory;
import com.liferay.portal.kernel.portlet.RequestBackedPortletURLFactoryUtil;
import com.liferay.portal.kernel.portlet.url.builder.PortletURLBuilder;
import com.liferay.portal.kernel.security.permission.ActionKeys;
import com.liferay.portal.kernel.security.permission.resource.ModelResourcePermission;
import com.liferay.portal.kernel.util.HashMapBuilder;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.StringUtil;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

/**
* @author Fabio Monaco
*/
public class CommerceChannelCommerceCurrencyDisplayContext {

public CommerceChannelCommerceCurrencyDisplayContext(
ModelResourcePermission<CommerceChannel>
commerceChannelModelResourcePermission,
CommerceChannelRelService commerceChannelRelService,
CommerceChannelService commerceChannelService,
HttpServletRequest httpServletRequest, ItemSelector itemSelector) {

_commerceChannelModelResourcePermission =
commerceChannelModelResourcePermission;
_commerceChannelRelService = commerceChannelRelService;
_commerceChannelService = commerceChannelService;
_itemSelector = itemSelector;

_cpRequestHelper = new CPRequestHelper(httpServletRequest);
}

public CommerceChannel getCommerceChannel() throws PortalException {
if (_commerceChannel != null) {
return _commerceChannel;
}

long commerceChannelId = ParamUtil.getLong(
_cpRequestHelper.getRenderRequest(), "commerceChannelId");

if (commerceChannelId > 0) {
_commerceChannel = _commerceChannelService.getCommerceChannel(
commerceChannelId);
}

return _commerceChannel;
}

public long getCommerceChannelId() throws PortalException {
CommerceChannel commerceChannel = getCommerceChannel();

if (commerceChannel == null) {
return 0;
}

return commerceChannel.getCommerceChannelId();
}

public CreationMenu getCreationMenu() throws Exception {
CreationMenu creationMenu = new CreationMenu();

if (hasPermission(getCommerceChannelId(), ActionKeys.UPDATE)) {
creationMenu.addDropdownItem(
dropdownItem -> {
LiferayPortletResponse liferayPortletResponse =
_cpRequestHelper.getLiferayPortletResponse();

dropdownItem.setHref(
liferayPortletResponse.getNamespace() +
"addCommerceChannelCommerceCurrency");

dropdownItem.setLabel(
LanguageUtil.get(
_cpRequestHelper.getRequest(), "add-currency"));
dropdownItem.setTarget("event");
});
}

return creationMenu;
}

public HashMap<String, Object> getJSContext() {
return HashMapBuilder.<String, Object>put(
"url",
() -> {
RequestBackedPortletURLFactory requestBackedPortletURLFactory =
RequestBackedPortletURLFactoryUtil.create(
_cpRequestHelper.getRenderRequest());

ItemSelectorCriterion itemSelectorCriterion =
new CommerceCurrencyItemSelectorCriterion();

itemSelectorCriterion.setDesiredItemSelectorReturnTypes(
new UUIDItemSelectorReturnType());

long commerceChannelId = getCommerceChannelId();

return PortletURLBuilder.create(
_itemSelector.getItemSelectorURL(
requestBackedPortletURLFactory, "currencySelectItem",
itemSelectorCriterion)
).setParameter(
"checkedCommerceCurrencyIds",
StringUtil.merge(
_getCheckedCommerceCurrencyIds(commerceChannelId))
).setParameter(
"commerceChannelId", commerceChannelId
).buildString();
}
).build();
}

public boolean hasPermission(long commerceChannelId, String actionId)
throws PortalException {

return _commerceChannelModelResourcePermission.contains(
_cpRequestHelper.getPermissionChecker(), commerceChannelId,
actionId);
}

private long[] _getCheckedCommerceCurrencyIds(long commerceChannelId)
throws PortalException {

return TransformUtil.transformToLongArray(
_commerceChannelRelService.getCommerceCurrencyCommerceChannelRels(
commerceChannelId, StringPool.BLANK, QueryUtil.ALL_POS,
QueryUtil.ALL_POS),
CommerceChannelRelModel::getClassPK);
}

private CommerceChannel _commerceChannel;
private final ModelResourcePermission<CommerceChannel>
_commerceChannelModelResourcePermission;
private final CommerceChannelRelService _commerceChannelRelService;
private final CommerceChannelService _commerceChannelService;
private final CPRequestHelper _cpRequestHelper;
private final ItemSelector _itemSelector;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* SPDX-FileCopyrightText: (c) 2025 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/

package com.liferay.commerce.channel.web.internal.frontend.data.set.provider;

import com.liferay.commerce.channel.web.internal.constants.CommerceChannelFDSNames;
import com.liferay.commerce.channel.web.internal.model.CommerceChannelCommerceCurrency;
import com.liferay.commerce.product.constants.CPPortletKeys;
import com.liferay.commerce.product.model.CommerceChannel;
import com.liferay.frontend.data.set.provider.FDSActionProvider;
import com.liferay.frontend.taglib.clay.servlet.taglib.util.DropdownItem;
import com.liferay.frontend.taglib.clay.servlet.taglib.util.DropdownItemListBuilder;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.language.Language;
import com.liferay.portal.kernel.portlet.url.builder.PortletURLBuilder;
import com.liferay.portal.kernel.security.permission.ActionKeys;
import com.liferay.portal.kernel.security.permission.PermissionThreadLocal;
import com.liferay.portal.kernel.security.permission.resource.ModelResourcePermission;
import com.liferay.portal.kernel.util.Constants;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.Portal;

import java.util.List;

import javax.portlet.PortletRequest;
import javax.portlet.PortletURL;

import javax.servlet.http.HttpServletRequest;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* @author Fabio Monaco
*/
@Component(
property = "fds.data.provider.key=" + CommerceChannelFDSNames.COMMERCE_CURRENCIES,
service = FDSActionProvider.class
)
public class CommerceChannelCommerceCurrencyFDSActionProvider
implements FDSActionProvider {

@Override
public List<DropdownItem> getDropdownItems(
long groupId, HttpServletRequest httpServletRequest, Object model)
throws PortalException {

CommerceChannelCommerceCurrency commerceChannelCommerceCurrency =
(CommerceChannelCommerceCurrency)model;

return DropdownItemListBuilder.add(
() -> _commerceChannelModelResourcePermission.contains(
PermissionThreadLocal.getPermissionChecker(),
commerceChannelCommerceCurrency.getCommerceChannelId(),
ActionKeys.UPDATE),
dropdownItem -> {
dropdownItem.setHref(
_getCommerceChannelCommerceCurrencyDeleteURL(
commerceChannelCommerceCurrency.
getCommerceChannelRelId(),
httpServletRequest));
dropdownItem.setIcon("trash");
dropdownItem.setLabel(
_language.get(httpServletRequest, "remove"));
}
).build();
}

private PortletURL _getCommerceChannelCommerceCurrencyDeleteURL(
long commerceChannelRelId, HttpServletRequest httpServletRequest) {

return PortletURLBuilder.create(
_portal.getControlPanelPortletURL(
httpServletRequest, CPPortletKeys.COMMERCE_CHANNELS,
PortletRequest.ACTION_PHASE)
).setActionName(
"/commerce_channels/edit_commerce_channel_commerce_currency"
).setCMD(
Constants.DELETE
).setRedirect(
ParamUtil.getString(
httpServletRequest, "currentUrl",
_portal.getCurrentURL(httpServletRequest))
).setParameter(
"commerceChannelRelId", commerceChannelRelId
).buildPortletURL();
}

@Reference(
target = "(model.class.name=com.liferay.commerce.product.model.CommerceChannel)"
)
private ModelResourcePermission<CommerceChannel>
_commerceChannelModelResourcePermission;

@Reference
private Language _language;

@Reference
private Portal _portal;

}
Loading