@etsoo/appscript 1.3.32 → 1.3.34
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 +27 -4
- package/lib/cjs/address/AddressContinent.d.ts +1 -1
- package/lib/cjs/address/AddressRegion.d.ts +7 -1
- package/lib/cjs/address/AddressRegion.js +21 -20
- package/lib/cjs/address/AddressState.d.ts +1 -1
- package/lib/cjs/app/CoreApp.d.ts +13 -2
- package/lib/cjs/app/CoreApp.js +45 -49
- package/lib/cjs/app/IApp.d.ts +2 -17
- package/lib/cjs/bridges/FlutterHost.d.ts +2 -1
- package/lib/cjs/bridges/FlutterHost.js +1 -0
- package/lib/cjs/bridges/IBridgeHost.d.ts +5 -0
- package/lib/cjs/business/BusinessTax.js +6 -6
- package/lib/cjs/business/Currency.d.ts +1 -1
- package/lib/cjs/business/ProductUnit.d.ts +1 -1
- package/lib/cjs/def/ListItem.d.ts +1 -1
- package/lib/cjs/erp/AddressApi.d.ts +16 -2
- package/lib/cjs/erp/AddressApi.js +43 -12
- package/lib/cjs/erp/BaseApi.js +6 -6
- package/lib/cjs/erp/dto/AuditLineDto.d.ts +3 -3
- package/lib/cjs/erp/dto/CurrencyDto.d.ts +1 -1
- package/lib/cjs/erp/dto/ExchangeRateDto.d.ts +1 -1
- package/lib/cjs/erp/dto/ExchangeRateHistoryDto.d.ts +1 -1
- package/lib/cjs/erp/dto/IdLabelDto.d.ts +1 -1
- package/lib/cjs/erp/dto/IdLabelPrimaryDto.d.ts +1 -1
- package/lib/cjs/erp/dto/InitCallDto.d.ts +1 -1
- package/lib/cjs/erp/dto/OrgDto.d.ts +1 -1
- package/lib/cjs/erp/dto/OrgQueryDto.d.ts +1 -1
- package/lib/cjs/erp/dto/PublicProductDto.d.ts +2 -2
- package/lib/cjs/erp/dto/ResultPayload.d.ts +3 -3
- package/lib/cjs/erp/rq/MemberListRQ.d.ts +1 -1
- package/lib/cjs/erp/rq/OrgListRQ.d.ts +1 -1
- package/lib/cjs/erp/rq/OrgQueryRQ.d.ts +1 -1
- package/lib/cjs/erp/rq/QueryRQ.d.ts +1 -1
- package/lib/cjs/erp/rq/RefreshTokenRQ.d.ts +1 -1
- package/lib/cjs/erp/rq/RegionsRQ.d.ts +14 -0
- package/lib/cjs/erp/rq/RegionsRQ.js +2 -0
- package/lib/cjs/erp/rq/TiplistRQ.d.ts +1 -1
- package/lib/cjs/i18n/en-US.json +1 -0
- package/lib/cjs/i18n/zh-CN.json +1 -0
- package/lib/cjs/i18n/zh-HK.json +1 -0
- package/lib/cjs/result/ActionResultError.js +12 -12
- package/lib/cjs/result/IActionResult.d.ts +2 -2
- package/lib/cjs/result/InitCallResult.d.ts +1 -1
- package/lib/cjs/state/User.d.ts +1 -1
- package/lib/mjs/address/AddressContinent.d.ts +1 -1
- package/lib/mjs/address/AddressRegion.d.ts +7 -1
- package/lib/mjs/address/AddressRegion.js +21 -20
- package/lib/mjs/address/AddressState.d.ts +1 -1
- package/lib/mjs/app/CoreApp.d.ts +13 -2
- package/lib/mjs/app/CoreApp.js +45 -49
- package/lib/mjs/app/IApp.d.ts +2 -17
- package/lib/mjs/bridges/FlutterHost.d.ts +2 -1
- package/lib/mjs/bridges/FlutterHost.js +1 -0
- package/lib/mjs/bridges/IBridgeHost.d.ts +5 -0
- package/lib/mjs/business/BusinessTax.js +6 -6
- package/lib/mjs/business/Currency.d.ts +1 -1
- package/lib/mjs/business/ProductUnit.d.ts +1 -1
- package/lib/mjs/def/ListItem.d.ts +1 -1
- package/lib/mjs/erp/AddressApi.d.ts +16 -2
- package/lib/mjs/erp/AddressApi.js +43 -12
- package/lib/mjs/erp/BaseApi.js +6 -6
- package/lib/mjs/erp/dto/AuditLineDto.d.ts +3 -3
- package/lib/mjs/erp/dto/CurrencyDto.d.ts +1 -1
- package/lib/mjs/erp/dto/ExchangeRateDto.d.ts +1 -1
- package/lib/mjs/erp/dto/ExchangeRateHistoryDto.d.ts +1 -1
- package/lib/mjs/erp/dto/IdLabelDto.d.ts +1 -1
- package/lib/mjs/erp/dto/IdLabelPrimaryDto.d.ts +1 -1
- package/lib/mjs/erp/dto/InitCallDto.d.ts +1 -1
- package/lib/mjs/erp/dto/OrgDto.d.ts +1 -1
- package/lib/mjs/erp/dto/OrgQueryDto.d.ts +1 -1
- package/lib/mjs/erp/dto/PublicProductDto.d.ts +2 -2
- package/lib/mjs/erp/dto/ResultPayload.d.ts +3 -3
- package/lib/mjs/erp/rq/MemberListRQ.d.ts +1 -1
- package/lib/mjs/erp/rq/OrgListRQ.d.ts +1 -1
- package/lib/mjs/erp/rq/OrgQueryRQ.d.ts +1 -1
- package/lib/mjs/erp/rq/QueryRQ.d.ts +1 -1
- package/lib/mjs/erp/rq/RefreshTokenRQ.d.ts +1 -1
- package/lib/mjs/erp/rq/RegionsRQ.d.ts +14 -0
- package/lib/mjs/erp/rq/RegionsRQ.js +1 -0
- package/lib/mjs/erp/rq/TiplistRQ.d.ts +1 -1
- package/lib/mjs/i18n/en-US.json +1 -0
- package/lib/mjs/i18n/zh-CN.json +1 -0
- package/lib/mjs/i18n/zh-HK.json +1 -0
- package/lib/mjs/result/ActionResultError.js +12 -12
- package/lib/mjs/result/IActionResult.d.ts +2 -2
- package/lib/mjs/result/InitCallResult.d.ts +1 -1
- package/lib/mjs/state/User.d.ts +1 -1
- package/package.json +8 -8
- package/src/address/AddressRegion.ts +29 -10
- package/src/app/CoreApp.ts +2 -26
- package/src/app/IApp.ts +0 -25
- package/src/bridges/FlutterHost.ts +2 -0
- package/src/bridges/IBridgeHost.ts +6 -0
- package/src/erp/AddressApi.ts +72 -25
- package/src/erp/rq/RegionsRQ.ts +16 -0
- package/src/i18n/en-US.json +1 -0
- package/src/i18n/zh-CN.json +1 -0
- package/src/i18n/zh-HK.json +1 -0
package/src/app/CoreApp.ts
CHANGED
|
@@ -30,7 +30,6 @@ import {
|
|
|
30
30
|
SHA3
|
|
31
31
|
} from 'crypto-js';
|
|
32
32
|
import { AddressRegion } from '../address/AddressRegion';
|
|
33
|
-
import { AddressUtils } from '../address/AddressUtils';
|
|
34
33
|
import { BridgeUtils } from '../bridges/BridgeUtils';
|
|
35
34
|
import { EntityStatus } from '../business/EntityStatus';
|
|
36
35
|
import { InitCallDto } from '../erp/dto/InitCallDto';
|
|
@@ -996,16 +995,6 @@ export abstract class CoreApp<
|
|
|
996
995
|
return DateUtils.format(input, currentCulture.name, options, timeZone);
|
|
997
996
|
}
|
|
998
997
|
|
|
999
|
-
formatMoney(
|
|
1000
|
-
input: null | undefined,
|
|
1001
|
-
isInteger?: boolean,
|
|
1002
|
-
options?: Intl.NumberFormatOptions
|
|
1003
|
-
): undefined;
|
|
1004
|
-
formatMoney(
|
|
1005
|
-
input: number | bigint,
|
|
1006
|
-
isInteger?: boolean,
|
|
1007
|
-
options?: Intl.NumberFormatOptions
|
|
1008
|
-
): string;
|
|
1009
998
|
/**
|
|
1010
999
|
* Format money number
|
|
1011
1000
|
* @param input Input money number
|
|
@@ -1014,11 +1003,10 @@ export abstract class CoreApp<
|
|
|
1014
1003
|
* @returns Result
|
|
1015
1004
|
*/
|
|
1016
1005
|
formatMoney(
|
|
1017
|
-
input: number | bigint
|
|
1006
|
+
input: number | bigint,
|
|
1018
1007
|
isInteger: boolean = false,
|
|
1019
1008
|
options?: Intl.NumberFormatOptions
|
|
1020
1009
|
) {
|
|
1021
|
-
if (input == null) return undefined;
|
|
1022
1010
|
return NumberUtils.formatMoney(
|
|
1023
1011
|
input,
|
|
1024
1012
|
this.currency,
|
|
@@ -1028,25 +1016,13 @@ export abstract class CoreApp<
|
|
|
1028
1016
|
);
|
|
1029
1017
|
}
|
|
1030
1018
|
|
|
1031
|
-
formatNumber(
|
|
1032
|
-
input: null | undefined,
|
|
1033
|
-
options?: Intl.NumberFormatOptions
|
|
1034
|
-
): undefined;
|
|
1035
|
-
formatNumber(
|
|
1036
|
-
input: number | bigint,
|
|
1037
|
-
options?: Intl.NumberFormatOptions
|
|
1038
|
-
): string;
|
|
1039
1019
|
/**
|
|
1040
1020
|
* Format number
|
|
1041
1021
|
* @param input Input number
|
|
1042
1022
|
* @param options Options
|
|
1043
1023
|
* @returns Result
|
|
1044
1024
|
*/
|
|
1045
|
-
formatNumber(
|
|
1046
|
-
input: number | bigint | null | undefined,
|
|
1047
|
-
options?: Intl.NumberFormatOptions
|
|
1048
|
-
) {
|
|
1049
|
-
if (input == null) return undefined;
|
|
1025
|
+
formatNumber(input: number | bigint, options?: Intl.NumberFormatOptions) {
|
|
1050
1026
|
return NumberUtils.format(input, this.culture, options);
|
|
1051
1027
|
}
|
|
1052
1028
|
|
package/src/app/IApp.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
|
|
9
9
|
import { DataTypes, DateUtils, IStorage, ListType } from '@etsoo/shared';
|
|
10
10
|
import { AddressRegion } from '../address/AddressRegion';
|
|
11
|
-
import { ProductUnit } from '../business/ProductUnit';
|
|
12
11
|
import { IActionResult } from '../result/IActionResult';
|
|
13
12
|
import { IUser } from '../state/User';
|
|
14
13
|
import { IAppSettings } from './AppSettings';
|
|
@@ -299,19 +298,6 @@ export interface IApp {
|
|
|
299
298
|
*/
|
|
300
299
|
formatError(error: ApiDataError): string;
|
|
301
300
|
|
|
302
|
-
/**
|
|
303
|
-
* Format money number
|
|
304
|
-
* @param input Input money number
|
|
305
|
-
* @param isInteger Is integer
|
|
306
|
-
* @param options Options
|
|
307
|
-
* @returns Result
|
|
308
|
-
*/
|
|
309
|
-
formatMoney(
|
|
310
|
-
input: null | undefined,
|
|
311
|
-
isInteger?: boolean,
|
|
312
|
-
options?: Intl.NumberFormatOptions
|
|
313
|
-
): undefined;
|
|
314
|
-
|
|
315
301
|
/**
|
|
316
302
|
* Format money number
|
|
317
303
|
* @param input Input money number
|
|
@@ -325,17 +311,6 @@ export interface IApp {
|
|
|
325
311
|
options?: Intl.NumberFormatOptions
|
|
326
312
|
): string;
|
|
327
313
|
|
|
328
|
-
/**
|
|
329
|
-
* Format number
|
|
330
|
-
* @param input Input number
|
|
331
|
-
* @param options Options
|
|
332
|
-
* @returns Result
|
|
333
|
-
*/
|
|
334
|
-
formatNumber(
|
|
335
|
-
input: null | undefined,
|
|
336
|
-
options?: Intl.NumberFormatOptions
|
|
337
|
-
): undefined;
|
|
338
|
-
|
|
339
314
|
/**
|
|
340
315
|
* Format number
|
|
341
316
|
* @param input Input number
|
package/src/erp/AddressApi.ts
CHANGED
|
@@ -5,6 +5,9 @@ import { AddressState } from '../address/AddressState';
|
|
|
5
5
|
import { IdLabelConditional } from './dto/IdLabelDto';
|
|
6
6
|
import { BaseApi } from './BaseApi';
|
|
7
7
|
import { IApiPayload } from '@etsoo/restclient';
|
|
8
|
+
import { RegionsRQ } from './rq/RegionsRQ';
|
|
9
|
+
|
|
10
|
+
const cachedRegions: { [P: string]: AddressRegionDb[] | undefined | null } = {};
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* Address Api
|
|
@@ -13,19 +16,21 @@ export class AddressApi extends BaseApi {
|
|
|
13
16
|
/**
|
|
14
17
|
* Get all continents
|
|
15
18
|
* @param isNumberKey Is number key or key as id
|
|
19
|
+
* @param includeAntarctica Include Antarctica or not
|
|
16
20
|
* @returns Continents
|
|
17
21
|
*/
|
|
18
|
-
|
|
19
|
-
isNumberKey = <T>false
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
continents<T extends boolean>(
|
|
23
|
+
isNumberKey = <T>false,
|
|
24
|
+
includeAntarctica: boolean = false
|
|
25
|
+
): IdLabelConditional<T> {
|
|
26
|
+
return <IdLabelConditional<T>>DataTypes.getEnumKeys(AddressContinent)
|
|
27
|
+
.filter((item) => includeAntarctica || item !== 'AN')
|
|
28
|
+
.map((key) => ({
|
|
29
|
+
id: isNumberKey
|
|
30
|
+
? <number>DataTypes.getEnumByKey(AddressContinent, key)!
|
|
31
|
+
: key.toString(),
|
|
32
|
+
label: this.getContinentLabel(key)
|
|
33
|
+
}));
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
/**
|
|
@@ -37,27 +42,69 @@ export class AddressApi extends BaseApi {
|
|
|
37
42
|
return this.app.get('continent' + id) ?? (id as string);
|
|
38
43
|
}
|
|
39
44
|
|
|
40
|
-
regions(isRemote: true): Promise<AddressRegionDb[] | undefined>;
|
|
41
|
-
regions(): AddressRegion[];
|
|
42
|
-
|
|
43
45
|
/**
|
|
44
|
-
* Get
|
|
45
|
-
* @param
|
|
46
|
-
* @returns Result
|
|
46
|
+
* Get all regions
|
|
47
|
+
* @param rq Rquest data
|
|
47
48
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
async getRegions(rq?: RegionsRQ): Promise<AddressRegionDb[] | undefined> {
|
|
50
|
+
const culture = this.app.culture;
|
|
51
|
+
let regions = cachedRegions[culture];
|
|
52
|
+
if (regions == null) {
|
|
53
|
+
regions = await this.api.get<AddressRegionDb[]>(
|
|
54
|
+
`Address/RegionList?language=${culture}`,
|
|
52
55
|
undefined,
|
|
53
56
|
{ defaultValue: [], showLoading: false }
|
|
54
57
|
);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
if (regions == null) return undefined;
|
|
59
|
+
cachedRegions[culture] = regions;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const { favoredIds = [], items = 8, keyword } = rq ?? {};
|
|
63
|
+
|
|
64
|
+
// Keyword filter
|
|
65
|
+
if (keyword)
|
|
66
|
+
regions = regions.filter(
|
|
67
|
+
(region) =>
|
|
68
|
+
region.label.includes(keyword) || region.id === keyword
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// Order by favoredIds
|
|
72
|
+
if (favoredIds.length > 0) {
|
|
73
|
+
regions = [...regions].sort((r1, r2) => {
|
|
74
|
+
const n1 = favoredIds.indexOf(r1.id);
|
|
75
|
+
const n2 = favoredIds.indexOf(r2.id);
|
|
76
|
+
|
|
77
|
+
if (n1 === n2) return 0;
|
|
78
|
+
if (n1 === -1) return 1;
|
|
79
|
+
if (n2 === -1) return -1;
|
|
80
|
+
return n1 - n2;
|
|
59
81
|
});
|
|
60
82
|
}
|
|
83
|
+
|
|
84
|
+
// Return the top items
|
|
85
|
+
return regions.slice(0, items);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get all local regions
|
|
90
|
+
*/
|
|
91
|
+
regions(): AddressRegion[];
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get all local regions limited to favored ids
|
|
95
|
+
* @param favoredIds Favored ids
|
|
96
|
+
*/
|
|
97
|
+
regions(favoredIds: string[]): AddressRegion[];
|
|
98
|
+
|
|
99
|
+
regions(p?: string[]) {
|
|
100
|
+
const items =
|
|
101
|
+
p == null || p.length === 0
|
|
102
|
+
? AddressRegion.all
|
|
103
|
+
: AddressRegion.all.filter((ad) => p.includes(ad.id));
|
|
104
|
+
return items.map((region) => ({
|
|
105
|
+
...region,
|
|
106
|
+
label: this.app.getRegionLabel(region.id)
|
|
107
|
+
}));
|
|
61
108
|
}
|
|
62
109
|
|
|
63
110
|
/**
|
package/src/i18n/en-US.json
CHANGED
package/src/i18n/zh-CN.json
CHANGED