Skip to content

Commit

Permalink
Add localization to order statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-dudarev committed Nov 14, 2023
1 parent c7bdca2 commit cf1cce9
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 193 deletions.
5 changes: 5 additions & 0 deletions src/VirtoCommerce.OrdersModule.Core/ModuleConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static class General
ValueType = SettingValueType.ShortText,
GroupName = "Orders|General",
IsDictionary = true,
IsLocalizable = true,
AllowedValues = new object[]
{
CustomerOrderStatus.New,
Expand Down Expand Up @@ -98,6 +99,7 @@ public static class General
ValueType = SettingValueType.ShortText,
GroupName = "Orders|General",
IsDictionary = true,
IsLocalizable = true,
AllowedValues = new object[] { "Pending", "InProgress", "Shipped", "Delivered", "Cancelled" },
};

Expand All @@ -114,6 +116,7 @@ public static class General
ValueType = SettingValueType.ShortText,
GroupName = "Orders|General",
IsDictionary = true,
IsLocalizable = true,
DefaultValue = "New",
AllowedValues = new object[] { "New", "PickPack", "Cancelled", "ReadyToSend", "Sent" }
};
Expand All @@ -124,6 +127,7 @@ public static class General
ValueType = SettingValueType.ShortText,
GroupName = "Orders|General",
IsDictionary = true,
IsLocalizable = true,
DefaultValue = "New",
AllowedValues = new object[] { "New", "Pending", "Authorized", "Paid", "PartiallyRefunded", "Refunded", "Voided", "Custom", "Cancelled" }
};
Expand All @@ -134,6 +138,7 @@ public static class General
ValueType = SettingValueType.ShortText,
GroupName = "Orders|General",
IsDictionary = true,
IsLocalizable = true,
DefaultValue = "Pending",
AllowedValues = new object[] { "Pending", "Rejected", "Processed" }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReference Include="VirtoCommerce.CustomerModule.Core" Version="3.400.0" />
<PackageReference Include="VirtoCommerce.NotificationsModule.Core" Version="3.400.0" />
<PackageReference Include="VirtoCommerce.PaymentModule.Core" Version="3.400.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.413.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.438.0-alpha.12789-pt-13976" />
<PackageReference Include="VirtoCommerce.ShippingModule.Core" Version="3.400.0" />
<PackageReference Include="VirtoCommerce.StoreModule.Core" Version="3.400.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.401.0" />
<PackageReference Include="VirtoCommerce.InventoryModule.Core" Version="3.402.0" />
<PackageReference Include="VirtoCommerce.Platform.Data" Version="3.413.0" />
<PackageReference Include="VirtoCommerce.Platform.Security" Version="3.406.0" />
<PackageReference Include="VirtoCommerce.Platform.Data" Version="3.438.0-alpha.12789-pt-13976" />
<PackageReference Include="VirtoCommerce.Platform.Security" Version="3.438.0-alpha.12789-pt-13976" />
<PackageReference Include="VirtoCommerce.SearchModule.Data" Version="3.402.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular.module('virtoCommerce.orderModule')
.controller('virtoCommerce.orderModule.customerOrderDetailController', ['$scope', '$window', 'platformWebApp.bladeNavigationService', 'platformWebApp.dialogService', 'platformWebApp.settings', 'virtoCommerce.customerModule.members', 'virtoCommerce.customerModule.memberTypesResolverService', 'virtoCommerce.orderModule.statusTranslationService', 'virtoCommerce.orderModule.securityAccounts', 'platformWebApp.authService',
function ($scope, $window, bladeNavigationService, dialogService, settings, members, memberTypesResolverService, statusTranslationService, securityAccounts, authService) {
.controller('virtoCommerce.orderModule.customerOrderDetailController', ['$scope', '$window', 'platformWebApp.bladeNavigationService', 'platformWebApp.dialogService', 'virtoCommerce.customerModule.members', 'virtoCommerce.customerModule.memberTypesResolverService', 'virtoCommerce.orderModule.securityAccounts', 'platformWebApp.authService',
function ($scope, $window, bladeNavigationService, dialogService, members, memberTypesResolverService, securityAccounts, authService) {
var blade = $scope.blade;
blade.currentEntityId = blade.customerOrder.id;

Expand All @@ -24,23 +24,6 @@ angular.module('virtoCommerce.orderModule')
}
});

settings.getValues({ id: 'Order.Status' }, translateBladeStatuses);
blade.openStatusSettingManagement = function () {
var newBlade = {
id: 'settingDetailChild',
isApiSave: true,
currentEntityId: 'Order.Status',
parentRefresh: translateBladeStatuses,
controller: 'platformWebApp.settingDictionaryController',
template: '$(Platform)/Scripts/app/settings/blades/setting-dictionary.tpl.html'
};
bladeNavigationService.showBlade(newBlade, blade);
};

function translateBladeStatuses(data) {
blade.statuses = statusTranslationService.translateStatuses(data, 'customerOrder');
}

function showCustomerDetailBlade(member) {
var foundTemplate = memberTypesResolverService.resolve(member.memberType);
if (foundTemplate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="blade-inner">
<div class="inner-block">
<div class="order-status" ng-if="blade.currentEntity.status">
<div class="status" ng-bind="blade.currentEntity | statusTranslate"></div>
<div class="status" ng-bind="blade.currentEntity.status | settingTranslate:'Order.Status'"></div>
<div class="reason" ng-bind="blade.currentEntity.cancelReason" ng-if="blade.currentEntity.isCancelled"></div>
</div>
<form name="formScope" ng-controller="virtoCommerce.orderModule.customerOrderDetailController">
Expand All @@ -29,18 +29,12 @@
</script>

<script type="text/ng-template" id="statusSelector.html">
<label class="form-label">
{{ 'orders.blades.customerOrder-detail.labels.status' | translate }}
<a href="" ng-click="blade.openStatusSettingManagement()" class="form-edit"><i class="form-ico fa fa-pencil"></i></a>
</label>
<div class="form-input">
<ui-select ng-model="blade.currentEntity.status" ng-disabled="blade.isLocked">
<ui-select-match placeholder="{{ 'orders.blades.customerOrder-detail.placeholders.status' | translate }}">{{ blade.currentEntity.status }}</ui-select-match>
<ui-select-choices repeat="x.key as x in blade.statuses | filter: {'value': $select.search}">
<span ng-bind-html="x.value | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
<va-setting-value-select blade="blade"
label="'orders.blades.customerOrder-detail.labels.status' | translate"
placeholder="'orders.blades.customerOrder-detail.placeholders.status' | translate"
setting="'Order.Status'"
ng-model="blade.currentEntity.status"
disabled="blade.isLocked"></va-setting-value-select>
</script>

<script type="text/ng-template" id="customerSelector.html">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
angular.module('virtoCommerce.orderModule')
.controller('virtoCommerce.orderModule.customerOrderItemsController', [
'$scope', '$translate',
'platformWebApp.bladeNavigationService', 'platformWebApp.authService', 'platformWebApp.settings',
'virtoCommerce.orderModule.catalogItems', 'virtoCommerce.orderModule.prices', 'virtoCommerce.orderModule.statusTranslationService',
function ($scope, $translate, bladeNavigationService, authService, settings, items, prices, statusTranslationService) {
'platformWebApp.bladeNavigationService', 'platformWebApp.authService',
'virtoCommerce.orderModule.catalogItems', 'virtoCommerce.orderModule.prices',
function ($scope, $translate, bladeNavigationService, authService, items, prices) {
var blade = $scope.blade;
blade.updatePermission = 'order:update';
blade.isVisiblePrices = authService.checkPermission('order:read_prices');
Expand All @@ -21,24 +21,17 @@ angular.module('virtoCommerce.orderModule')
blade.selectedAll = false;
};

settings.getValues({ id: 'OrderLineItem.Statuses' }, translateStatuses);

blade.openStatusSettingManagement = function () {
var newBlade = {
id: 'settingDetailChild',
controller: 'platformWebApp.settingDictionaryController',
template: '$(Platform)/Scripts/app/settings/blades/setting-dictionary.tpl.html',
currentEntityId: 'OrderLineItem.Statuses',
parentRefresh: translateStatuses,
isApiSave: true,
};
bladeNavigationService.showBlade(newBlade, blade);
};

function translateStatuses(data) {
blade.statuses = statusTranslationService.translateStatuses(data, 'line-item');
}

function addProductsToOrder(products) {
angular.forEach(products, function (product) {
items.get({ id: product.id }, function (data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,10 @@
</td>
<td class="table-col">
<div class="form-input __inline">
<div class="form-input">
<ui-select ng-model="data.status">
<ui-select-match allow-clear="true" placeholder="{{ 'orders.blades.customerOrder-detail.placeholders.status' | translate }}">{{data.status}}</ui-select-match>
<ui-select-choices repeat="x.key as x in blade.statuses | filter: {'value': $select.search}">
<span ng-bind-html="x.value | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
<va-setting-value-select placeholder="'orders.blades.customerOrder-detail.placeholders.status' | translate"
setting="'OrderLineItem.Statuses'"
ng-model="data.status"
allow-clear="true"></va-setting-value-select>
</div>
</td>
<td class="table-col">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function ($rootScope, $scope, $localStorage, customerOrders, bladeUtils, dialogS
{ name: 'total', displayName: 'orders.blades.customerOrder-list.labels.total', cellFilter: 'currency | showPrice:' + $scope.getPricesVisibility(), width: '**' },
{ name: 'currency', displayName: 'orders.blades.customerOrder-list.labels.currency', width: '*' },
{ name: 'isApproved', displayName: 'orders.blades.customerOrder-list.labels.confirmed', width: '*', cellClass: '__blue' },
{ name: 'status', displayName: 'orders.blades.customerOrder-list.labels.status', cellFilter: 'statusTranslate:row.entity', width: '*' },
{ name: 'status', displayName: 'orders.blades.customerOrder-list.labels.status', cellFilter: 'settingTranslate:"Order.Status"', width: '*' },
{ name: 'createdDate', displayName: 'orders.blades.customerOrder-list.labels.created', width: '**', sort: { direction: uiGridConstants.DESC } }
]}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
angular.module('virtoCommerce.orderModule')
.controller('virtoCommerce.orderModule.filterDetailController', ['$scope', '$localStorage', 'platformWebApp.settings', 'virtoCommerce.customerModule.members', '$translate', 'virtoCommerce.orderModule.statusTranslationService', 'platformWebApp.metaFormsService', 'platformWebApp.accounts',
function ($scope, $localStorage, settings, members, $translate, statusTranslationService, metaFormsService, securityAccounts) {
.controller('virtoCommerce.orderModule.filterDetailController', ['$scope', '$localStorage', 'virtoCommerce.customerModule.members', '$translate', 'platformWebApp.metaFormsService', 'platformWebApp.accounts',
function ($scope, $localStorage, members, $translate, metaFormsService, securityAccounts) {
var blade = $scope.blade;

blade.metaFields = blade.metaFields ? blade.metaFields : metaFormsService.getMetaFields('orderFilterDetail');

function translateBladeStatuses(data) {
blade.statuses = statusTranslationService.translateStatuses(data, 'customerOrder');
}
settings.getValues({ id: 'Order.Status' }, translateBladeStatuses);

blade.fetchEmployees = function (criteria) {
criteria.memberType = 'Employee';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
</div>

<script type="text/ng-template" id="statusesSelector.html">
<div class="form-input">
<ui-select multiple ng-model="blade.currentEntity.statuses">
<ui-select-match placeholder="{{ 'orders.blades.filter-detail.placeholders.all' | translate }}">{{$item.value}}</ui-select-match>
<ui-select-choices repeat="x.key as x in blade.statuses | filter: {'value': $select.search}">
<span ng-bind-html="x.value | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
<va-setting-value-select blade="blade"
placeholder="'orders.blades.filter-detail.placeholders.all' | translate"
setting="'Order.Status'"
ng-model="blade.currentEntity.statuses"
multiple></va-setting-value-select>
</script>

<script type="text/ng-template" id="storeSelector.html">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ angular.module('virtoCommerce.orderModule')
.controller('virtoCommerce.orderModule.paymentDetailController', [
'$scope',
'platformWebApp.bladeNavigationService',
'platformWebApp.dialogService',
'platformWebApp.settings',
'virtoCommerce.orderModule.order_res_customerOrders',
'virtoCommerce.orderModule.statusTranslationService',
'platformWebApp.authService',
'virtoCommerce.paymentModule.paymentMethods',
'virtoCommerce.customerModule.members',
'currencyFilter',
function ($scope, bladeNavigationService, dialogService, settings, customerOrders, statusTranslationService, authService, paymentMethods, members, currencyFilter) {
function ($scope, bladeNavigationService, customerOrders, authService, paymentMethods, members) {
var blade = $scope.blade;
blade.isVisiblePrices = authService.checkPermission('order:read_prices');
blade.paymentMethods = [];
Expand Down Expand Up @@ -51,19 +47,6 @@ angular.module('virtoCommerce.orderModule')
bladeNavigationService.setError('Error ' + error.status, blade);
});

settings.getValues({ id: 'PaymentIn.Status' }, translateBladeStatuses);
blade.openStatusSettingManagement = function () {
var newBlade = {
id: 'settingDetailChild',
isApiSave: true,
currentEntityId: 'PaymentIn.Status',
parentRefresh: translateBladeStatuses,
controller: 'platformWebApp.settingDictionaryController',
template: '$(Platform)/Scripts/app/settings/blades/setting-dictionary.tpl.html'
};
bladeNavigationService.showBlade(newBlade, blade);
};

blade.toolbarCommands.push({
name: 'orders.blades.payment-detail.labels.capture-payment',
icon: 'fas fa-file-text',
Expand Down Expand Up @@ -116,10 +99,6 @@ angular.module('virtoCommerce.orderModule')
}
});

function translateBladeStatuses(data) {
blade.statuses = statusTranslationService.translateStatuses(data, 'PaymentIn');
}

blade.setEntityStatus = function (status) {
blade.currentEntity.status = status;
blade.currentEntity.paymentStatus = status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="blade-inner">
<div class="inner-block" ng-controller="virtoCommerce.orderModule.paymentDetailController">
<div class="order-status" ng-if="blade.currentEntity.status">
<div class="status" ng-bind="blade.currentEntity | statusTranslate"></div>
<div class="status" ng-bind="blade.currentEntity.status | settingTranslate:'PaymentIn.Status'"></div>
<div class="reason" ng-bind="blade.currentEntity.cancelReason" ng-if="blade.currentEntity.isCancelled"></div>
</div>
<div class="order-brand" ng-if="!blade.isNew">
Expand Down Expand Up @@ -42,18 +42,12 @@
<div class="form columns clearfix">
<div class="column">
<div class="form-group">
<label class="form-label">
{{ 'orders.blades.payment-detail.labels.status' | translate }}
<a href="" ng-click="blade.openStatusSettingManagement()" class="form-edit"><i class="form-ico fa fa-pencil"></i></a>
</label>
<div class="form-input">
<ui-select ng-model="blade.currentEntity.status" ng-change="blade.currentEntity.paymentStatus = $select.selected.key" ng-disabled="blade.isLocked">
<ui-select-match placeholder="{{ 'orders.blades.payment-detail.placeholders.status' | translate }}">{{ blade.currentEntity.status }}</ui-select-match>
<ui-select-choices repeat="x.key as x in blade.statuses | filter: {'value': $select.search}">
<span ng-bind-html="x.value | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
<va-setting-value-select blade="blade"
label="'orders.blades.payment-detail.labels.status' | translate"
placeholder="'orders.blades.payment-detail.placeholders.status' | translate"
setting="'PaymentIn.Status'"
ng-model="blade.currentEntity.status"
disabled="blade.isLocked"></va-setting-value-select>
</div>
<div class="form-group">
<label class="form-label">{{ 'orders.blades.payment-detail.labels.amount' | translate }}</label>
Expand Down
Loading

0 comments on commit cf1cce9

Please sign in to comment.