@etsoo/appscript 1.3.6 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/app/CoreApp.ts +5 -16
- package/lib/cjs/address/AddressUtils.d.ts +0 -20
- package/lib/cjs/address/AddressUtils.js +0 -60
- package/lib/cjs/app/CoreApp.d.ts +10 -0
- package/lib/cjs/app/CoreApp.js +18 -2
- package/lib/cjs/app/IApp.d.ts +6 -0
- package/lib/cjs/erp/AddressApi.d.ts +12 -8
- package/lib/cjs/erp/AddressApi.js +23 -25
- package/lib/cjs/i18n/en-US.json +19 -0
- package/lib/cjs/i18n/zh-CN.json +19 -0
- package/lib/cjs/i18n/zh-HK.json +19 -0
- package/lib/mjs/address/AddressUtils.d.ts +0 -20
- package/lib/mjs/address/AddressUtils.js +0 -37
- package/lib/mjs/app/CoreApp.d.ts +10 -0
- package/lib/mjs/app/CoreApp.js +18 -2
- package/lib/mjs/app/IApp.d.ts +6 -0
- package/lib/mjs/erp/AddressApi.d.ts +12 -8
- package/lib/mjs/erp/AddressApi.js +23 -25
- package/lib/mjs/i18n/en-US.json +19 -0
- package/lib/mjs/i18n/zh-CN.json +19 -0
- package/lib/mjs/i18n/zh-HK.json +19 -0
- package/package.json +3 -3
- package/src/address/AddressUtils.ts +0 -45
- package/src/app/CoreApp.ts +20 -1
- package/src/app/IApp.ts +7 -0
- package/src/erp/AddressApi.ts +16 -19
- package/src/i18n/en-US.json +19 -0
- package/src/i18n/zh-CN.json +19 -0
- package/src/i18n/zh-HK.json +19 -0
- package/src/i18n/address.en-US.json +0 -21
- package/src/i18n/address.zh-CN.json +0 -21
- package/src/i18n/address.zh-HK.json +0 -21
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -143,6 +143,10 @@ const appClass = EnhanceApp(CoreAppTest);
|
|
|
143
143
|
const app = new appClass();
|
|
144
144
|
app.changeCulture(app.settings.cultures[0]);
|
|
145
145
|
|
|
146
|
+
test('Test for properties', () => {
|
|
147
|
+
expect(app.settings.currentRegion.label).toBe('中国大陆');
|
|
148
|
+
});
|
|
149
|
+
|
|
146
150
|
test('Tests for addRootUrl', () => {
|
|
147
151
|
expect(app.addRootUrl('/home')).toBe('/cms/home');
|
|
148
152
|
expect(app.addRootUrl('./home')).toBe('/cms/./home');
|
|
@@ -201,10 +205,7 @@ test('Tests for addressApi', async () => {
|
|
|
201
205
|
const continents = await app.addressApi.continents();
|
|
202
206
|
expect(continents.length).toBe(7);
|
|
203
207
|
|
|
204
|
-
const
|
|
205
|
-
expect(labels['regionHK']).toBe('Hong Kong, China');
|
|
206
|
-
|
|
207
|
-
const regions = await app.addressApi.regions('zh-CN');
|
|
208
|
+
const regions = await app.addressApi.regions();
|
|
208
209
|
const cn = regions.find((r) => r.id === 'CN');
|
|
209
210
|
expect(cn?.label).toBe('中国大陆');
|
|
210
211
|
});
|
|
@@ -217,16 +218,4 @@ test('Tests for publicApi', async () => {
|
|
|
217
218
|
|
|
218
219
|
const currencies = await app.publicApi.currencies(['NZD', 'AUD', 'USD']);
|
|
219
220
|
expect(currencies[1].id).toBe('AUD');
|
|
220
|
-
|
|
221
|
-
//const currenciesRemote = await app.publicApi.currencies();
|
|
222
|
-
//console.log(currenciesRemote);
|
|
223
|
-
|
|
224
|
-
//const history = await app.publicApi.exchangeRateHistory(['NZD', 'AUD'], 24);
|
|
225
|
-
//console.log(history);
|
|
226
|
-
|
|
227
|
-
//const qrcode = await app.publicApi.mobileQRCode('xz@etsoo.com');
|
|
228
|
-
//console.log(qrcode);
|
|
229
|
-
|
|
230
|
-
//const exchangeRate = await app.publicApi.exchangeRate('USD');
|
|
231
|
-
//console.log(exchangeRate);
|
|
232
221
|
});
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
1
|
import { AddressRegion } from './AddressRegion';
|
|
3
2
|
/**
|
|
4
3
|
* Address utils
|
|
5
4
|
*/
|
|
6
5
|
export declare namespace AddressUtils {
|
|
7
|
-
/**
|
|
8
|
-
* Get address labels
|
|
9
|
-
* @param language Language
|
|
10
|
-
* @returns Result
|
|
11
|
-
*/
|
|
12
|
-
function getLabels(language: string): Promise<DataTypes.StringRecord>;
|
|
13
6
|
/**
|
|
14
7
|
* Get region from regions and detected region and language
|
|
15
8
|
* @param regions Supported regions
|
|
@@ -17,17 +10,4 @@ export declare namespace AddressUtils {
|
|
|
17
10
|
* @param detectedLanguage Detected language
|
|
18
11
|
*/
|
|
19
12
|
function getRegion(regions: string[], detectedRegion?: string | null, detectedLanguage?: string | null): AddressRegion;
|
|
20
|
-
/**
|
|
21
|
-
* Get region label
|
|
22
|
-
* @param id Region id
|
|
23
|
-
* @param labels Labels
|
|
24
|
-
* @returns Label
|
|
25
|
-
*/
|
|
26
|
-
function getRegionLabel(id: string, labels: DataTypes.StringRecord): string;
|
|
27
|
-
/**
|
|
28
|
-
* Update region label
|
|
29
|
-
* @param region Region
|
|
30
|
-
* @param culture Culture
|
|
31
|
-
*/
|
|
32
|
-
function updateRegionLabel(region: AddressRegion, culture: string): Promise<void>;
|
|
33
13
|
}
|
|
@@ -1,51 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.AddressUtils = void 0;
|
|
27
4
|
const AddressRegion_1 = require("./AddressRegion");
|
|
28
|
-
const languageLabels = {};
|
|
29
5
|
/**
|
|
30
6
|
* Address utils
|
|
31
7
|
*/
|
|
32
8
|
var AddressUtils;
|
|
33
9
|
(function (AddressUtils) {
|
|
34
|
-
/**
|
|
35
|
-
* Get address labels
|
|
36
|
-
* @param language Language
|
|
37
|
-
* @returns Result
|
|
38
|
-
*/
|
|
39
|
-
async function getLabels(language) {
|
|
40
|
-
let labels = languageLabels[language];
|
|
41
|
-
if (labels == null) {
|
|
42
|
-
labels = await Promise.resolve().then(() => __importStar(require(`./../i18n/address.${language}.json`)));
|
|
43
|
-
// Cache
|
|
44
|
-
languageLabels[language] = labels;
|
|
45
|
-
}
|
|
46
|
-
return labels;
|
|
47
|
-
}
|
|
48
|
-
AddressUtils.getLabels = getLabels;
|
|
49
10
|
/**
|
|
50
11
|
* Get region from regions and detected region and language
|
|
51
12
|
* @param regions Supported regions
|
|
@@ -71,25 +32,4 @@ var AddressUtils;
|
|
|
71
32
|
return AddressRegion_1.AddressRegion.getById(regions[0]);
|
|
72
33
|
}
|
|
73
34
|
AddressUtils.getRegion = getRegion;
|
|
74
|
-
/**
|
|
75
|
-
* Get region label
|
|
76
|
-
* @param id Region id
|
|
77
|
-
* @param labels Labels
|
|
78
|
-
* @returns Label
|
|
79
|
-
*/
|
|
80
|
-
function getRegionLabel(id, labels) {
|
|
81
|
-
var _a;
|
|
82
|
-
return (_a = labels['region' + id]) !== null && _a !== void 0 ? _a : id;
|
|
83
|
-
}
|
|
84
|
-
AddressUtils.getRegionLabel = getRegionLabel;
|
|
85
|
-
/**
|
|
86
|
-
* Update region label
|
|
87
|
-
* @param region Region
|
|
88
|
-
* @param culture Culture
|
|
89
|
-
*/
|
|
90
|
-
async function updateRegionLabel(region, culture) {
|
|
91
|
-
const labels = await AddressUtils.getLabels(culture);
|
|
92
|
-
region.label = getRegionLabel(region.id, labels);
|
|
93
|
-
}
|
|
94
|
-
AddressUtils.updateRegionLabel = updateRegionLabel;
|
|
95
35
|
})(AddressUtils = exports.AddressUtils || (exports.AddressUtils = {}));
|
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -216,6 +216,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
216
216
|
* @param culture New culture definition
|
|
217
217
|
*/
|
|
218
218
|
changeCulture(culture: DataTypes.CultureDefinition): void;
|
|
219
|
+
/**
|
|
220
|
+
* Update current region label
|
|
221
|
+
*/
|
|
222
|
+
protected updateRegionLabel(): void;
|
|
219
223
|
/**
|
|
220
224
|
* Check language is supported or not, return a valid language when supported
|
|
221
225
|
* @param language Language
|
|
@@ -360,6 +364,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
360
364
|
* @returns List
|
|
361
365
|
*/
|
|
362
366
|
protected getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): ListType1[];
|
|
367
|
+
/**
|
|
368
|
+
* Get region label
|
|
369
|
+
* @param id Region id
|
|
370
|
+
* @returns Label
|
|
371
|
+
*/
|
|
372
|
+
getRegionLabel(id: string): string;
|
|
363
373
|
/**
|
|
364
374
|
* Get all regions
|
|
365
375
|
* @returns Regions
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -6,7 +6,6 @@ const restclient_1 = require("@etsoo/restclient");
|
|
|
6
6
|
const shared_1 = require("@etsoo/shared");
|
|
7
7
|
const crypto_js_1 = require("crypto-js");
|
|
8
8
|
const AddressRegion_1 = require("../address/AddressRegion");
|
|
9
|
-
const AddressUtils_1 = require("../address/AddressUtils");
|
|
10
9
|
const BridgeUtils_1 = require("../bridges/BridgeUtils");
|
|
11
10
|
const EntityStatus_1 = require("../business/EntityStatus");
|
|
12
11
|
const ActionResultError_1 = require("../result/ActionResultError");
|
|
@@ -487,8 +486,8 @@ class CoreApp {
|
|
|
487
486
|
this._currency = regionItem.currency;
|
|
488
487
|
this._region = regionId;
|
|
489
488
|
// Hold the current country or region
|
|
490
|
-
AddressUtils_1.AddressUtils.updateRegionLabel(regionItem, this._culture);
|
|
491
489
|
this.settings.currentRegion = regionItem;
|
|
490
|
+
this.updateRegionLabel();
|
|
492
491
|
}
|
|
493
492
|
/**
|
|
494
493
|
* Change culture
|
|
@@ -509,6 +508,14 @@ class CoreApp {
|
|
|
509
508
|
this._culture = name;
|
|
510
509
|
// Hold the current resources
|
|
511
510
|
this.settings.currentCulture = culture;
|
|
511
|
+
this.updateRegionLabel();
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Update current region label
|
|
515
|
+
*/
|
|
516
|
+
updateRegionLabel() {
|
|
517
|
+
const region = this.settings.currentRegion;
|
|
518
|
+
region.label = this.getRegionLabel(region.id);
|
|
512
519
|
}
|
|
513
520
|
/**
|
|
514
521
|
* Check language is supported or not, return a valid language when supported
|
|
@@ -896,6 +903,15 @@ class CoreApp {
|
|
|
896
903
|
}
|
|
897
904
|
return list;
|
|
898
905
|
}
|
|
906
|
+
/**
|
|
907
|
+
* Get region label
|
|
908
|
+
* @param id Region id
|
|
909
|
+
* @returns Label
|
|
910
|
+
*/
|
|
911
|
+
getRegionLabel(id) {
|
|
912
|
+
var _a;
|
|
913
|
+
return (_a = this.get('region' + id)) !== null && _a !== void 0 ? _a : id;
|
|
914
|
+
}
|
|
899
915
|
/**
|
|
900
916
|
* Get all regions
|
|
901
917
|
* @returns Regions
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -284,6 +284,12 @@ export interface IApp {
|
|
|
284
284
|
* @returns Cached token
|
|
285
285
|
*/
|
|
286
286
|
getCacheToken(): string | undefined;
|
|
287
|
+
/**
|
|
288
|
+
* Get region label
|
|
289
|
+
* @param id Region id
|
|
290
|
+
* @returns Label
|
|
291
|
+
*/
|
|
292
|
+
getRegionLabel(id: string): string;
|
|
287
293
|
/**
|
|
288
294
|
* Get all regions
|
|
289
295
|
* @returns Regions
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AddressContinent } from '../address/AddressContinent';
|
|
1
2
|
import { AddressRegion, AddressRegionDb } from '../address/AddressRegion';
|
|
2
3
|
import { AddressState } from '../address/AddressState';
|
|
3
4
|
import { IdLabelConditional } from '../dto/IdLabelDto';
|
|
@@ -8,23 +9,26 @@ import { BaseApi } from './BaseApi';
|
|
|
8
9
|
export declare class AddressApi extends BaseApi {
|
|
9
10
|
/**
|
|
10
11
|
* Get all continents
|
|
11
|
-
* @param language Language
|
|
12
12
|
* @param isNumberKey Is number key or key as id
|
|
13
13
|
* @returns Continents
|
|
14
14
|
*/
|
|
15
|
-
continents<T extends boolean>(
|
|
15
|
+
continents<T extends boolean>(isNumberKey?: T): Promise<IdLabelConditional<T>>;
|
|
16
16
|
/**
|
|
17
|
-
* Get
|
|
18
|
-
* @param
|
|
17
|
+
* Get continent label
|
|
18
|
+
* @param id Region id
|
|
19
|
+
* @returns Label
|
|
20
|
+
*/
|
|
21
|
+
getContinentLabel(id: AddressContinent | string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Get region list
|
|
19
24
|
* @param isLocal Is local version
|
|
20
25
|
* @returns Result
|
|
21
26
|
*/
|
|
22
|
-
regions<T extends boolean = true>(
|
|
27
|
+
regions<T extends boolean = true>(isLocal?: T): Promise<T extends true | undefined ? AddressRegion[] : AddressRegionDb[] | undefined>;
|
|
23
28
|
/**
|
|
24
|
-
* Get state list
|
|
29
|
+
* Get state list
|
|
25
30
|
* @param regionId Region id
|
|
26
|
-
* @param language Language
|
|
27
31
|
* @returns Result
|
|
28
32
|
*/
|
|
29
|
-
states(regionId: string
|
|
33
|
+
states(regionId: string): Promise<AddressState[] | undefined>;
|
|
30
34
|
}
|
|
@@ -4,7 +4,6 @@ exports.AddressApi = void 0;
|
|
|
4
4
|
const shared_1 = require("@etsoo/shared");
|
|
5
5
|
const AddressContinent_1 = require("../address/AddressContinent");
|
|
6
6
|
const AddressRegion_1 = require("../address/AddressRegion");
|
|
7
|
-
const AddressUtils_1 = require("../address/AddressUtils");
|
|
8
7
|
const BaseApi_1 = require("./BaseApi");
|
|
9
8
|
/**
|
|
10
9
|
* Address Api
|
|
@@ -12,50 +11,49 @@ const BaseApi_1 = require("./BaseApi");
|
|
|
12
11
|
class AddressApi extends BaseApi_1.BaseApi {
|
|
13
12
|
/**
|
|
14
13
|
* Get all continents
|
|
15
|
-
* @param language Language
|
|
16
14
|
* @param isNumberKey Is number key or key as id
|
|
17
15
|
* @returns Continents
|
|
18
16
|
*/
|
|
19
|
-
async continents(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
async continents(isNumberKey = false) {
|
|
18
|
+
return shared_1.DataTypes.getEnumKeys(AddressContinent_1.AddressContinent).map((key) => ({
|
|
19
|
+
id: isNumberKey
|
|
20
|
+
? shared_1.DataTypes.getEnumByKey(AddressContinent_1.AddressContinent, key)
|
|
21
|
+
: key.toString(),
|
|
22
|
+
label: this.getContinentLabel(key)
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get continent label
|
|
27
|
+
* @param id Region id
|
|
28
|
+
* @returns Label
|
|
29
|
+
*/
|
|
30
|
+
getContinentLabel(id) {
|
|
31
|
+
var _a;
|
|
32
|
+
return (_a = this.app.get('continent' + id)) !== null && _a !== void 0 ? _a : id;
|
|
30
33
|
}
|
|
31
34
|
/**
|
|
32
|
-
* Get region list
|
|
33
|
-
* @param language Language
|
|
35
|
+
* Get region list
|
|
34
36
|
* @param isLocal Is local version
|
|
35
37
|
* @returns Result
|
|
36
38
|
*/
|
|
37
|
-
async regions(
|
|
38
|
-
language = this.app.checkLanguage(language);
|
|
39
|
+
async regions(isLocal) {
|
|
39
40
|
if (isLocal == null || isLocal) {
|
|
40
|
-
const labels = await AddressUtils_1.AddressUtils.getLabels(language);
|
|
41
41
|
return AddressRegion_1.AddressRegion.all.map((region) => {
|
|
42
|
-
region.label =
|
|
42
|
+
region.label = this.app.getRegionLabel(region.id);
|
|
43
43
|
return { ...region };
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
-
return (await this.app.api.get(`Address/RegionList?language=${
|
|
47
|
+
return (await this.app.api.get(`Address/RegionList?language=${this.app.culture}`, undefined, { defaultValue: [] }));
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* Get state list
|
|
51
|
+
* Get state list
|
|
52
52
|
* @param regionId Region id
|
|
53
|
-
* @param language Language
|
|
54
53
|
* @returns Result
|
|
55
54
|
*/
|
|
56
|
-
states(regionId
|
|
57
|
-
|
|
58
|
-
return this.app.api.get(`Address/StateList?regionId=${regionId}&language=${language}`, undefined, { defaultValue: [] });
|
|
55
|
+
states(regionId) {
|
|
56
|
+
return this.app.api.get(`Address/StateList?regionId=${regionId}&language=${this.app.culture}`, undefined, { defaultValue: [] });
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
59
|
exports.AddressApi = AddressApi;
|
package/lib/cjs/i18n/en-US.json
CHANGED
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
"confirm": "Confirm",
|
|
16
16
|
"confirmAction": "Are you sure you want to {0}?",
|
|
17
17
|
"completeTip": "{0} completed",
|
|
18
|
+
"continentAF": "Africa",
|
|
19
|
+
"continentAN": "Antarctica",
|
|
20
|
+
"continentAS": "Asia",
|
|
21
|
+
"continentEU": "Europe",
|
|
22
|
+
"continentNA": "North America",
|
|
23
|
+
"continentOC": "Oceania",
|
|
24
|
+
"continentSA": "South America",
|
|
18
25
|
"copy": "Copy",
|
|
19
26
|
"creation": "Creation",
|
|
20
27
|
"currentPassword": "Current password",
|
|
@@ -106,6 +113,18 @@
|
|
|
106
113
|
"refresh": "Refresh",
|
|
107
114
|
"refreshing": "Refreshing",
|
|
108
115
|
"releaseToRefresh": "Release to refresh",
|
|
116
|
+
"regionAU": "Australia",
|
|
117
|
+
"regionCA": "Canada",
|
|
118
|
+
"regionCN": "Mainland China",
|
|
119
|
+
"regionDE": "Germany",
|
|
120
|
+
"regionFR": "France",
|
|
121
|
+
"regionGB": "United Kingdom",
|
|
122
|
+
"regionHK": "Hong Kong, China",
|
|
123
|
+
"regionIE": "Ireland",
|
|
124
|
+
"regionJP": "Japan",
|
|
125
|
+
"regionNZ": "New Zealand",
|
|
126
|
+
"regionSG": "Singapore",
|
|
127
|
+
"regionUS": "United States",
|
|
109
128
|
"reloginTip": "Please enter your password, resubmit the data after successful login",
|
|
110
129
|
"remove": "Remove",
|
|
111
130
|
"renew": "Renew",
|
package/lib/cjs/i18n/zh-CN.json
CHANGED
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
"confirm": "确认",
|
|
16
16
|
"confirmAction": "确定要{0}吗?",
|
|
17
17
|
"completeTip": "已完成 {0}",
|
|
18
|
+
"continentAF": "非洲",
|
|
19
|
+
"continentAN": "南极洲",
|
|
20
|
+
"continentAS": "亚洲",
|
|
21
|
+
"continentEU": "欧洲",
|
|
22
|
+
"continentNA": "北美洲",
|
|
23
|
+
"continentOC": "大洋洲",
|
|
24
|
+
"continentSA": "南美洲",
|
|
18
25
|
"copy": "复制",
|
|
19
26
|
"creation": "登记时间",
|
|
20
27
|
"currentPassword": "当前密码",
|
|
@@ -105,6 +112,18 @@
|
|
|
105
112
|
"record": "记录",
|
|
106
113
|
"refresh": "刷新",
|
|
107
114
|
"refreshing": "正在刷新",
|
|
115
|
+
"regionAU": "澳大利亚",
|
|
116
|
+
"regionCA": "加拿大",
|
|
117
|
+
"regionCN": "中国大陆",
|
|
118
|
+
"regionDE": "德国",
|
|
119
|
+
"regionFR": "法国",
|
|
120
|
+
"regionGB": "英国",
|
|
121
|
+
"regionHK": "中国香港",
|
|
122
|
+
"regionIE": "爱尔兰",
|
|
123
|
+
"regionJP": "日本",
|
|
124
|
+
"regionNZ": "新西兰",
|
|
125
|
+
"regionSG": "新加坡",
|
|
126
|
+
"regionUS": "美国",
|
|
108
127
|
"releaseToRefresh": "释放刷新",
|
|
109
128
|
"reloginTip": "请输入您的登录密码,登录成功后请重新提交数据",
|
|
110
129
|
"remove": "移除",
|
package/lib/cjs/i18n/zh-HK.json
CHANGED
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
"confirm": "確認",
|
|
16
16
|
"confirmAction": "確定要{0}嗎?",
|
|
17
17
|
"completeTip": "已完成 {0}",
|
|
18
|
+
"continentAF": "非洲",
|
|
19
|
+
"continentAN": "南極洲",
|
|
20
|
+
"continentAS": "亞洲",
|
|
21
|
+
"continentEU": "歐洲",
|
|
22
|
+
"continentNA": "北美洲",
|
|
23
|
+
"continentOC": "大洋洲",
|
|
24
|
+
"continentSA": "南美洲",
|
|
18
25
|
"copy": "複製",
|
|
19
26
|
"creation": "登記時間",
|
|
20
27
|
"currentPassword": "當前密碼",
|
|
@@ -105,6 +112,18 @@
|
|
|
105
112
|
"record": "記錄",
|
|
106
113
|
"refresh": "刷新",
|
|
107
114
|
"refreshing": "正在刷新",
|
|
115
|
+
"regionAU": "澳大利亞",
|
|
116
|
+
"regionCA": "加拿大",
|
|
117
|
+
"regionCN": "中國大陸",
|
|
118
|
+
"regionDE": "德國",
|
|
119
|
+
"regionFR": "法國",
|
|
120
|
+
"regionGB": "英國",
|
|
121
|
+
"regionHK": "中國香港",
|
|
122
|
+
"regionIE": "愛爾蘭",
|
|
123
|
+
"regionJP": "日本",
|
|
124
|
+
"regionNZ": "新西蘭",
|
|
125
|
+
"regionSG": "新加坡",
|
|
126
|
+
"regionUS": "美國",
|
|
108
127
|
"releaseToRefresh": "釋放刷新",
|
|
109
128
|
"reloginTip": "請輸入您的登錄密碼,登錄成功後請重新提交數據",
|
|
110
129
|
"remove": "移除",
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
1
|
import { AddressRegion } from './AddressRegion';
|
|
3
2
|
/**
|
|
4
3
|
* Address utils
|
|
5
4
|
*/
|
|
6
5
|
export declare namespace AddressUtils {
|
|
7
|
-
/**
|
|
8
|
-
* Get address labels
|
|
9
|
-
* @param language Language
|
|
10
|
-
* @returns Result
|
|
11
|
-
*/
|
|
12
|
-
function getLabels(language: string): Promise<DataTypes.StringRecord>;
|
|
13
6
|
/**
|
|
14
7
|
* Get region from regions and detected region and language
|
|
15
8
|
* @param regions Supported regions
|
|
@@ -17,17 +10,4 @@ export declare namespace AddressUtils {
|
|
|
17
10
|
* @param detectedLanguage Detected language
|
|
18
11
|
*/
|
|
19
12
|
function getRegion(regions: string[], detectedRegion?: string | null, detectedLanguage?: string | null): AddressRegion;
|
|
20
|
-
/**
|
|
21
|
-
* Get region label
|
|
22
|
-
* @param id Region id
|
|
23
|
-
* @param labels Labels
|
|
24
|
-
* @returns Label
|
|
25
|
-
*/
|
|
26
|
-
function getRegionLabel(id: string, labels: DataTypes.StringRecord): string;
|
|
27
|
-
/**
|
|
28
|
-
* Update region label
|
|
29
|
-
* @param region Region
|
|
30
|
-
* @param culture Culture
|
|
31
|
-
*/
|
|
32
|
-
function updateRegionLabel(region: AddressRegion, culture: string): Promise<void>;
|
|
33
13
|
}
|
|
@@ -1,25 +1,9 @@
|
|
|
1
1
|
import { AddressRegion } from './AddressRegion';
|
|
2
|
-
const languageLabels = {};
|
|
3
2
|
/**
|
|
4
3
|
* Address utils
|
|
5
4
|
*/
|
|
6
5
|
export var AddressUtils;
|
|
7
6
|
(function (AddressUtils) {
|
|
8
|
-
/**
|
|
9
|
-
* Get address labels
|
|
10
|
-
* @param language Language
|
|
11
|
-
* @returns Result
|
|
12
|
-
*/
|
|
13
|
-
async function getLabels(language) {
|
|
14
|
-
let labels = languageLabels[language];
|
|
15
|
-
if (labels == null) {
|
|
16
|
-
labels = await import(`./../i18n/address.${language}.json`);
|
|
17
|
-
// Cache
|
|
18
|
-
languageLabels[language] = labels;
|
|
19
|
-
}
|
|
20
|
-
return labels;
|
|
21
|
-
}
|
|
22
|
-
AddressUtils.getLabels = getLabels;
|
|
23
7
|
/**
|
|
24
8
|
* Get region from regions and detected region and language
|
|
25
9
|
* @param regions Supported regions
|
|
@@ -45,25 +29,4 @@ export var AddressUtils;
|
|
|
45
29
|
return AddressRegion.getById(regions[0]);
|
|
46
30
|
}
|
|
47
31
|
AddressUtils.getRegion = getRegion;
|
|
48
|
-
/**
|
|
49
|
-
* Get region label
|
|
50
|
-
* @param id Region id
|
|
51
|
-
* @param labels Labels
|
|
52
|
-
* @returns Label
|
|
53
|
-
*/
|
|
54
|
-
function getRegionLabel(id, labels) {
|
|
55
|
-
var _a;
|
|
56
|
-
return (_a = labels['region' + id]) !== null && _a !== void 0 ? _a : id;
|
|
57
|
-
}
|
|
58
|
-
AddressUtils.getRegionLabel = getRegionLabel;
|
|
59
|
-
/**
|
|
60
|
-
* Update region label
|
|
61
|
-
* @param region Region
|
|
62
|
-
* @param culture Culture
|
|
63
|
-
*/
|
|
64
|
-
async function updateRegionLabel(region, culture) {
|
|
65
|
-
const labels = await AddressUtils.getLabels(culture);
|
|
66
|
-
region.label = getRegionLabel(region.id, labels);
|
|
67
|
-
}
|
|
68
|
-
AddressUtils.updateRegionLabel = updateRegionLabel;
|
|
69
32
|
})(AddressUtils || (AddressUtils = {}));
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -216,6 +216,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
216
216
|
* @param culture New culture definition
|
|
217
217
|
*/
|
|
218
218
|
changeCulture(culture: DataTypes.CultureDefinition): void;
|
|
219
|
+
/**
|
|
220
|
+
* Update current region label
|
|
221
|
+
*/
|
|
222
|
+
protected updateRegionLabel(): void;
|
|
219
223
|
/**
|
|
220
224
|
* Check language is supported or not, return a valid language when supported
|
|
221
225
|
* @param language Language
|
|
@@ -360,6 +364,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
360
364
|
* @returns List
|
|
361
365
|
*/
|
|
362
366
|
protected getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): ListType1[];
|
|
367
|
+
/**
|
|
368
|
+
* Get region label
|
|
369
|
+
* @param id Region id
|
|
370
|
+
* @returns Label
|
|
371
|
+
*/
|
|
372
|
+
getRegionLabel(id: string): string;
|
|
363
373
|
/**
|
|
364
374
|
* Get all regions
|
|
365
375
|
* @returns Regions
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -3,7 +3,6 @@ import { ApiDataError } from '@etsoo/restclient';
|
|
|
3
3
|
import { DataTypes, DateUtils, DomUtils, NumberUtils, Utils } from '@etsoo/shared';
|
|
4
4
|
import { AES, algo, enc, HmacSHA512, lib, mode, pad, PBKDF2, SHA3 } from 'crypto-js';
|
|
5
5
|
import { AddressRegion } from '../address/AddressRegion';
|
|
6
|
-
import { AddressUtils } from '../address/AddressUtils';
|
|
7
6
|
import { BridgeUtils } from '../bridges/BridgeUtils';
|
|
8
7
|
import { EntityStatus } from '../business/EntityStatus';
|
|
9
8
|
import { ActionResultError } from '../result/ActionResultError';
|
|
@@ -484,8 +483,8 @@ export class CoreApp {
|
|
|
484
483
|
this._currency = regionItem.currency;
|
|
485
484
|
this._region = regionId;
|
|
486
485
|
// Hold the current country or region
|
|
487
|
-
AddressUtils.updateRegionLabel(regionItem, this._culture);
|
|
488
486
|
this.settings.currentRegion = regionItem;
|
|
487
|
+
this.updateRegionLabel();
|
|
489
488
|
}
|
|
490
489
|
/**
|
|
491
490
|
* Change culture
|
|
@@ -506,6 +505,14 @@ export class CoreApp {
|
|
|
506
505
|
this._culture = name;
|
|
507
506
|
// Hold the current resources
|
|
508
507
|
this.settings.currentCulture = culture;
|
|
508
|
+
this.updateRegionLabel();
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Update current region label
|
|
512
|
+
*/
|
|
513
|
+
updateRegionLabel() {
|
|
514
|
+
const region = this.settings.currentRegion;
|
|
515
|
+
region.label = this.getRegionLabel(region.id);
|
|
509
516
|
}
|
|
510
517
|
/**
|
|
511
518
|
* Check language is supported or not, return a valid language when supported
|
|
@@ -893,6 +900,15 @@ export class CoreApp {
|
|
|
893
900
|
}
|
|
894
901
|
return list;
|
|
895
902
|
}
|
|
903
|
+
/**
|
|
904
|
+
* Get region label
|
|
905
|
+
* @param id Region id
|
|
906
|
+
* @returns Label
|
|
907
|
+
*/
|
|
908
|
+
getRegionLabel(id) {
|
|
909
|
+
var _a;
|
|
910
|
+
return (_a = this.get('region' + id)) !== null && _a !== void 0 ? _a : id;
|
|
911
|
+
}
|
|
896
912
|
/**
|
|
897
913
|
* Get all regions
|
|
898
914
|
* @returns Regions
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -284,6 +284,12 @@ export interface IApp {
|
|
|
284
284
|
* @returns Cached token
|
|
285
285
|
*/
|
|
286
286
|
getCacheToken(): string | undefined;
|
|
287
|
+
/**
|
|
288
|
+
* Get region label
|
|
289
|
+
* @param id Region id
|
|
290
|
+
* @returns Label
|
|
291
|
+
*/
|
|
292
|
+
getRegionLabel(id: string): string;
|
|
287
293
|
/**
|
|
288
294
|
* Get all regions
|
|
289
295
|
* @returns Regions
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AddressContinent } from '../address/AddressContinent';
|
|
1
2
|
import { AddressRegion, AddressRegionDb } from '../address/AddressRegion';
|
|
2
3
|
import { AddressState } from '../address/AddressState';
|
|
3
4
|
import { IdLabelConditional } from '../dto/IdLabelDto';
|
|
@@ -8,23 +9,26 @@ import { BaseApi } from './BaseApi';
|
|
|
8
9
|
export declare class AddressApi extends BaseApi {
|
|
9
10
|
/**
|
|
10
11
|
* Get all continents
|
|
11
|
-
* @param language Language
|
|
12
12
|
* @param isNumberKey Is number key or key as id
|
|
13
13
|
* @returns Continents
|
|
14
14
|
*/
|
|
15
|
-
continents<T extends boolean>(
|
|
15
|
+
continents<T extends boolean>(isNumberKey?: T): Promise<IdLabelConditional<T>>;
|
|
16
16
|
/**
|
|
17
|
-
* Get
|
|
18
|
-
* @param
|
|
17
|
+
* Get continent label
|
|
18
|
+
* @param id Region id
|
|
19
|
+
* @returns Label
|
|
20
|
+
*/
|
|
21
|
+
getContinentLabel(id: AddressContinent | string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Get region list
|
|
19
24
|
* @param isLocal Is local version
|
|
20
25
|
* @returns Result
|
|
21
26
|
*/
|
|
22
|
-
regions<T extends boolean = true>(
|
|
27
|
+
regions<T extends boolean = true>(isLocal?: T): Promise<T extends true | undefined ? AddressRegion[] : AddressRegionDb[] | undefined>;
|
|
23
28
|
/**
|
|
24
|
-
* Get state list
|
|
29
|
+
* Get state list
|
|
25
30
|
* @param regionId Region id
|
|
26
|
-
* @param language Language
|
|
27
31
|
* @returns Result
|
|
28
32
|
*/
|
|
29
|
-
states(regionId: string
|
|
33
|
+
states(regionId: string): Promise<AddressState[] | undefined>;
|
|
30
34
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DataTypes } from '@etsoo/shared';
|
|
2
2
|
import { AddressContinent } from '../address/AddressContinent';
|
|
3
3
|
import { AddressRegion } from '../address/AddressRegion';
|
|
4
|
-
import { AddressUtils } from '../address/AddressUtils';
|
|
5
4
|
import { BaseApi } from './BaseApi';
|
|
6
5
|
/**
|
|
7
6
|
* Address Api
|
|
@@ -9,49 +8,48 @@ import { BaseApi } from './BaseApi';
|
|
|
9
8
|
export class AddressApi extends BaseApi {
|
|
10
9
|
/**
|
|
11
10
|
* Get all continents
|
|
12
|
-
* @param language Language
|
|
13
11
|
* @param isNumberKey Is number key or key as id
|
|
14
12
|
* @returns Continents
|
|
15
13
|
*/
|
|
16
|
-
async continents(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
async continents(isNumberKey = false) {
|
|
15
|
+
return DataTypes.getEnumKeys(AddressContinent).map((key) => ({
|
|
16
|
+
id: isNumberKey
|
|
17
|
+
? DataTypes.getEnumByKey(AddressContinent, key)
|
|
18
|
+
: key.toString(),
|
|
19
|
+
label: this.getContinentLabel(key)
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get continent label
|
|
24
|
+
* @param id Region id
|
|
25
|
+
* @returns Label
|
|
26
|
+
*/
|
|
27
|
+
getContinentLabel(id) {
|
|
28
|
+
var _a;
|
|
29
|
+
return (_a = this.app.get('continent' + id)) !== null && _a !== void 0 ? _a : id;
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
29
|
-
* Get region list
|
|
30
|
-
* @param language Language
|
|
32
|
+
* Get region list
|
|
31
33
|
* @param isLocal Is local version
|
|
32
34
|
* @returns Result
|
|
33
35
|
*/
|
|
34
|
-
async regions(
|
|
35
|
-
language = this.app.checkLanguage(language);
|
|
36
|
+
async regions(isLocal) {
|
|
36
37
|
if (isLocal == null || isLocal) {
|
|
37
|
-
const labels = await AddressUtils.getLabels(language);
|
|
38
38
|
return AddressRegion.all.map((region) => {
|
|
39
|
-
region.label =
|
|
39
|
+
region.label = this.app.getRegionLabel(region.id);
|
|
40
40
|
return { ...region };
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
else {
|
|
44
|
-
return (await this.app.api.get(`Address/RegionList?language=${
|
|
44
|
+
return (await this.app.api.get(`Address/RegionList?language=${this.app.culture}`, undefined, { defaultValue: [] }));
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Get state list
|
|
48
|
+
* Get state list
|
|
49
49
|
* @param regionId Region id
|
|
50
|
-
* @param language Language
|
|
51
50
|
* @returns Result
|
|
52
51
|
*/
|
|
53
|
-
states(regionId
|
|
54
|
-
|
|
55
|
-
return this.app.api.get(`Address/StateList?regionId=${regionId}&language=${language}`, undefined, { defaultValue: [] });
|
|
52
|
+
states(regionId) {
|
|
53
|
+
return this.app.api.get(`Address/StateList?regionId=${regionId}&language=${this.app.culture}`, undefined, { defaultValue: [] });
|
|
56
54
|
}
|
|
57
55
|
}
|
package/lib/mjs/i18n/en-US.json
CHANGED
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
"confirm": "Confirm",
|
|
16
16
|
"confirmAction": "Are you sure you want to {0}?",
|
|
17
17
|
"completeTip": "{0} completed",
|
|
18
|
+
"continentAF": "Africa",
|
|
19
|
+
"continentAN": "Antarctica",
|
|
20
|
+
"continentAS": "Asia",
|
|
21
|
+
"continentEU": "Europe",
|
|
22
|
+
"continentNA": "North America",
|
|
23
|
+
"continentOC": "Oceania",
|
|
24
|
+
"continentSA": "South America",
|
|
18
25
|
"copy": "Copy",
|
|
19
26
|
"creation": "Creation",
|
|
20
27
|
"currentPassword": "Current password",
|
|
@@ -106,6 +113,18 @@
|
|
|
106
113
|
"refresh": "Refresh",
|
|
107
114
|
"refreshing": "Refreshing",
|
|
108
115
|
"releaseToRefresh": "Release to refresh",
|
|
116
|
+
"regionAU": "Australia",
|
|
117
|
+
"regionCA": "Canada",
|
|
118
|
+
"regionCN": "Mainland China",
|
|
119
|
+
"regionDE": "Germany",
|
|
120
|
+
"regionFR": "France",
|
|
121
|
+
"regionGB": "United Kingdom",
|
|
122
|
+
"regionHK": "Hong Kong, China",
|
|
123
|
+
"regionIE": "Ireland",
|
|
124
|
+
"regionJP": "Japan",
|
|
125
|
+
"regionNZ": "New Zealand",
|
|
126
|
+
"regionSG": "Singapore",
|
|
127
|
+
"regionUS": "United States",
|
|
109
128
|
"reloginTip": "Please enter your password, resubmit the data after successful login",
|
|
110
129
|
"remove": "Remove",
|
|
111
130
|
"renew": "Renew",
|
package/lib/mjs/i18n/zh-CN.json
CHANGED
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
"confirm": "确认",
|
|
16
16
|
"confirmAction": "确定要{0}吗?",
|
|
17
17
|
"completeTip": "已完成 {0}",
|
|
18
|
+
"continentAF": "非洲",
|
|
19
|
+
"continentAN": "南极洲",
|
|
20
|
+
"continentAS": "亚洲",
|
|
21
|
+
"continentEU": "欧洲",
|
|
22
|
+
"continentNA": "北美洲",
|
|
23
|
+
"continentOC": "大洋洲",
|
|
24
|
+
"continentSA": "南美洲",
|
|
18
25
|
"copy": "复制",
|
|
19
26
|
"creation": "登记时间",
|
|
20
27
|
"currentPassword": "当前密码",
|
|
@@ -105,6 +112,18 @@
|
|
|
105
112
|
"record": "记录",
|
|
106
113
|
"refresh": "刷新",
|
|
107
114
|
"refreshing": "正在刷新",
|
|
115
|
+
"regionAU": "澳大利亚",
|
|
116
|
+
"regionCA": "加拿大",
|
|
117
|
+
"regionCN": "中国大陆",
|
|
118
|
+
"regionDE": "德国",
|
|
119
|
+
"regionFR": "法国",
|
|
120
|
+
"regionGB": "英国",
|
|
121
|
+
"regionHK": "中国香港",
|
|
122
|
+
"regionIE": "爱尔兰",
|
|
123
|
+
"regionJP": "日本",
|
|
124
|
+
"regionNZ": "新西兰",
|
|
125
|
+
"regionSG": "新加坡",
|
|
126
|
+
"regionUS": "美国",
|
|
108
127
|
"releaseToRefresh": "释放刷新",
|
|
109
128
|
"reloginTip": "请输入您的登录密码,登录成功后请重新提交数据",
|
|
110
129
|
"remove": "移除",
|
package/lib/mjs/i18n/zh-HK.json
CHANGED
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
"confirm": "確認",
|
|
16
16
|
"confirmAction": "確定要{0}嗎?",
|
|
17
17
|
"completeTip": "已完成 {0}",
|
|
18
|
+
"continentAF": "非洲",
|
|
19
|
+
"continentAN": "南極洲",
|
|
20
|
+
"continentAS": "亞洲",
|
|
21
|
+
"continentEU": "歐洲",
|
|
22
|
+
"continentNA": "北美洲",
|
|
23
|
+
"continentOC": "大洋洲",
|
|
24
|
+
"continentSA": "南美洲",
|
|
18
25
|
"copy": "複製",
|
|
19
26
|
"creation": "登記時間",
|
|
20
27
|
"currentPassword": "當前密碼",
|
|
@@ -105,6 +112,18 @@
|
|
|
105
112
|
"record": "記錄",
|
|
106
113
|
"refresh": "刷新",
|
|
107
114
|
"refreshing": "正在刷新",
|
|
115
|
+
"regionAU": "澳大利亞",
|
|
116
|
+
"regionCA": "加拿大",
|
|
117
|
+
"regionCN": "中國大陸",
|
|
118
|
+
"regionDE": "德國",
|
|
119
|
+
"regionFR": "法國",
|
|
120
|
+
"regionGB": "英國",
|
|
121
|
+
"regionHK": "中國香港",
|
|
122
|
+
"regionIE": "愛爾蘭",
|
|
123
|
+
"regionJP": "日本",
|
|
124
|
+
"regionNZ": "新西蘭",
|
|
125
|
+
"regionSG": "新加坡",
|
|
126
|
+
"regionUS": "美國",
|
|
108
127
|
"releaseToRefresh": "釋放刷新",
|
|
109
128
|
"reloginTip": "請輸入您的登錄密碼,登錄成功後請重新提交數據",
|
|
110
129
|
"remove": "移除",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"eslint": "^8.25.0",
|
|
71
71
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
72
72
|
"eslint-plugin-import": "^2.26.0",
|
|
73
|
-
"jest": "^29.
|
|
74
|
-
"jest-environment-jsdom": "^29.
|
|
73
|
+
"jest": "^29.2.0",
|
|
74
|
+
"jest-environment-jsdom": "^29.2.0",
|
|
75
75
|
"ts-jest": "^29.0.3",
|
|
76
76
|
"typescript": "^4.8.4"
|
|
77
77
|
}
|
|
@@ -1,28 +1,9 @@
|
|
|
1
|
-
import { DataTypes } from '@etsoo/shared';
|
|
2
1
|
import { AddressRegion } from './AddressRegion';
|
|
3
2
|
|
|
4
|
-
const languageLabels: Record<string, DataTypes.StringRecord | undefined> = {};
|
|
5
|
-
|
|
6
3
|
/**
|
|
7
4
|
* Address utils
|
|
8
5
|
*/
|
|
9
6
|
export namespace AddressUtils {
|
|
10
|
-
/**
|
|
11
|
-
* Get address labels
|
|
12
|
-
* @param language Language
|
|
13
|
-
* @returns Result
|
|
14
|
-
*/
|
|
15
|
-
export async function getLabels(language: string) {
|
|
16
|
-
let labels = languageLabels[language];
|
|
17
|
-
if (labels == null) {
|
|
18
|
-
labels = await import(`./../i18n/address.${language}.json`);
|
|
19
|
-
|
|
20
|
-
// Cache
|
|
21
|
-
languageLabels[language] = labels;
|
|
22
|
-
}
|
|
23
|
-
return labels!;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
7
|
/**
|
|
27
8
|
* Get region from regions and detected region and language
|
|
28
9
|
* @param regions Supported regions
|
|
@@ -51,30 +32,4 @@ export namespace AddressUtils {
|
|
|
51
32
|
// Default
|
|
52
33
|
return AddressRegion.getById(regions[0])!;
|
|
53
34
|
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Get region label
|
|
57
|
-
* @param id Region id
|
|
58
|
-
* @param labels Labels
|
|
59
|
-
* @returns Label
|
|
60
|
-
*/
|
|
61
|
-
export function getRegionLabel(
|
|
62
|
-
id: string,
|
|
63
|
-
labels: DataTypes.StringRecord
|
|
64
|
-
): string {
|
|
65
|
-
return (labels['region' + id] as string) ?? id;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Update region label
|
|
70
|
-
* @param region Region
|
|
71
|
-
* @param culture Culture
|
|
72
|
-
*/
|
|
73
|
-
export async function updateRegionLabel(
|
|
74
|
-
region: AddressRegion,
|
|
75
|
-
culture: string
|
|
76
|
-
) {
|
|
77
|
-
const labels = await AddressUtils.getLabels(culture);
|
|
78
|
-
region.label = getRegionLabel(region.id, labels);
|
|
79
|
-
}
|
|
80
35
|
}
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -718,8 +718,8 @@ export abstract class CoreApp<
|
|
|
718
718
|
this._region = regionId;
|
|
719
719
|
|
|
720
720
|
// Hold the current country or region
|
|
721
|
-
AddressUtils.updateRegionLabel(regionItem, this._culture);
|
|
722
721
|
this.settings.currentRegion = regionItem;
|
|
722
|
+
this.updateRegionLabel();
|
|
723
723
|
}
|
|
724
724
|
|
|
725
725
|
/**
|
|
@@ -745,6 +745,16 @@ export abstract class CoreApp<
|
|
|
745
745
|
|
|
746
746
|
// Hold the current resources
|
|
747
747
|
this.settings.currentCulture = culture;
|
|
748
|
+
|
|
749
|
+
this.updateRegionLabel();
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Update current region label
|
|
754
|
+
*/
|
|
755
|
+
protected updateRegionLabel() {
|
|
756
|
+
const region = this.settings.currentRegion;
|
|
757
|
+
region.label = this.getRegionLabel(region.id);
|
|
748
758
|
}
|
|
749
759
|
|
|
750
760
|
/**
|
|
@@ -1219,6 +1229,15 @@ export abstract class CoreApp<
|
|
|
1219
1229
|
return list;
|
|
1220
1230
|
}
|
|
1221
1231
|
|
|
1232
|
+
/**
|
|
1233
|
+
* Get region label
|
|
1234
|
+
* @param id Region id
|
|
1235
|
+
* @returns Label
|
|
1236
|
+
*/
|
|
1237
|
+
getRegionLabel(id: string) {
|
|
1238
|
+
return this.get('region' + id) ?? id;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1222
1241
|
/**
|
|
1223
1242
|
* Get all regions
|
|
1224
1243
|
* @returns Regions
|
package/src/app/IApp.ts
CHANGED
|
@@ -375,6 +375,13 @@ export interface IApp {
|
|
|
375
375
|
*/
|
|
376
376
|
getCacheToken(): string | undefined;
|
|
377
377
|
|
|
378
|
+
/**
|
|
379
|
+
* Get region label
|
|
380
|
+
* @param id Region id
|
|
381
|
+
* @returns Label
|
|
382
|
+
*/
|
|
383
|
+
getRegionLabel(id: string): string;
|
|
384
|
+
|
|
378
385
|
/**
|
|
379
386
|
* Get all regions
|
|
380
387
|
* @returns Regions
|
package/src/erp/AddressApi.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { DataTypes } from '@etsoo/shared';
|
|
|
2
2
|
import { AddressContinent } from '../address/AddressContinent';
|
|
3
3
|
import { AddressRegion, AddressRegionDb } from '../address/AddressRegion';
|
|
4
4
|
import { AddressState } from '../address/AddressState';
|
|
5
|
-
import { AddressUtils } from '../address/AddressUtils';
|
|
6
5
|
import { IdLabelConditional } from '../dto/IdLabelDto';
|
|
7
6
|
import { BaseApi } from './BaseApi';
|
|
8
7
|
|
|
@@ -12,51 +11,51 @@ import { BaseApi } from './BaseApi';
|
|
|
12
11
|
export class AddressApi extends BaseApi {
|
|
13
12
|
/**
|
|
14
13
|
* Get all continents
|
|
15
|
-
* @param language Language
|
|
16
14
|
* @param isNumberKey Is number key or key as id
|
|
17
15
|
* @returns Continents
|
|
18
16
|
*/
|
|
19
17
|
async continents<T extends boolean>(
|
|
20
|
-
language?: string,
|
|
21
18
|
isNumberKey = <T>false
|
|
22
19
|
): Promise<IdLabelConditional<T>> {
|
|
23
|
-
const labels = await AddressUtils.getLabels(
|
|
24
|
-
this.app.checkLanguage(language)
|
|
25
|
-
);
|
|
26
20
|
return <IdLabelConditional<T>>DataTypes.getEnumKeys(
|
|
27
21
|
AddressContinent
|
|
28
22
|
).map((key) => ({
|
|
29
23
|
id: isNumberKey
|
|
30
24
|
? <number>DataTypes.getEnumByKey(AddressContinent, key)!
|
|
31
25
|
: key.toString(),
|
|
32
|
-
label:
|
|
26
|
+
label: this.getContinentLabel(key)
|
|
33
27
|
}));
|
|
34
28
|
}
|
|
35
29
|
|
|
36
30
|
/**
|
|
37
|
-
* Get
|
|
38
|
-
* @param
|
|
31
|
+
* Get continent label
|
|
32
|
+
* @param id Region id
|
|
33
|
+
* @returns Label
|
|
34
|
+
*/
|
|
35
|
+
getContinentLabel(id: AddressContinent | string) {
|
|
36
|
+
return this.app.get('continent' + id) ?? (id as string);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get region list
|
|
39
41
|
* @param isLocal Is local version
|
|
40
42
|
* @returns Result
|
|
41
43
|
*/
|
|
42
44
|
async regions<T extends boolean = true>(
|
|
43
|
-
language?: string,
|
|
44
45
|
isLocal?: T
|
|
45
46
|
): Promise<
|
|
46
47
|
T extends true | undefined
|
|
47
48
|
? AddressRegion[]
|
|
48
49
|
: AddressRegionDb[] | undefined
|
|
49
50
|
> {
|
|
50
|
-
language = this.app.checkLanguage(language);
|
|
51
51
|
if (isLocal == null || isLocal) {
|
|
52
|
-
const labels = await AddressUtils.getLabels(language);
|
|
53
52
|
return AddressRegion.all.map((region) => {
|
|
54
|
-
region.label =
|
|
53
|
+
region.label = this.app.getRegionLabel(region.id);
|
|
55
54
|
return { ...region };
|
|
56
55
|
});
|
|
57
56
|
} else {
|
|
58
57
|
return (await this.app.api.get<AddressRegionDb[]>(
|
|
59
|
-
`Address/RegionList?language=${
|
|
58
|
+
`Address/RegionList?language=${this.app.culture}`,
|
|
60
59
|
undefined,
|
|
61
60
|
{ defaultValue: [] }
|
|
62
61
|
)) as any;
|
|
@@ -64,15 +63,13 @@ export class AddressApi extends BaseApi {
|
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
/**
|
|
67
|
-
* Get state list
|
|
66
|
+
* Get state list
|
|
68
67
|
* @param regionId Region id
|
|
69
|
-
* @param language Language
|
|
70
68
|
* @returns Result
|
|
71
69
|
*/
|
|
72
|
-
states(regionId: string
|
|
73
|
-
language = this.app.checkLanguage(language);
|
|
70
|
+
states(regionId: string) {
|
|
74
71
|
return this.app.api.get<AddressState[]>(
|
|
75
|
-
`Address/StateList?regionId=${regionId}&language=${
|
|
72
|
+
`Address/StateList?regionId=${regionId}&language=${this.app.culture}`,
|
|
76
73
|
undefined,
|
|
77
74
|
{ defaultValue: [] }
|
|
78
75
|
);
|
package/src/i18n/en-US.json
CHANGED
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
"confirm": "Confirm",
|
|
16
16
|
"confirmAction": "Are you sure you want to {0}?",
|
|
17
17
|
"completeTip": "{0} completed",
|
|
18
|
+
"continentAF": "Africa",
|
|
19
|
+
"continentAN": "Antarctica",
|
|
20
|
+
"continentAS": "Asia",
|
|
21
|
+
"continentEU": "Europe",
|
|
22
|
+
"continentNA": "North America",
|
|
23
|
+
"continentOC": "Oceania",
|
|
24
|
+
"continentSA": "South America",
|
|
18
25
|
"copy": "Copy",
|
|
19
26
|
"creation": "Creation",
|
|
20
27
|
"currentPassword": "Current password",
|
|
@@ -106,6 +113,18 @@
|
|
|
106
113
|
"refresh": "Refresh",
|
|
107
114
|
"refreshing": "Refreshing",
|
|
108
115
|
"releaseToRefresh": "Release to refresh",
|
|
116
|
+
"regionAU": "Australia",
|
|
117
|
+
"regionCA": "Canada",
|
|
118
|
+
"regionCN": "Mainland China",
|
|
119
|
+
"regionDE": "Germany",
|
|
120
|
+
"regionFR": "France",
|
|
121
|
+
"regionGB": "United Kingdom",
|
|
122
|
+
"regionHK": "Hong Kong, China",
|
|
123
|
+
"regionIE": "Ireland",
|
|
124
|
+
"regionJP": "Japan",
|
|
125
|
+
"regionNZ": "New Zealand",
|
|
126
|
+
"regionSG": "Singapore",
|
|
127
|
+
"regionUS": "United States",
|
|
109
128
|
"reloginTip": "Please enter your password, resubmit the data after successful login",
|
|
110
129
|
"remove": "Remove",
|
|
111
130
|
"renew": "Renew",
|
package/src/i18n/zh-CN.json
CHANGED
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
"confirm": "确认",
|
|
16
16
|
"confirmAction": "确定要{0}吗?",
|
|
17
17
|
"completeTip": "已完成 {0}",
|
|
18
|
+
"continentAF": "非洲",
|
|
19
|
+
"continentAN": "南极洲",
|
|
20
|
+
"continentAS": "亚洲",
|
|
21
|
+
"continentEU": "欧洲",
|
|
22
|
+
"continentNA": "北美洲",
|
|
23
|
+
"continentOC": "大洋洲",
|
|
24
|
+
"continentSA": "南美洲",
|
|
18
25
|
"copy": "复制",
|
|
19
26
|
"creation": "登记时间",
|
|
20
27
|
"currentPassword": "当前密码",
|
|
@@ -105,6 +112,18 @@
|
|
|
105
112
|
"record": "记录",
|
|
106
113
|
"refresh": "刷新",
|
|
107
114
|
"refreshing": "正在刷新",
|
|
115
|
+
"regionAU": "澳大利亚",
|
|
116
|
+
"regionCA": "加拿大",
|
|
117
|
+
"regionCN": "中国大陆",
|
|
118
|
+
"regionDE": "德国",
|
|
119
|
+
"regionFR": "法国",
|
|
120
|
+
"regionGB": "英国",
|
|
121
|
+
"regionHK": "中国香港",
|
|
122
|
+
"regionIE": "爱尔兰",
|
|
123
|
+
"regionJP": "日本",
|
|
124
|
+
"regionNZ": "新西兰",
|
|
125
|
+
"regionSG": "新加坡",
|
|
126
|
+
"regionUS": "美国",
|
|
108
127
|
"releaseToRefresh": "释放刷新",
|
|
109
128
|
"reloginTip": "请输入您的登录密码,登录成功后请重新提交数据",
|
|
110
129
|
"remove": "移除",
|
package/src/i18n/zh-HK.json
CHANGED
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
"confirm": "確認",
|
|
16
16
|
"confirmAction": "確定要{0}嗎?",
|
|
17
17
|
"completeTip": "已完成 {0}",
|
|
18
|
+
"continentAF": "非洲",
|
|
19
|
+
"continentAN": "南極洲",
|
|
20
|
+
"continentAS": "亞洲",
|
|
21
|
+
"continentEU": "歐洲",
|
|
22
|
+
"continentNA": "北美洲",
|
|
23
|
+
"continentOC": "大洋洲",
|
|
24
|
+
"continentSA": "南美洲",
|
|
18
25
|
"copy": "複製",
|
|
19
26
|
"creation": "登記時間",
|
|
20
27
|
"currentPassword": "當前密碼",
|
|
@@ -105,6 +112,18 @@
|
|
|
105
112
|
"record": "記錄",
|
|
106
113
|
"refresh": "刷新",
|
|
107
114
|
"refreshing": "正在刷新",
|
|
115
|
+
"regionAU": "澳大利亞",
|
|
116
|
+
"regionCA": "加拿大",
|
|
117
|
+
"regionCN": "中國大陸",
|
|
118
|
+
"regionDE": "德國",
|
|
119
|
+
"regionFR": "法國",
|
|
120
|
+
"regionGB": "英國",
|
|
121
|
+
"regionHK": "中國香港",
|
|
122
|
+
"regionIE": "愛爾蘭",
|
|
123
|
+
"regionJP": "日本",
|
|
124
|
+
"regionNZ": "新西蘭",
|
|
125
|
+
"regionSG": "新加坡",
|
|
126
|
+
"regionUS": "美國",
|
|
108
127
|
"releaseToRefresh": "釋放刷新",
|
|
109
128
|
"reloginTip": "請輸入您的登錄密碼,登錄成功後請重新提交數據",
|
|
110
129
|
"remove": "移除",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"continentAF": "Africa",
|
|
3
|
-
"continentAN": "Antarctica",
|
|
4
|
-
"continentAS": "Asia",
|
|
5
|
-
"continentEU": "Europe",
|
|
6
|
-
"continentNA": "North America",
|
|
7
|
-
"continentOC": "Oceania",
|
|
8
|
-
"continentSA": "South America",
|
|
9
|
-
"regionAU": "Australia",
|
|
10
|
-
"regionCA": "Canada",
|
|
11
|
-
"regionCN": "Mainland China",
|
|
12
|
-
"regionDE": "Germany",
|
|
13
|
-
"regionFR": "France",
|
|
14
|
-
"regionGB": "United Kingdom",
|
|
15
|
-
"regionHK": "Hong Kong, China",
|
|
16
|
-
"regionIE": "Ireland",
|
|
17
|
-
"regionJP": "Japan",
|
|
18
|
-
"regionNZ": "New Zealand",
|
|
19
|
-
"regionSG": "Singapore",
|
|
20
|
-
"regionUS": "United States"
|
|
21
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"continentAF": "非洲",
|
|
3
|
-
"continentAN": "南极洲",
|
|
4
|
-
"continentAS": "亚洲",
|
|
5
|
-
"continentEU": "欧洲",
|
|
6
|
-
"continentNA": "北美洲",
|
|
7
|
-
"continentOC": "大洋洲",
|
|
8
|
-
"continentSA": "南美洲",
|
|
9
|
-
"regionAU": "澳大利亚",
|
|
10
|
-
"regionCA": "加拿大",
|
|
11
|
-
"regionCN": "中国大陆",
|
|
12
|
-
"regionDE": "德国",
|
|
13
|
-
"regionFR": "法国",
|
|
14
|
-
"regionGB": "英国",
|
|
15
|
-
"regionHK": "中国香港",
|
|
16
|
-
"regionIE": "爱尔兰",
|
|
17
|
-
"regionJP": "日本",
|
|
18
|
-
"regionNZ": "新西兰",
|
|
19
|
-
"regionSG": "新加坡",
|
|
20
|
-
"regionUS": "美国"
|
|
21
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"continentAF": "非洲",
|
|
3
|
-
"continentAN": "南極洲",
|
|
4
|
-
"continentAS": "亞洲",
|
|
5
|
-
"continentEU": "歐洲",
|
|
6
|
-
"continentNA": "北美洲",
|
|
7
|
-
"continentOC": "大洋洲",
|
|
8
|
-
"continentSA": "南美洲",
|
|
9
|
-
"regionAU": "澳大利亞",
|
|
10
|
-
"regionCA": "加拿大",
|
|
11
|
-
"regionCN": "中國大陸",
|
|
12
|
-
"regionDE": "德國",
|
|
13
|
-
"regionFR": "法國",
|
|
14
|
-
"regionGB": "英國",
|
|
15
|
-
"regionHK": "中國香港",
|
|
16
|
-
"regionIE": "愛爾蘭",
|
|
17
|
-
"regionJP": "日本",
|
|
18
|
-
"regionNZ": "新西蘭",
|
|
19
|
-
"regionSG": "新加坡",
|
|
20
|
-
"regionUS": "美國"
|
|
21
|
-
}
|