-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PT-1895: Display localized country name in UI (#186)
- Loading branch information
Egis
authored
Jun 2, 2021
1 parent
b891772
commit 89f4f31
Showing
4 changed files
with
77 additions
and
88 deletions.
There are no files selected for viewing
136 changes: 67 additions & 69 deletions
136
src/VirtoCommerce.CoreModule.Web/Scripts/common/blades/address-detail.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}]); | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters