diff --git a/.github/workflows/deploy-pr.yml b/.github/workflows/deploy-pr.yml new file mode 100644 index 000000000..28e5628be --- /dev/null +++ b/.github/workflows/deploy-pr.yml @@ -0,0 +1,42 @@ +# v1.0 + +name: Deploy to environments +on: + pull_request: + paths-ignore: + - '.github/**' + - 'docs/**' + - 'build/**' + - 'README.md' + - 'LICENSE' + branches: [dev] + types: [labeled, closed] + +jobs: + deploy: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} + + steps: + + - name: Read deployment config + if: contains(github.event.pull_request.labels.*.name, 'deploy-dev') + uses: VirtoCommerce/vc-github-actions/get-deploy-param@master + id: deployConfig + + - name: Gets artifact link + if: contains(github.event.pull_request.labels.*.name, 'deploy-dev') + uses: VirtoCommerce/vc-github-actions/get-artifact-link@master + id: artifactLink + + - name: Create deploy PR in DEV + if: github.event.action != 'closed' && contains(github.event.pull_request.labels.*.name, 'deploy-dev') + uses: VirtoCommerce/vc-github-actions/create-deploy-pr@master + with: + deployRepo: ${{ steps.deployConfig.outputs.deployRepo }} + deployBranch: ${{ fromJSON(steps.deployConfig.outputs.deployConfig).dev.deployBranch }} + artifactKey: ${{ steps.deployConfig.outputs.artifactKey }} + artifactUrl: ${{ steps.artifactLink.outputs.artifactUrl }} + taskNumber: ${{ steps.artifactLink.outputs.qaTaskNumber }} + cmPath: ${{ steps.deployConfig.outputs.cmPath }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..0cf649928 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,78 @@ +# v1.0 + +name: VC deployment +on: + workflow_dispatch: + inputs: + artifactUrl: + description: 'Full link to artifact docker image or artifact download url' + required: true + deployBranch: + description: 'ArgoCd branch name' + required: true + default: 'dev' + +jobs: + cd: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} + + steps: + + - name: Read deployment config + uses: VirtoCommerce/vc-github-actions/get-deploy-param@master + id: deployConfig + with: + envName: ${{ github.event.inputs.deployBranch }} + + - name: Start deployment + uses: bobheadxi/deployments@master + id: deployment + with: + step: start + token: ${{ secrets.GITHUB_TOKEN }} + env: Development + no_override: false + + - name: Update deployment-cm + uses: VirtoCommerce/vc-github-actions/create-deploy-pr@master + with: + deployRepo: ${{ steps.deployConfig.outputs.deployRepo }} + deployBranch: ${{ steps.deployConfig.outputs.deployBranch }} + artifactKey: ${{ steps.deployConfig.outputs.artifactKey }} + artifactUrl: ${{ github.event.inputs.artifactUrl }} + taskNumber: "undefined" + forceCommit: "true" + cmPath: ${{ steps.deployConfig.outputs.cmPath }} + + - name: Wait for environment is up + shell: pwsh + timeout-minutes: 15 + run: | + do { + Start-Sleep -s 15 + $statusBage = (Invoke-WebRequest -Uri "https://argo.govirto.com/api/badge?name=${{ steps.deployConfig.outputs.deployAppName }}").Content + + $syncedAndHealthy = $statusBage.Contains('>Healthy<') -and $statusBage.Contains('>Synced<') + if (-not $syncedAndHealthy) { + Write-Host "Sync pending..." + } + } + while (-not $syncedAndHealthy) + - name: BUILD_STATE::successful + if: success() + run: echo "BUILD_STATE=successful" >> $GITHUB_ENV + + - name: BUILD_STATE::failed + if: failure() + run: echo "BUILD_STATE=failed" >> $GITHUB_ENV + + - name: Update GitHub deployment status + uses: bobheadxi/deployments@master + if: always() + with: + step: finish + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + deployment_id: ${{ steps.deployment.outputs.deployment_id }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b5d28d55c..c7e70eed5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -# v1.1.3 +# v1.1.4 name: Module CI on: @@ -68,7 +68,6 @@ jobs: else echo "VERSION_SUFFIX=${{ steps.image.outputs.suffix }}" >> $GITHUB_ENV fi; - - name: Add version suffix if: ${{ github.ref != 'refs/heads/master' }} uses: VirtoCommerce/vc-github-actions/add-version-suffix@master @@ -134,4 +133,12 @@ jobs: moduleId: ${{ steps.image.outputs.moduleId }} moduleDescription: ${{ steps.image.outputs.moduleDescription }} projectUrl: ${{ steps.image.outputs.projectUrl }} - iconUrl: ${{ steps.image.outputs.iconUrl }} \ No newline at end of file + iconUrl: ${{ steps.image.outputs.iconUrl }} + + - name: Invoke Module deployment workflow + if: ${{ github.ref == 'refs/heads/master' }} + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: VC deployment + token: ${{ secrets.REPO_TOKEN }} + inputs: '{ "artifactUrl": "https://github.com/${{ github.repository }}/releases/download/${{ steps.image.outputs.shortVersion }}/${{ steps.image.outputs.moduleId }}_${{ steps.image.outputs.shortVersion }}.zip", "deployBranch": "dev" }' diff --git a/Directory.Build.props b/Directory.Build.props index 1c36da468..b99f74031 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 3.17.0 + 3.18.0 $(VersionSuffix)-$(BuildNumber) diff --git a/src/VirtoCommerce.CoreModule.Web/Localizations/en.VirtoCommerce.Core.json b/src/VirtoCommerce.CoreModule.Web/Localizations/en.VirtoCommerce.Core.json index dad6706dd..81f66d031 100644 --- a/src/VirtoCommerce.CoreModule.Web/Localizations/en.VirtoCommerce.Core.json +++ b/src/VirtoCommerce.CoreModule.Web/Localizations/en.VirtoCommerce.Core.json @@ -1,317 +1,318 @@ { - "core": { - "commands": { - "apply-filter": "Save & apply", - "rebuild-index": "Build Index" - }, - "main-menu-title": { - "search-index": "Search index" - }, - "blades": { - "index-progress": { - "labels": { - "start": "Start", - "end": "End", - "errors": "Errors", - "stats": "Indexed - {{ processedCount }} of {{ totalCount }} documents" - } - }, - "index-detail": { - "title": "Search index", - "title-new": "Search index missing", - "subtitle": "Search index details", - "labels": { - "no-index": "Index not found", - "build-date": "Last indexed", - "content": "Index content" - } - }, - "address-list": { - "labels": { - "no-addresses": "No Addresses yet" - } - }, - "address-detail": { - "subtitle": "Edit address", - "labels": { - "name": "Address Name", - "address-type": "Address type", - "first-name": "First name", - "last-name": "Last name", - "country": "Country", - "region": "Region", - "city": "City", - "address1": "Address line 1", - "address2": "Address line 2", - "zip-code": "Zip code", - "email": "Email", - "phone": "Phone" - }, - "placeholders": { - "address-type": "Select...", - "country": "Select..." - } - }, - "currency-list": { - "title": "Currencies", - "subtitle": "Manage system currencies", - "labels": { - "exchange-rate": "Exchange rate:", - "no-currencies": "No currencies" - } - }, - "currency-detail": { - "new-title": "New currency", - "new-subtitle": "Enter currency details", - "subtitle": "Edit currency details", - "labels": { - "code": "Code", - "name": "Name", - "is-primary": "Is primary", - "exchange-rate": "Exchange rate", - "symbol": "Symbol", - "custom-formatting": "Currency custom formatting" - }, - "descriptions": { - "code": "The currency code. Use 3 letter ISO 4217 code, if it exists.", - "name": "The name of the currency.", - "is-primary": "Is this the primary currency? Only one currency can by primary.", - "exchange-rate": "The exchange rate against the primary exchange rate currency", - "symbol": "Short currency symbol", - "custom-formatting": "Custom formatting to be applied to the currency value" - }, - "placeholders": { - "symbol": "Enter symbol or leave empty for default culture", - "code": "Enter currency code", - "name": "Enter currency name", - "exchange-rate": "Enter exchange rate against the primary currency", - "custom-formatting": "0,0.000" - }, - "validation": { - "maxlength": "Currency code must have only 3 symbols" - } - }, - "fulfillment-center-contact": { - "labels": { - "country": "Country", - "region": "Region", - "city": "City", - "address": "Address", - "zip-code": "Zip code", - "phone": "Phone" - }, - "placeholders": { - "country": "Select...", - "region": "Enter region", - "city": "Enter city", - "address1": "Enter address line 1", - "address2": "Enter address line 2", - "zip-code": "Enter postal code", - "phone": "Enter phone number" - } - }, - "fulfillment-center-detail": { - "subtitle": "Edit Fulfillment center", - "labels": { - "name": "Name", - "description": "Description", - "max-releases": "Max. releases per pick batch", - "pick-delay": "Pick delay" - } - }, - "fulfillment-center-list": { - "title": "Fulfillment centers", - "subtitle": "Manage Fulfillment centers" - }, - "seo-list": { - "subtitle": "Manage SEOs", - "labels": { - "duplicates-found": "There are {{count}} conflicting Semantic URLs!", - "resolve-duplicates": "Resolve conflicts", - "language-code": "Language", - "container": "Store", - "semanticUrl": "Semantic URL" - } - }, - "seo-detail": { - "title-new": "New SEO", - "subtitle": "SEO details", - "labels": { - "is-active": "Is active", - "store": "Store", - "language": "Language", - "url-keyword": "URL keyword", - "page-title": "Page title", - "meta-description": "Meta description", - "meta-keywords": "Meta keywords", - "alternative-text": "Image alternative text" - }, - "placeholders": { - "store": "Select Store", - "language": "Select Language", - "url-keyword": "Enter keyword", - "page-title": "Enter title", - "meta-description": "Enter description", - "meta-keywords": "Enter keywords", - "alternative-text": "Enter text" - }, - "validations": { - "url-keyword-required": "Required", - "url-keyword-invalid": "Invalid characters in URL found", - "url-keyword-duplicate": "Duplicate URL found" - } - }, - "seo-duplicates": { - "subtitle": "SEO conflicts", - "labels": { - "semanticUrl": "Semantic URL", - "container": "Store" - } - }, - "package-type-list": { - "title": "Predefined package size dimensions", - "subtitle": "Manage system packages types", - "labels": { - "no-packages": "No predefined packages" - } - }, - "package-type-detail": { - "new-title": "New package type", - "new-subtitle": "Enter package size values", - "subtitle": "Edit package size details", - "labels": { - "name": "Package type name", - "name-description": "will be used for identification", - "name-placeholder": "Enter package type name", - "measureUnit": "Measure unit", - "measureUnit-description": "will be used as primary measure unit for sizes", - "measureUnit-placeholder": "Choose measure unit or define new", - "width": "Width", - "height": "Height", - "length": "Length" - } - }, - "document-type-list": { - "title": "Document types", - "labels": { - "document-type": "Document type", - "indexed-docs-total": "Docs count", - "provider": "Provider", - "scope": "Scope", - "last-indexation-date": "Last indexed", - "build-index": "Build index", - "rebuild-index": "Rebuild index" - } - } - }, - "dialogs": { - "reindex": { - "title": "Build Search Index", - "msg1": "Choose how to update the Search Index. Options:", - "msg2": "Build: index for all data without recreating.", - "msg3": "Delete + build: Current search index will be deleted and built from scratch. Note that there WON'T BE ANY SEARCH RESULTS until the build process finishes.", - "index": "Build", - "reindex": "Delete + build" - }, - "address-delete": { - "title": "Delete confirmation", - "message": "Are you sure you want to delete this Address?" - }, - "address-save": { - "title": "Save changes", - "message": "The Address has been modified. Do you want to save changes?" - }, - "currency-delete": { - "title": "Delete confirmation", - "message": "Are you sure you want to delete this Currency?" - }, - "currency-save": { - "title": "Save changes", - "message": "The Currency has been modified. Do you want to save changes?" - }, - "fulfillment-delete": { - "title": "Delete confirmation", - "message": "Are you sure you want to delete this Fulfillment center?" - }, - "fulfillments-save": { - "title": "Save changes", - "message": "The fulfillments has been modified. Do you want to save changes?" - }, - "seo-save": { - "title": "Save changes", - "message": "The SEO information has been modified. Do you want to save changes?" - }, - "package-type-save": { - "title": "Save changes", - "message": "The package type information has been modified. Do you want to save changes?" - }, - "package-type-delete": { - "title": "Delete confirmation", - "message": "Are you sure you want to delete this package type?" - } - }, - "widgets": { - "index": { - "index-ok": "Indexed ", - "index-old": "Outdated. Index was built ", - "no-index": "Search index missing" - }, - "currency": { - "title": "Currencies" - }, - "fulfillmentCenterContact": { - "blade-subtitle": "Contact information", - "title": "Contact information" - }, - "fulfillment": { - "title": "Fulfillment centers" - }, - "seo": { - "title": "SEO" - } - } + "core": { + "commands": { + "apply-filter": "Save & apply", + "rebuild-index": "Build Index" }, - "permissions": { - "core:packageType:create": "Create packageType related data", - "core:packageType:update": "Update packageType related data", - "core:packageType:delete": "Delete packageType related data", - "core:currency:create": "Create currency related data", - "core:currency:update": "Update currency related data", - "core:currency:delete": "Delete currency related data" + "main-menu-title": { + "search-index": "Search index" }, - "settings": { - "VirtoCommerce.Core.General.TaxTypes": { - "description": "Tax types available in system", - "title": "Tax types" + "blades": { + "index-progress": { + "labels": { + "start": "Start", + "end": "End", + "errors": "Errors", + "stats": "Indexed - {{ processedCount }} of {{ totalCount }} documents" + } + }, + "index-detail": { + "title": "Search index", + "title-new": "Search index missing", + "subtitle": "Search index details", + "labels": { + "no-index": "Index not found", + "build-date": "Last indexed", + "content": "Index content" + } + }, + "address-list": { + "labels": { + "no-addresses": "No Addresses yet" + } + }, + "address-detail": { + "subtitle": "Edit address", + "labels": { + "name": "Address Name", + "address-type": "Address type", + "first-name": "First name", + "last-name": "Last name", + "country": "Country", + "region": "Region", + "city": "City", + "address1": "Address line 1", + "address2": "Address line 2", + "zip-code": "Zip code", + "email": "Email", + "phone": "Phone" }, - "VirtoCommerce.Core.General.WeightUnits": { - "description": "Mass units available for physical goods weighting", - "title": "Mass units" + "placeholders": { + "address-type": "Select...", + "country": "Select...", + "region": "Select..." + } + }, + "currency-list": { + "title": "Currencies", + "subtitle": "Manage system currencies", + "labels": { + "exchange-rate": "Exchange rate:", + "no-currencies": "No currencies" + } + }, + "currency-detail": { + "new-title": "New currency", + "new-subtitle": "Enter currency details", + "subtitle": "Edit currency details", + "labels": { + "code": "Code", + "name": "Name", + "is-primary": "Is primary", + "exchange-rate": "Exchange rate", + "symbol": "Symbol", + "custom-formatting": "Currency custom formatting" }, - "VirtoCommerce.Core.General.MeasureUnits": { - "description": "Measure units available for measuring length", - "title": "Units of length" + "descriptions": { + "code": "The currency code. Use 3 letter ISO 4217 code, if it exists.", + "name": "The name of the currency.", + "is-primary": "Is this the primary currency? Only one currency can by primary.", + "exchange-rate": "The exchange rate against the primary exchange rate currency", + "symbol": "Short currency symbol", + "custom-formatting": "Custom formatting to be applied to the currency value" }, - "VirtoCommerce.Core.General.Languages": { - "description": "Languages available in the platform", - "title": "Languages" + "placeholders": { + "symbol": "Enter symbol or leave empty for default culture", + "code": "Enter currency code", + "name": "Enter currency name", + "exchange-rate": "Enter exchange rate against the primary currency", + "custom-formatting": "0,0.000" + }, + "validation": { + "maxlength": "Currency code must have only 3 symbols" + } + }, + "fulfillment-center-contact": { + "labels": { + "country": "Country", + "region": "Region", + "city": "City", + "address": "Address", + "zip-code": "Zip code", + "phone": "Phone" }, - "VirtoCommerce.Core.FixedRateShippingMethod.Ground.Rate": { - "description": "Fixed Ground shipping rate", - "title": "Ground shipping rate" + "placeholders": { + "country": "Select...", + "region": "Enter region", + "city": "Enter city", + "address1": "Enter address line 1", + "address2": "Enter address line 2", + "zip-code": "Enter postal code", + "phone": "Enter phone number" + } + }, + "fulfillment-center-detail": { + "subtitle": "Edit Fulfillment center", + "labels": { + "name": "Name", + "description": "Description", + "max-releases": "Max. releases per pick batch", + "pick-delay": "Pick delay" + } + }, + "fulfillment-center-list": { + "title": "Fulfillment centers", + "subtitle": "Manage Fulfillment centers" + }, + "seo-list": { + "subtitle": "Manage SEOs", + "labels": { + "duplicates-found": "There are {{count}} conflicting Semantic URLs!", + "resolve-duplicates": "Resolve conflicts", + "language-code": "Language", + "container": "Store", + "semanticUrl": "Semantic URL" + } + }, + "seo-detail": { + "title-new": "New SEO", + "subtitle": "SEO details", + "labels": { + "is-active": "Is active", + "store": "Store", + "language": "Language", + "url-keyword": "URL keyword", + "page-title": "Page title", + "meta-description": "Meta description", + "meta-keywords": "Meta keywords", + "alternative-text": "Image alternative text" }, - "VirtoCommerce.Core.FixedRateShippingMethod.Air.Rate": { - "description": "Fixed Air shipping rate", - "title": "Air shipping rate" + "placeholders": { + "store": "Select Store", + "language": "Select Language", + "url-keyword": "Enter keyword", + "page-title": "Enter title", + "meta-description": "Enter description", + "meta-keywords": "Enter keywords", + "alternative-text": "Enter text" }, - "VirtoCommerce.Core.FixedTaxRateProvider.Rate": { - "description": "Fixed tax rate", - "title": "Fixed tax rate %" + "validations": { + "url-keyword-required": "Required", + "url-keyword-invalid": "Invalid characters in URL found", + "url-keyword-duplicate": "Duplicate URL found" } - }, - "module": { - "VirtoCommerce.Core": { - "description": "Export/Import fulfillment centers" + }, + "seo-duplicates": { + "subtitle": "SEO conflicts", + "labels": { + "semanticUrl": "Semantic URL", + "container": "Store" + } + }, + "package-type-list": { + "title": "Predefined package size dimensions", + "subtitle": "Manage system packages types", + "labels": { + "no-packages": "No predefined packages" + } + }, + "package-type-detail": { + "new-title": "New package type", + "new-subtitle": "Enter package size values", + "subtitle": "Edit package size details", + "labels": { + "name": "Package type name", + "name-description": "will be used for identification", + "name-placeholder": "Enter package type name", + "measureUnit": "Measure unit", + "measureUnit-description": "will be used as primary measure unit for sizes", + "measureUnit-placeholder": "Choose measure unit or define new", + "width": "Width", + "height": "Height", + "length": "Length" + } + }, + "document-type-list": { + "title": "Document types", + "labels": { + "document-type": "Document type", + "indexed-docs-total": "Docs count", + "provider": "Provider", + "scope": "Scope", + "last-indexation-date": "Last indexed", + "build-index": "Build index", + "rebuild-index": "Rebuild index" } + } + }, + "dialogs": { + "reindex": { + "title": "Build Search Index", + "msg1": "Choose how to update the Search Index. Options:", + "msg2": "Build: index for all data without recreating.", + "msg3": "Delete + build: Current search index will be deleted and built from scratch. Note that there WON'T BE ANY SEARCH RESULTS until the build process finishes.", + "index": "Build", + "reindex": "Delete + build" + }, + "address-delete": { + "title": "Delete confirmation", + "message": "Are you sure you want to delete this Address?" + }, + "address-save": { + "title": "Save changes", + "message": "The Address has been modified. Do you want to save changes?" + }, + "currency-delete": { + "title": "Delete confirmation", + "message": "Are you sure you want to delete this Currency?" + }, + "currency-save": { + "title": "Save changes", + "message": "The Currency has been modified. Do you want to save changes?" + }, + "fulfillment-delete": { + "title": "Delete confirmation", + "message": "Are you sure you want to delete this Fulfillment center?" + }, + "fulfillments-save": { + "title": "Save changes", + "message": "The fulfillments has been modified. Do you want to save changes?" + }, + "seo-save": { + "title": "Save changes", + "message": "The SEO information has been modified. Do you want to save changes?" + }, + "package-type-save": { + "title": "Save changes", + "message": "The package type information has been modified. Do you want to save changes?" + }, + "package-type-delete": { + "title": "Delete confirmation", + "message": "Are you sure you want to delete this package type?" + } + }, + "widgets": { + "index": { + "index-ok": "Indexed ", + "index-old": "Outdated. Index was built ", + "no-index": "Search index missing" + }, + "currency": { + "title": "Currencies" + }, + "fulfillmentCenterContact": { + "blade-subtitle": "Contact information", + "title": "Contact information" + }, + "fulfillment": { + "title": "Fulfillment centers" + }, + "seo": { + "title": "SEO" + } + } + }, + "permissions": { + "core:packageType:create": "Create packageType related data", + "core:packageType:update": "Update packageType related data", + "core:packageType:delete": "Delete packageType related data", + "core:currency:create": "Create currency related data", + "core:currency:update": "Update currency related data", + "core:currency:delete": "Delete currency related data" + }, + "settings": { + "VirtoCommerce.Core.General.TaxTypes": { + "description": "Tax types available in system", + "title": "Tax types" + }, + "VirtoCommerce.Core.General.WeightUnits": { + "description": "Mass units available for physical goods weighting", + "title": "Mass units" + }, + "VirtoCommerce.Core.General.MeasureUnits": { + "description": "Measure units available for measuring length", + "title": "Units of length" + }, + "VirtoCommerce.Core.General.Languages": { + "description": "Languages available in the platform", + "title": "Languages" + }, + "VirtoCommerce.Core.FixedRateShippingMethod.Ground.Rate": { + "description": "Fixed Ground shipping rate", + "title": "Ground shipping rate" + }, + "VirtoCommerce.Core.FixedRateShippingMethod.Air.Rate": { + "description": "Fixed Air shipping rate", + "title": "Air shipping rate" + }, + "VirtoCommerce.Core.FixedTaxRateProvider.Rate": { + "description": "Fixed tax rate", + "title": "Fixed tax rate %" + } + }, + "module": { + "VirtoCommerce.Core": { + "description": "Export/Import fulfillment centers" } + } } diff --git a/src/VirtoCommerce.CoreModule.Web/Scripts/common/blades/address-detail.js b/src/VirtoCommerce.CoreModule.Web/Scripts/common/blades/address-detail.js index 5f77ba4b2..1e64a6410 100644 --- a/src/VirtoCommerce.CoreModule.Web/Scripts/common/blades/address-detail.js +++ b/src/VirtoCommerce.CoreModule.Web/Scripts/common/blades/address-detail.js @@ -1,5 +1,5 @@ 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) { + .controller('virtoCommerce.coreModule.common.coreAddressDetailController', ['$scope', '$filter', 'platformWebApp.common.countries', 'platformWebApp.dialogService', 'platformWebApp.metaFormsService', 'platformWebApp.bladeNavigationService', function ($scope, $filter, countries, dialogService, metaFormsService, bladeNavigationService) { var blade = $scope.blade; blade.addressTypes = ['Billing', 'Shipping', 'BillingAndShipping']; @@ -10,6 +10,72 @@ angular.module('virtoCommerce.coreModule.common') blade.origEntity = blade.currentEntity; blade.currentEntity = angular.copy(blade.origEntity); blade.countries = countries.query(); + blade.countries.$promise.then( + (allCountries) => { + $scope.$watch('blade.currentEntity.countryCode', (countryCode, old) => { + if (countryCode) { + var country = _.findWhere(allCountries, { id: countryCode }); + if (country) { + blade.currentEntity.countryName = country.name; + + if (countryCode !== old) { + blade.currentEntity.regionName = undefined; + currentRegions = []; + } + + if (country.regions) { + currentRegions = country.regions; + } else { + countries.queryRegions(countryCode).$promise.then((regions) => { + country.regions = regions; + currentRegions.push(...regions); + }); + } + } + } + }); + } + ); + + var currentRegions = []; + if (blade.currentEntity.regionName && !blade.currentEntity.regionId) { + addRegion(currentRegions, blade.currentEntity.regionName); + } + + blade.getRegions = function (search) { + var results = currentRegions; + if (search && search.length > 1) { + var filtered = $filter('filter')(results, search); + if (!_.some(filtered)) { + addRegion(results, search); + } else if (filtered.length > 1) { // remove other (added) records + filtered = _.filter(filtered, (x) => !x.id && x.displayName.length > search.length); + for (var x of filtered) { + results.splice(_.indexOf(results, x), 1); + } + } + } + + return results; + }; + + function addRegion(regions, name) { + regions.unshift({ name: name, displayName: name }); + } + + $scope.$watch('blade.currentEntity.regionName', function (regionName, old) { + if (regionName === old) return; + + var newId = null; + if (regionName) { + var region = _.findWhere(currentRegions, { name: regionName }); + if (region) { + newId = region.id; + } + } + + blade.currentEntity.regionId = newId; + }); blade.toolbarCommands = [{ name: "platform.commands.reset", icon: 'fa fa-undo', @@ -46,18 +112,11 @@ angular.module('virtoCommerce.coreModule.common') $scope.saveChanges = function () { if (blade.confirmChangesFn) { blade.confirmChangesFn(blade.currentEntity); - }; + } 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; - } - }); - function isDirty() { return !angular.equals(blade.currentEntity, blade.origEntity); } @@ -75,7 +134,7 @@ angular.module('virtoCommerce.coreModule.common') if (remove) { if (blade.deleteFn) { blade.deleteFn(blade.currentEntity); - }; + } $scope.bladeClose(); } } diff --git a/src/VirtoCommerce.CoreModule.Web/Scripts/common/blades/address-detail.tpl.html b/src/VirtoCommerce.CoreModule.Web/Scripts/common/blades/address-detail.tpl.html index 1d2905130..d19375810 100644 --- a/src/VirtoCommerce.CoreModule.Web/Scripts/common/blades/address-detail.tpl.html +++ b/src/VirtoCommerce.CoreModule.Web/Scripts/common/blades/address-detail.tpl.html @@ -31,3 +31,14 @@ + diff --git a/src/VirtoCommerce.CoreModule.Web/Scripts/common/common.js b/src/VirtoCommerce.CoreModule.Web/Scripts/common/common.js index 8ae3aaef2..8e599f3a6 100644 --- a/src/VirtoCommerce.CoreModule.Web/Scripts/common/common.js +++ b/src/VirtoCommerce.CoreModule.Web/Scripts/common/common.js @@ -1,7 +1,6 @@ angular.module('virtoCommerce.coreModule.common', []) .run(['platformWebApp.metaFormsService', function (metaFormsService) { metaFormsService.registerMetaFields('addressDetails', [{ - name: 'addressType', templateUrl: 'addressTypeSelector.html', priority: 0 }, { @@ -17,14 +16,10 @@ angular.module('virtoCommerce.coreModule.common', []) isRequired: true, priority: 2 }, { - name: 'countryCode', templateUrl: 'countrySelector.html', priority: 3 }, { - name: 'regionName', - title: 'core.blades.address-detail.labels.region', - valueType: 'ShortText', - isRequired: true, + templateUrl: 'countryRegionSelector.html', priority: 4 }, { name: 'city', diff --git a/src/VirtoCommerce.CoreModule.Web/module.manifest b/src/VirtoCommerce.CoreModule.Web/module.manifest index b0b2c6a4e..a9bd14fa8 100644 --- a/src/VirtoCommerce.CoreModule.Web/module.manifest +++ b/src/VirtoCommerce.CoreModule.Web/module.manifest @@ -1,9 +1,9 @@ VirtoCommerce.Core - 3.17.0 + 3.18.0 - 3.60.0 + 3.66.0 Commerce core module Common e-commerce domain functionality diff --git a/src/VirtoCommerce.CoreModule.Web/package-lock.json b/src/VirtoCommerce.CoreModule.Web/package-lock.json index c8d76e9cb..6b3aca1a6 100644 --- a/src/VirtoCommerce.CoreModule.Web/package-lock.json +++ b/src/VirtoCommerce.CoreModule.Web/package-lock.json @@ -1974,7 +1974,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -1995,12 +1996,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2015,17 +2018,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2142,7 +2148,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2154,6 +2161,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2168,6 +2176,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2175,12 +2184,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2199,6 +2210,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2279,7 +2291,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2291,6 +2304,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2376,7 +2390,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -2412,6 +2427,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2431,6 +2447,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2474,12 +2491,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } },