Skip to content

Commit

Permalink
PT-1895: Display localized country name in UI (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
Egis authored Jun 2, 2021
1 parent b891772 commit 89f4f31
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 88 deletions.
Original file line number Diff line number Diff line change
@@ -1,87 +1,85 @@
angular.module('virtoCommerce.coreModule.common')
.controller('virtoCommerce.coreModule.common.coreAddressDetailController', ['$scope', 'platformWebApp.common.countries', 'platformWebApp.dialogService', 'platformWebApp.metaFormsService', 'platformWebApp.bladeNavigationService', function ($scope, countries, dialogService, metaFormsService, bladeNavigationService) {
var blade = $scope.blade;
var blade = $scope.blade;

blade.addressTypes = ['Billing', 'Shipping', 'BillingAndShipping'];
blade.metaFields = blade.metaFields && blade.metaFields.length ? blade.metaFields : metaFormsService.getMetaFields('addressDetails');
if (blade.currentEntity.isNew) {
blade.currentEntity.addressType = blade.addressTypes[1];
}
blade.origEntity = blade.currentEntity;
blade.currentEntity = angular.copy(blade.origEntity);
blade.countries = countries.query();



blade.toolbarCommands = [{
name: "platform.commands.reset", icon: 'fa fa-undo',
executeMethod: function () {
angular.copy(blade.origEntity, blade.currentEntity);
},
canExecuteMethod: isDirty
}, {
name: "platform.commands.delete", icon: 'fas fa-trash-alt',
executeMethod: deleteEntry,
canExecuteMethod: function () {
return !blade.currentEntity.isNew;
blade.addressTypes = ['Billing', 'Shipping', 'BillingAndShipping'];
blade.metaFields = blade.metaFields && blade.metaFields.length ? blade.metaFields : metaFormsService.getMetaFields('addressDetails');
if (blade.currentEntity.isNew) {
blade.currentEntity.addressType = blade.addressTypes[1];
}
}];
blade.origEntity = blade.currentEntity;
blade.currentEntity = angular.copy(blade.origEntity);
blade.countries = countries.query();

blade.toolbarCommands = [{
name: "platform.commands.reset", icon: 'fa fa-undo',
executeMethod: function () {
angular.copy(blade.origEntity, blade.currentEntity);
},
canExecuteMethod: isDirty
}, {
name: "platform.commands.delete", icon: 'fas fa-trash-alt',
executeMethod: deleteEntry,
canExecuteMethod: function () {
return !blade.currentEntity.isNew;
}
}];

blade.isLoading = false;
blade.isLoading = false;

blade.onClose = function (closeCallback) {
bladeNavigationService.showConfirmationIfNeeded(isDirty(), canSave(), blade, $scope.saveChanges, closeCallback, "core.dialogs.address-save.title", "core.dialogs.address-save.message");
};
blade.onClose = function (closeCallback) {
bladeNavigationService.showConfirmationIfNeeded(isDirty(), canSave(), blade, $scope.saveChanges, closeCallback, "core.dialogs.address-save.title", "core.dialogs.address-save.message");
};

$scope.setForm = function (form) {
$scope.formScope = form;
};
$scope.setForm = function (form) {
$scope.formScope = form;
};

$scope.isValid = function () {
return $scope.formScope && $scope.formScope.$valid;
}
$scope.isValid = function () {
return $scope.formScope && $scope.formScope.$valid;
};

$scope.cancelChanges = function () {
$scope.bladeClose();
}
$scope.cancelChanges = function () {
$scope.bladeClose();
};

$scope.saveChanges = function () {
if (blade.confirmChangesFn) {
blade.confirmChangesFn(blade.currentEntity);
$scope.saveChanges = function () {
if (blade.confirmChangesFn) {
blade.confirmChangesFn(blade.currentEntity);
};
angular.copy(blade.currentEntity, blade.origEntity);
$scope.bladeClose();
};
angular.copy(blade.currentEntity, blade.origEntity);
$scope.bladeClose();
};

$scope.$watch('blade.currentEntity.countryCode', function (countryCode) {
var country;
if (countryCode && (country = _.findWhere(blade.countries, { id: countryCode }))) {
blade.currentEntity.countryName = country.name;
}
});
$scope.$watch('blade.currentEntity.countryCode', function (countryCode) {
var country;
if (countryCode && (country = _.findWhere(blade.countries, { id: countryCode }))) {
blade.currentEntity.countryName = country.name;
}
});

function isDirty() {
return !angular.equals(blade.currentEntity, blade.origEntity);
}
function isDirty() {
return !angular.equals(blade.currentEntity, blade.origEntity);
}

function canSave() {
return isDirty();
}
function canSave() {
return isDirty();
}

function deleteEntry() {
var dialog = {
id: "confirmDelete",
title: "core.dialogs.address-delete.title",
message: "core.dialogs.address-delete.message",
callback: function (remove) {
if (remove) {
if (blade.deleteFn) {
blade.deleteFn(blade.currentEntity);
};
$scope.bladeClose();
function deleteEntry() {
var dialog = {
id: "confirmDelete",
title: "core.dialogs.address-delete.title",
message: "core.dialogs.address-delete.message",
callback: function (remove) {
if (remove) {
if (blade.deleteFn) {
blade.deleteFn(blade.currentEntity);
};
$scope.bladeClose();
}
}
}
dialogService.showConfirmationDialog(dialog);
}
dialogService.showConfirmationDialog(dialog);
}
}]);
}]);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="blade-static __bottom" ng-include="'$(Platform)/Scripts/common/templates/ok-cancel.tpl.html'"></div>
<div class="blade-static __bottom" ng-include="'$(Platform)/Scripts/common/templates/ok-cancel.tpl.html'"></div>
<div class="blade-content">
<div class="blade-inner">
<div class="inner-block">
Expand All @@ -14,7 +14,7 @@
<div class="form-input">
<ui-select ng-model="blade.currentEntity.addressType">
<ui-select-match placeholder="{{ 'core.blades.address-detail.placeholders.address-type' | translate }}">{{$select.selected}}</ui-select-match>
<ui-select-choices repeat="x as x in blade.addressTypes | filter: $select.search ">
<ui-select-choices repeat="x as x in blade.addressTypes | filter: $select.search">
<span ng-bind-html="x | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
Expand All @@ -24,19 +24,10 @@
<label class="form-label">{{ 'core.blades.address-detail.labels.country' | translate }}</label>
<div class="form-input">
<ui-select ng-model="blade.currentEntity.countryCode" required>
<ui-select-match placeholder="{{ 'core.blades.address-detail.placeholders.country' | translate }}">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="x.id as x in blade.countries | filter: $select.search ">
<span ng-bind-html="x.name | highlight: $select.search"></span>
<ui-select-match placeholder="{{ 'core.blades.address-detail.placeholders.country' | translate }}">{{$select.selected.displayName}}</ui-select-match>
<ui-select-choices repeat="x.id as x in blade.countries | filter: $select.search">
<span ng-bind-html="x.displayName | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
</script>
<!--duplicates template from platform version after 2.13.15. Remove this after platform version dependency increases -->
<script type="text/ng-template" id="dEmail.html">
<div class="form-input">
<input ng-required="currentEntity.isRequired"
ng-model="context.currentPropValues[0].value"
placeholder="Enter email"
type="email" />
</div>
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,9 @@
Browsing from country
<div class="form-input" ng-controller="virtoCommerce.dynamicExpressions.conditionGeoCountryController">
<ui-select ng-model="element1.value" required>
<ui-select-match placeholder="Select...">{{$select.selected.name}}</ui-select-match>
<ui-select-match placeholder="Select...">{{$select.selected.displayName}}</ui-select-match>
<ui-select-choices repeat="x.id as x in countries | filter: $select.search ">
<span ng-bind-html="x.name | highlight: $select.search"></span>
<span ng-bind-html="x.displayName | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/VirtoCommerce.CoreModule.Web/module.manifest
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<id>VirtoCommerce.Core</id>
<version>3.17.0</version>
<version-tag />
<platformVersion>3.51.0</platformVersion>
<platformVersion>3.60.0-alpha.11916</platformVersion>
<title>Commerce core module</title>
<description>Common e-commerce domain functionality</description>
<authors>
Expand All @@ -26,4 +26,4 @@
<group>commerce</group>
</groups>
<useFullTypeNameInSwagger>false</useFullTypeNameInSwagger>
</module>
</module>

0 comments on commit 89f4f31

Please sign in to comment.