@etsoo/appscript 1.3.60 → 1.3.62
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/lib/cjs/app/CoreApp.d.ts +2 -2
- package/lib/cjs/app/IApp.d.ts +17 -1
- package/lib/cjs/business/ProductUnit.d.ts +28 -1
- package/lib/cjs/business/ProductUnit.js +17 -1
- package/lib/cjs/business/RepeatOption.d.ts +1 -1
- package/lib/cjs/business/RepeatOption.js +1 -1
- package/lib/cjs/erp/PublicApi.d.ts +10 -0
- package/lib/cjs/erp/PublicApi.js +16 -1
- package/lib/cjs/i18n/en.json +2 -0
- package/lib/cjs/i18n/zh-Hans.json +1 -0
- package/lib/cjs/i18n/zh-Hant.json +1 -0
- package/lib/mjs/app/CoreApp.d.ts +2 -2
- package/lib/mjs/app/IApp.d.ts +17 -1
- package/lib/mjs/business/ProductUnit.d.ts +28 -1
- package/lib/mjs/business/ProductUnit.js +16 -0
- package/lib/mjs/business/RepeatOption.d.ts +1 -1
- package/lib/mjs/business/RepeatOption.js +1 -1
- package/lib/mjs/erp/PublicApi.d.ts +10 -0
- package/lib/mjs/erp/PublicApi.js +17 -2
- package/lib/mjs/i18n/en.json +2 -0
- package/lib/mjs/i18n/zh-Hans.json +1 -0
- package/lib/mjs/i18n/zh-Hant.json +1 -0
- package/package.json +2 -2
- package/src/app/CoreApp.ts +2 -2
- package/src/app/IApp.ts +39 -1
- package/src/business/ProductUnit.ts +23 -1
- package/src/business/RepeatOption.ts +1 -1
- package/src/erp/PublicApi.ts +20 -2
- package/src/i18n/en.json +2 -0
- package/src/i18n/zh-Hans.json +1 -0
- package/src/i18n/zh-Hant.json +1 -0
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -359,7 +359,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
359
359
|
* @param filter Filter
|
|
360
360
|
* @returns List
|
|
361
361
|
*/
|
|
362
|
-
|
|
362
|
+
getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): ListType[];
|
|
363
363
|
/**
|
|
364
364
|
* Get enum item string id list
|
|
365
365
|
* @param em Enum
|
|
@@ -367,7 +367,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
367
367
|
* @param filter Filter
|
|
368
368
|
* @returns List
|
|
369
369
|
*/
|
|
370
|
-
|
|
370
|
+
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[];
|
|
371
371
|
/**
|
|
372
372
|
* Get region label
|
|
373
373
|
* @param id Region id
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { INotifier, NotificationAlign, NotificationCallProps, NotificationContent, NotificationReturn } from '@etsoo/notificationbase';
|
|
2
2
|
import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
|
|
3
|
-
import { DataTypes, DateUtils, IStorage, ListType } from '@etsoo/shared';
|
|
3
|
+
import { DataTypes, DateUtils, IStorage, ListType, ListType1 } from '@etsoo/shared';
|
|
4
4
|
import { AddressRegion } from '../address/AddressRegion';
|
|
5
5
|
import { IActionResult } from '../result/IActionResult';
|
|
6
6
|
import { IUser } from '../state/User';
|
|
@@ -288,6 +288,22 @@ export interface IApp {
|
|
|
288
288
|
* @returns Cached token
|
|
289
289
|
*/
|
|
290
290
|
getCacheToken(): string | undefined;
|
|
291
|
+
/**
|
|
292
|
+
* Get enum item number id list
|
|
293
|
+
* @param em Enum
|
|
294
|
+
* @param prefix Label prefix
|
|
295
|
+
* @param filter Filter
|
|
296
|
+
* @returns List
|
|
297
|
+
*/
|
|
298
|
+
getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): ListType[];
|
|
299
|
+
/**
|
|
300
|
+
* Get enum item string id list
|
|
301
|
+
* @param em Enum
|
|
302
|
+
* @param prefix Label prefix
|
|
303
|
+
* @param filter Filter
|
|
304
|
+
* @returns List
|
|
305
|
+
*/
|
|
306
|
+
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[];
|
|
291
307
|
/**
|
|
292
308
|
* Get region label
|
|
293
309
|
* @param id Region id
|
|
@@ -15,6 +15,13 @@ export declare enum ProductBaseUnit {
|
|
|
15
15
|
*/
|
|
16
16
|
SET = 2
|
|
17
17
|
}
|
|
18
|
+
declare enum ProductAssetUnit {
|
|
19
|
+
/**
|
|
20
|
+
* Time
|
|
21
|
+
* 次
|
|
22
|
+
*/
|
|
23
|
+
TIME = 99
|
|
24
|
+
}
|
|
18
25
|
/**
|
|
19
26
|
* Product weight units
|
|
20
27
|
* Range 40 - 49
|
|
@@ -52,6 +59,7 @@ export declare const ProductUnit: {
|
|
|
52
59
|
JIN: ProductWeightUnit.JIN;
|
|
53
60
|
KILOGRAM: ProductWeightUnit.KILOGRAM;
|
|
54
61
|
TON: ProductWeightUnit.TON;
|
|
62
|
+
TIME: ProductAssetUnit.TIME;
|
|
55
63
|
HOUR: RepeatOption.HOUR;
|
|
56
64
|
DAY: RepeatOption.DAY;
|
|
57
65
|
YEAR: RepeatOption.YEAR;
|
|
@@ -65,4 +73,23 @@ export declare const ProductUnit: {
|
|
|
65
73
|
PC: ProductBaseUnit.PC;
|
|
66
74
|
SET: ProductBaseUnit.SET;
|
|
67
75
|
};
|
|
68
|
-
export type ProductUnit = ProductBaseUnit | RepeatOption | ProductWeightUnit;
|
|
76
|
+
export type ProductUnit = ProductBaseUnit | RepeatOption | ProductAssetUnit | ProductWeightUnit;
|
|
77
|
+
/**
|
|
78
|
+
* Product asset units enum
|
|
79
|
+
*/
|
|
80
|
+
export declare const AssetUnits: {
|
|
81
|
+
[x: number]: string;
|
|
82
|
+
TIME: ProductAssetUnit.TIME;
|
|
83
|
+
HOUR: RepeatOption.HOUR;
|
|
84
|
+
DAY: RepeatOption.DAY;
|
|
85
|
+
YEAR: RepeatOption.YEAR;
|
|
86
|
+
WEEK: RepeatOption.WEEK;
|
|
87
|
+
FORTNIGHT: RepeatOption.FORTNIGHT;
|
|
88
|
+
FOURWEEK: RepeatOption.FOURWEEK;
|
|
89
|
+
MONTH: RepeatOption.MONTH;
|
|
90
|
+
BIMONTH: RepeatOption.BIMONTH;
|
|
91
|
+
QUATER: RepeatOption.QUATER;
|
|
92
|
+
HALFYEAR: RepeatOption.HALFYEAR;
|
|
93
|
+
};
|
|
94
|
+
export type AssetUnits = RepeatOption | ProductAssetUnit;
|
|
95
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProductUnit = exports.ProductWeightUnit = exports.ProductBaseUnit = void 0;
|
|
3
|
+
exports.AssetUnits = exports.ProductUnit = exports.ProductWeightUnit = exports.ProductBaseUnit = void 0;
|
|
4
4
|
const RepeatOption_1 = require("./RepeatOption");
|
|
5
5
|
/**
|
|
6
6
|
* Product base units
|
|
@@ -19,6 +19,14 @@ var ProductBaseUnit;
|
|
|
19
19
|
*/
|
|
20
20
|
ProductBaseUnit[ProductBaseUnit["SET"] = 2] = "SET";
|
|
21
21
|
})(ProductBaseUnit = exports.ProductBaseUnit || (exports.ProductBaseUnit = {}));
|
|
22
|
+
var ProductAssetUnit;
|
|
23
|
+
(function (ProductAssetUnit) {
|
|
24
|
+
/**
|
|
25
|
+
* Time
|
|
26
|
+
* 次
|
|
27
|
+
*/
|
|
28
|
+
ProductAssetUnit[ProductAssetUnit["TIME"] = 99] = "TIME";
|
|
29
|
+
})(ProductAssetUnit || (ProductAssetUnit = {}));
|
|
22
30
|
/**
|
|
23
31
|
* Product weight units
|
|
24
32
|
* Range 40 - 49
|
|
@@ -54,5 +62,13 @@ var ProductWeightUnit;
|
|
|
54
62
|
exports.ProductUnit = {
|
|
55
63
|
...ProductBaseUnit,
|
|
56
64
|
...RepeatOption_1.RepeatOption,
|
|
65
|
+
...ProductAssetUnit,
|
|
57
66
|
...ProductWeightUnit
|
|
58
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Product asset units enum
|
|
70
|
+
*/
|
|
71
|
+
exports.AssetUnits = {
|
|
72
|
+
...RepeatOption_1.RepeatOption,
|
|
73
|
+
...ProductAssetUnit
|
|
74
|
+
};
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RepeatOption = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Repeat options
|
|
6
|
-
*
|
|
6
|
+
* com.etsoo.CoreFramework.Business.RepeatOption
|
|
7
7
|
* Part of ProductUnit, range 10 - 39
|
|
8
8
|
*/
|
|
9
9
|
var RepeatOption;
|
|
@@ -15,6 +15,16 @@ export declare class PublicApi extends BaseApi {
|
|
|
15
15
|
* Default currency
|
|
16
16
|
*/
|
|
17
17
|
defaultCurrency: string | Currency;
|
|
18
|
+
/**
|
|
19
|
+
* Asset units
|
|
20
|
+
* @returns Result
|
|
21
|
+
*/
|
|
22
|
+
assetUnits(): ListType1[];
|
|
23
|
+
/**
|
|
24
|
+
* Base units
|
|
25
|
+
* @returns Result
|
|
26
|
+
*/
|
|
27
|
+
baseUnits(): ListType1[];
|
|
18
28
|
/**
|
|
19
29
|
* Get currencies
|
|
20
30
|
* @param names Limited currency names for local data, undefined will try to retrive remoately
|
package/lib/cjs/erp/PublicApi.js
CHANGED
|
@@ -7,6 +7,7 @@ const ProductUnit_1 = require("../business/ProductUnit");
|
|
|
7
7
|
const RepeatOption_1 = require("../business/RepeatOption");
|
|
8
8
|
const BaseApi_1 = require("./BaseApi");
|
|
9
9
|
const cachedCurrencyRates = {};
|
|
10
|
+
const unitPrefix = 'unit';
|
|
10
11
|
/**
|
|
11
12
|
* Public API
|
|
12
13
|
*/
|
|
@@ -18,6 +19,20 @@ class PublicApi extends BaseApi_1.BaseApi {
|
|
|
18
19
|
*/
|
|
19
20
|
this.defaultCurrency = this.app.defaultRegion.currency;
|
|
20
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Asset units
|
|
24
|
+
* @returns Result
|
|
25
|
+
*/
|
|
26
|
+
assetUnits() {
|
|
27
|
+
return this.app.getEnumStrList(ProductUnit_1.AssetUnits, unitPrefix);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Base units
|
|
31
|
+
* @returns Result
|
|
32
|
+
*/
|
|
33
|
+
baseUnits() {
|
|
34
|
+
return this.app.getEnumStrList(ProductUnit_1.ProductUnit, unitPrefix);
|
|
35
|
+
}
|
|
21
36
|
currencies(names) {
|
|
22
37
|
if (typeof names === 'boolean' && names) {
|
|
23
38
|
return Currency_1.Currencies.map((name) => {
|
|
@@ -116,7 +131,7 @@ class PublicApi extends BaseApi_1.BaseApi {
|
|
|
116
131
|
getUnitLabel(unit, isJoined) {
|
|
117
132
|
var _a;
|
|
118
133
|
const key = ProductUnit_1.ProductUnit[unit];
|
|
119
|
-
const label = (_a = this.app.get(
|
|
134
|
+
const label = (_a = this.app.get(unitPrefix + key)) !== null && _a !== void 0 ? _a : key;
|
|
120
135
|
const join = this.getUnitJoin(isJoined);
|
|
121
136
|
if (join) {
|
|
122
137
|
return join.format(label);
|
package/lib/cjs/i18n/en.json
CHANGED
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -359,7 +359,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
359
359
|
* @param filter Filter
|
|
360
360
|
* @returns List
|
|
361
361
|
*/
|
|
362
|
-
|
|
362
|
+
getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): ListType[];
|
|
363
363
|
/**
|
|
364
364
|
* Get enum item string id list
|
|
365
365
|
* @param em Enum
|
|
@@ -367,7 +367,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
367
367
|
* @param filter Filter
|
|
368
368
|
* @returns List
|
|
369
369
|
*/
|
|
370
|
-
|
|
370
|
+
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[];
|
|
371
371
|
/**
|
|
372
372
|
* Get region label
|
|
373
373
|
* @param id Region id
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { INotifier, NotificationAlign, NotificationCallProps, NotificationContent, NotificationReturn } from '@etsoo/notificationbase';
|
|
2
2
|
import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
|
|
3
|
-
import { DataTypes, DateUtils, IStorage, ListType } from '@etsoo/shared';
|
|
3
|
+
import { DataTypes, DateUtils, IStorage, ListType, ListType1 } from '@etsoo/shared';
|
|
4
4
|
import { AddressRegion } from '../address/AddressRegion';
|
|
5
5
|
import { IActionResult } from '../result/IActionResult';
|
|
6
6
|
import { IUser } from '../state/User';
|
|
@@ -288,6 +288,22 @@ export interface IApp {
|
|
|
288
288
|
* @returns Cached token
|
|
289
289
|
*/
|
|
290
290
|
getCacheToken(): string | undefined;
|
|
291
|
+
/**
|
|
292
|
+
* Get enum item number id list
|
|
293
|
+
* @param em Enum
|
|
294
|
+
* @param prefix Label prefix
|
|
295
|
+
* @param filter Filter
|
|
296
|
+
* @returns List
|
|
297
|
+
*/
|
|
298
|
+
getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: (id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined): ListType[];
|
|
299
|
+
/**
|
|
300
|
+
* Get enum item string id list
|
|
301
|
+
* @param em Enum
|
|
302
|
+
* @param prefix Label prefix
|
|
303
|
+
* @param filter Filter
|
|
304
|
+
* @returns List
|
|
305
|
+
*/
|
|
306
|
+
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[];
|
|
291
307
|
/**
|
|
292
308
|
* Get region label
|
|
293
309
|
* @param id Region id
|
|
@@ -15,6 +15,13 @@ export declare enum ProductBaseUnit {
|
|
|
15
15
|
*/
|
|
16
16
|
SET = 2
|
|
17
17
|
}
|
|
18
|
+
declare enum ProductAssetUnit {
|
|
19
|
+
/**
|
|
20
|
+
* Time
|
|
21
|
+
* 次
|
|
22
|
+
*/
|
|
23
|
+
TIME = 99
|
|
24
|
+
}
|
|
18
25
|
/**
|
|
19
26
|
* Product weight units
|
|
20
27
|
* Range 40 - 49
|
|
@@ -52,6 +59,7 @@ export declare const ProductUnit: {
|
|
|
52
59
|
JIN: ProductWeightUnit.JIN;
|
|
53
60
|
KILOGRAM: ProductWeightUnit.KILOGRAM;
|
|
54
61
|
TON: ProductWeightUnit.TON;
|
|
62
|
+
TIME: ProductAssetUnit.TIME;
|
|
55
63
|
HOUR: RepeatOption.HOUR;
|
|
56
64
|
DAY: RepeatOption.DAY;
|
|
57
65
|
YEAR: RepeatOption.YEAR;
|
|
@@ -65,4 +73,23 @@ export declare const ProductUnit: {
|
|
|
65
73
|
PC: ProductBaseUnit.PC;
|
|
66
74
|
SET: ProductBaseUnit.SET;
|
|
67
75
|
};
|
|
68
|
-
export type ProductUnit = ProductBaseUnit | RepeatOption | ProductWeightUnit;
|
|
76
|
+
export type ProductUnit = ProductBaseUnit | RepeatOption | ProductAssetUnit | ProductWeightUnit;
|
|
77
|
+
/**
|
|
78
|
+
* Product asset units enum
|
|
79
|
+
*/
|
|
80
|
+
export declare const AssetUnits: {
|
|
81
|
+
[x: number]: string;
|
|
82
|
+
TIME: ProductAssetUnit.TIME;
|
|
83
|
+
HOUR: RepeatOption.HOUR;
|
|
84
|
+
DAY: RepeatOption.DAY;
|
|
85
|
+
YEAR: RepeatOption.YEAR;
|
|
86
|
+
WEEK: RepeatOption.WEEK;
|
|
87
|
+
FORTNIGHT: RepeatOption.FORTNIGHT;
|
|
88
|
+
FOURWEEK: RepeatOption.FOURWEEK;
|
|
89
|
+
MONTH: RepeatOption.MONTH;
|
|
90
|
+
BIMONTH: RepeatOption.BIMONTH;
|
|
91
|
+
QUATER: RepeatOption.QUATER;
|
|
92
|
+
HALFYEAR: RepeatOption.HALFYEAR;
|
|
93
|
+
};
|
|
94
|
+
export type AssetUnits = RepeatOption | ProductAssetUnit;
|
|
95
|
+
export {};
|
|
@@ -16,6 +16,14 @@ export var ProductBaseUnit;
|
|
|
16
16
|
*/
|
|
17
17
|
ProductBaseUnit[ProductBaseUnit["SET"] = 2] = "SET";
|
|
18
18
|
})(ProductBaseUnit || (ProductBaseUnit = {}));
|
|
19
|
+
var ProductAssetUnit;
|
|
20
|
+
(function (ProductAssetUnit) {
|
|
21
|
+
/**
|
|
22
|
+
* Time
|
|
23
|
+
* 次
|
|
24
|
+
*/
|
|
25
|
+
ProductAssetUnit[ProductAssetUnit["TIME"] = 99] = "TIME";
|
|
26
|
+
})(ProductAssetUnit || (ProductAssetUnit = {}));
|
|
19
27
|
/**
|
|
20
28
|
* Product weight units
|
|
21
29
|
* Range 40 - 49
|
|
@@ -51,5 +59,13 @@ export var ProductWeightUnit;
|
|
|
51
59
|
export const ProductUnit = {
|
|
52
60
|
...ProductBaseUnit,
|
|
53
61
|
...RepeatOption,
|
|
62
|
+
...ProductAssetUnit,
|
|
54
63
|
...ProductWeightUnit
|
|
55
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Product asset units enum
|
|
67
|
+
*/
|
|
68
|
+
export const AssetUnits = {
|
|
69
|
+
...RepeatOption,
|
|
70
|
+
...ProductAssetUnit
|
|
71
|
+
};
|
|
@@ -15,6 +15,16 @@ export declare class PublicApi extends BaseApi {
|
|
|
15
15
|
* Default currency
|
|
16
16
|
*/
|
|
17
17
|
defaultCurrency: string | Currency;
|
|
18
|
+
/**
|
|
19
|
+
* Asset units
|
|
20
|
+
* @returns Result
|
|
21
|
+
*/
|
|
22
|
+
assetUnits(): ListType1[];
|
|
23
|
+
/**
|
|
24
|
+
* Base units
|
|
25
|
+
* @returns Result
|
|
26
|
+
*/
|
|
27
|
+
baseUnits(): ListType1[];
|
|
18
28
|
/**
|
|
19
29
|
* Get currencies
|
|
20
30
|
* @param names Limited currency names for local data, undefined will try to retrive remoately
|
package/lib/mjs/erp/PublicApi.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { DataTypes } from '@etsoo/shared';
|
|
2
2
|
import { Currencies } from '../business/Currency';
|
|
3
|
-
import { ProductUnit } from '../business/ProductUnit';
|
|
3
|
+
import { AssetUnits, ProductUnit } from '../business/ProductUnit';
|
|
4
4
|
import { RepeatOption } from '../business/RepeatOption';
|
|
5
5
|
import { BaseApi } from './BaseApi';
|
|
6
6
|
const cachedCurrencyRates = {};
|
|
7
|
+
const unitPrefix = 'unit';
|
|
7
8
|
/**
|
|
8
9
|
* Public API
|
|
9
10
|
*/
|
|
@@ -15,6 +16,20 @@ export class PublicApi extends BaseApi {
|
|
|
15
16
|
*/
|
|
16
17
|
this.defaultCurrency = this.app.defaultRegion.currency;
|
|
17
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Asset units
|
|
21
|
+
* @returns Result
|
|
22
|
+
*/
|
|
23
|
+
assetUnits() {
|
|
24
|
+
return this.app.getEnumStrList(AssetUnits, unitPrefix);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Base units
|
|
28
|
+
* @returns Result
|
|
29
|
+
*/
|
|
30
|
+
baseUnits() {
|
|
31
|
+
return this.app.getEnumStrList(ProductUnit, unitPrefix);
|
|
32
|
+
}
|
|
18
33
|
currencies(names) {
|
|
19
34
|
if (typeof names === 'boolean' && names) {
|
|
20
35
|
return Currencies.map((name) => {
|
|
@@ -113,7 +128,7 @@ export class PublicApi extends BaseApi {
|
|
|
113
128
|
getUnitLabel(unit, isJoined) {
|
|
114
129
|
var _a;
|
|
115
130
|
const key = ProductUnit[unit];
|
|
116
|
-
const label = (_a = this.app.get(
|
|
131
|
+
const label = (_a = this.app.get(unitPrefix + key)) !== null && _a !== void 0 ? _a : key;
|
|
117
132
|
const join = this.getUnitJoin(isJoined);
|
|
118
133
|
if (join) {
|
|
119
134
|
return join.format(label);
|
package/lib/mjs/i18n/en.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.62",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
"jest": "^29.4.1",
|
|
69
69
|
"jest-environment-jsdom": "^29.4.1",
|
|
70
70
|
"ts-jest": "^29.0.5",
|
|
71
|
-
"typescript": "^4.9.
|
|
71
|
+
"typescript": "^4.9.5"
|
|
72
72
|
}
|
|
73
73
|
}
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -1195,7 +1195,7 @@ export abstract class CoreApp<
|
|
|
1195
1195
|
* @param filter Filter
|
|
1196
1196
|
* @returns List
|
|
1197
1197
|
*/
|
|
1198
|
-
|
|
1198
|
+
getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(
|
|
1199
1199
|
em: E,
|
|
1200
1200
|
prefix: string,
|
|
1201
1201
|
filter?: (
|
|
@@ -1226,7 +1226,7 @@ export abstract class CoreApp<
|
|
|
1226
1226
|
* @param filter Filter
|
|
1227
1227
|
* @returns List
|
|
1228
1228
|
*/
|
|
1229
|
-
|
|
1229
|
+
getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(
|
|
1230
1230
|
em: E,
|
|
1231
1231
|
prefix: string,
|
|
1232
1232
|
filter?: (
|
package/src/app/IApp.ts
CHANGED
|
@@ -6,7 +6,13 @@ import {
|
|
|
6
6
|
NotificationReturn
|
|
7
7
|
} from '@etsoo/notificationbase';
|
|
8
8
|
import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
DataTypes,
|
|
11
|
+
DateUtils,
|
|
12
|
+
IStorage,
|
|
13
|
+
ListType,
|
|
14
|
+
ListType1
|
|
15
|
+
} from '@etsoo/shared';
|
|
10
16
|
import { AddressRegion } from '../address/AddressRegion';
|
|
11
17
|
import { IActionResult } from '../result/IActionResult';
|
|
12
18
|
import { IUser } from '../state/User';
|
|
@@ -379,6 +385,38 @@ export interface IApp {
|
|
|
379
385
|
*/
|
|
380
386
|
getCacheToken(): string | undefined;
|
|
381
387
|
|
|
388
|
+
/**
|
|
389
|
+
* Get enum item number id list
|
|
390
|
+
* @param em Enum
|
|
391
|
+
* @param prefix Label prefix
|
|
392
|
+
* @param filter Filter
|
|
393
|
+
* @returns List
|
|
394
|
+
*/
|
|
395
|
+
getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(
|
|
396
|
+
em: E,
|
|
397
|
+
prefix: string,
|
|
398
|
+
filter?: (
|
|
399
|
+
id: E[keyof E],
|
|
400
|
+
key: keyof E & string
|
|
401
|
+
) => E[keyof E] | undefined
|
|
402
|
+
): ListType[];
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Get enum item string id list
|
|
406
|
+
* @param em Enum
|
|
407
|
+
* @param prefix Label prefix
|
|
408
|
+
* @param filter Filter
|
|
409
|
+
* @returns List
|
|
410
|
+
*/
|
|
411
|
+
getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(
|
|
412
|
+
em: E,
|
|
413
|
+
prefix: string,
|
|
414
|
+
filter?: (
|
|
415
|
+
id: E[keyof E],
|
|
416
|
+
key: keyof E & string
|
|
417
|
+
) => E[keyof E] | undefined
|
|
418
|
+
): ListType1[];
|
|
419
|
+
|
|
382
420
|
/**
|
|
383
421
|
* Get region label
|
|
384
422
|
* @param id Region id
|
|
@@ -18,6 +18,14 @@ export enum ProductBaseUnit {
|
|
|
18
18
|
SET = 2
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
enum ProductAssetUnit {
|
|
22
|
+
/**
|
|
23
|
+
* Time
|
|
24
|
+
* 次
|
|
25
|
+
*/
|
|
26
|
+
TIME = 99
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
/**
|
|
22
30
|
* Product weight units
|
|
23
31
|
* Range 40 - 49
|
|
@@ -56,6 +64,20 @@ export enum ProductWeightUnit {
|
|
|
56
64
|
export const ProductUnit = {
|
|
57
65
|
...ProductBaseUnit,
|
|
58
66
|
...RepeatOption,
|
|
67
|
+
...ProductAssetUnit,
|
|
59
68
|
...ProductWeightUnit
|
|
60
69
|
};
|
|
61
|
-
export type ProductUnit =
|
|
70
|
+
export type ProductUnit =
|
|
71
|
+
| ProductBaseUnit
|
|
72
|
+
| RepeatOption
|
|
73
|
+
| ProductAssetUnit
|
|
74
|
+
| ProductWeightUnit;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Product asset units enum
|
|
78
|
+
*/
|
|
79
|
+
export const AssetUnits = {
|
|
80
|
+
...RepeatOption,
|
|
81
|
+
...ProductAssetUnit
|
|
82
|
+
};
|
|
83
|
+
export type AssetUnits = RepeatOption | ProductAssetUnit;
|
package/src/erp/PublicApi.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IApiPayload } from '@etsoo/restclient';
|
|
2
2
|
import { DataTypes, ListType, ListType1 } from '@etsoo/shared';
|
|
3
3
|
import { Currencies, Currency } from '../business/Currency';
|
|
4
|
-
import { ProductUnit } from '../business/ProductUnit';
|
|
4
|
+
import { AssetUnits, ProductUnit } from '../business/ProductUnit';
|
|
5
5
|
import { RepeatOption } from '../business/RepeatOption';
|
|
6
6
|
import { BaseApi } from './BaseApi';
|
|
7
7
|
import { CurrencyDto } from './dto/CurrencyDto';
|
|
@@ -13,6 +13,8 @@ const cachedCurrencyRates: {
|
|
|
13
13
|
[P: Currency | string]: ExchangeRateDto | undefined | null;
|
|
14
14
|
} = {};
|
|
15
15
|
|
|
16
|
+
const unitPrefix = 'unit';
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* Public API
|
|
18
20
|
*/
|
|
@@ -22,6 +24,22 @@ export class PublicApi extends BaseApi {
|
|
|
22
24
|
*/
|
|
23
25
|
defaultCurrency: string | Currency = this.app.defaultRegion.currency;
|
|
24
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Asset units
|
|
29
|
+
* @returns Result
|
|
30
|
+
*/
|
|
31
|
+
assetUnits() {
|
|
32
|
+
return this.app.getEnumStrList(AssetUnits, unitPrefix);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Base units
|
|
37
|
+
* @returns Result
|
|
38
|
+
*/
|
|
39
|
+
baseUnits() {
|
|
40
|
+
return this.app.getEnumStrList(ProductUnit, unitPrefix);
|
|
41
|
+
}
|
|
42
|
+
|
|
25
43
|
/**
|
|
26
44
|
* Get currencies
|
|
27
45
|
* @param names Limited currency names for local data, undefined will try to retrive remoately
|
|
@@ -149,7 +167,7 @@ export class PublicApi extends BaseApi {
|
|
|
149
167
|
*/
|
|
150
168
|
getUnitLabel(unit: ProductUnit | number, isJoined?: boolean | string) {
|
|
151
169
|
const key = ProductUnit[unit];
|
|
152
|
-
const label = this.app.get(
|
|
170
|
+
const label = this.app.get(unitPrefix + key) ?? key;
|
|
153
171
|
const join = this.getUnitJoin(isJoined);
|
|
154
172
|
if (join) {
|
|
155
173
|
return join.format(label);
|
package/src/i18n/en.json
CHANGED
package/src/i18n/zh-Hans.json
CHANGED