@etsoo/appscript 1.2.24 → 1.2.25
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 +15 -0
- package/lib/cjs/app/CoreApp.d.ts +13 -0
- package/lib/cjs/app/CoreApp.js +10 -0
- package/lib/cjs/business/BusinessUtils.d.ts +21 -2
- package/lib/cjs/business/BusinessUtils.js +32 -6
- package/lib/cjs/business/ProductUnit.d.ts +47 -45
- package/lib/cjs/business/ProductUnit.js +36 -48
- package/lib/cjs/business/RepeatOption.d.ts +56 -0
- package/lib/cjs/business/RepeatOption.js +60 -0
- package/lib/cjs/i18n/en-US.json +17 -0
- package/lib/cjs/i18n/zh-CN.json +18 -0
- package/lib/cjs/i18n/zh-HK.json +17 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/mjs/app/CoreApp.d.ts +13 -0
- package/lib/mjs/app/CoreApp.js +10 -0
- package/lib/mjs/business/BusinessUtils.d.ts +21 -2
- package/lib/mjs/business/BusinessUtils.js +32 -6
- package/lib/mjs/business/ProductUnit.d.ts +47 -45
- package/lib/mjs/business/ProductUnit.js +35 -47
- package/lib/mjs/business/RepeatOption.d.ts +56 -0
- package/lib/mjs/business/RepeatOption.js +57 -0
- package/lib/mjs/i18n/en-US.json +17 -0
- package/lib/mjs/i18n/zh-CN.json +18 -0
- package/lib/mjs/i18n/zh-HK.json +17 -0
- package/lib/mjs/index.d.ts +1 -0
- package/lib/mjs/index.js +1 -0
- package/package.json +6 -6
- package/src/app/CoreApp.ts +18 -0
- package/src/business/BusinessUtils.ts +66 -7
- package/src/business/ProductUnit.ts +35 -51
- package/src/business/RepeatOption.ts +65 -0
- package/src/i18n/en-US.json +17 -0
- package/src/i18n/zh-CN.json +18 -0
- package/src/i18n/zh-HK.json +17 -0
- package/src/index.ts +1 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
import { RepeatOption } from '..';
|
|
2
3
|
import { IdLabelDto } from '../dto/IdLabelDto';
|
|
3
4
|
import { ICultureGet } from '../state/Culture';
|
|
4
5
|
import { EntityStatus } from './EntityStatus';
|
|
@@ -27,7 +28,7 @@ export namespace BusinessUtils {
|
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Get product unit's label
|
|
30
|
-
* Please define the label in culture with key '
|
|
31
|
+
* Please define the label in culture with key 'statusNormal' for Normal status
|
|
31
32
|
* @param unit Unit
|
|
32
33
|
* @param func Label delegate
|
|
33
34
|
* @returns Label
|
|
@@ -62,11 +63,21 @@ export namespace BusinessUtils {
|
|
|
62
63
|
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
|
63
64
|
* @param unit Unit
|
|
64
65
|
* @param func Label delegate
|
|
66
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
65
67
|
* @returns Label
|
|
66
68
|
*/
|
|
67
|
-
export function getUnitLabel(
|
|
69
|
+
export function getUnitLabel(
|
|
70
|
+
unit: ProductUnit,
|
|
71
|
+
func: ICultureGet,
|
|
72
|
+
isJoined?: boolean
|
|
73
|
+
) {
|
|
68
74
|
const key = ProductUnit[unit];
|
|
69
|
-
|
|
75
|
+
const label = func('unit' + key) ?? key;
|
|
76
|
+
if (isJoined) {
|
|
77
|
+
const jLabel = func('unitJoin');
|
|
78
|
+
if (jLabel) return jLabel.format(label);
|
|
79
|
+
}
|
|
80
|
+
return label;
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
/**
|
|
@@ -74,13 +85,61 @@ export namespace BusinessUtils {
|
|
|
74
85
|
* @param func Label delegate
|
|
75
86
|
* @returns Units
|
|
76
87
|
*/
|
|
77
|
-
export function getUnits(func: ICultureGet): IdLabelDto[]
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
export function getUnits(func: ICultureGet): IdLabelDto[];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
* Get all product units
|
|
93
|
+
* @param func Label delegate
|
|
94
|
+
* @param options Define the order and limit the items
|
|
95
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
96
|
+
* @returns Units
|
|
97
|
+
*/
|
|
98
|
+
export function getUnits(
|
|
99
|
+
func: ICultureGet,
|
|
100
|
+
options?: string[],
|
|
101
|
+
isJoined?: boolean
|
|
102
|
+
): IdLabelDto[];
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* Get all product units
|
|
107
|
+
* @param func Label delegate
|
|
108
|
+
* @param options Define the order and limit the items
|
|
109
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
110
|
+
* @returns Units
|
|
111
|
+
*/
|
|
112
|
+
export function getUnits(
|
|
113
|
+
func: ICultureGet,
|
|
114
|
+
options?: string[],
|
|
115
|
+
isJoined?: boolean
|
|
116
|
+
): IdLabelDto[] {
|
|
117
|
+
options ??= DataTypes.getEnumKeys(ProductUnit);
|
|
118
|
+
return options.map((key) => {
|
|
119
|
+
const id = DataTypes.getEnumByKey(ProductUnit, key)! as number;
|
|
80
120
|
return {
|
|
81
121
|
id,
|
|
82
|
-
label: getUnitLabel(id, func)
|
|
122
|
+
label: getUnitLabel(id, func, isJoined).formatInitial(true)
|
|
83
123
|
};
|
|
84
124
|
});
|
|
85
125
|
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
* Get all repeat options
|
|
130
|
+
* @param func Label delegate
|
|
131
|
+
* @param options Define the order and limit the items
|
|
132
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
133
|
+
* @returns Units
|
|
134
|
+
*/
|
|
135
|
+
export function getRepeatOptions(
|
|
136
|
+
func: ICultureGet,
|
|
137
|
+
options?: string[],
|
|
138
|
+
isJoined: boolean = true
|
|
139
|
+
): IdLabelDto[] {
|
|
140
|
+
options ??= DataTypes.getEnumKeys(RepeatOption);
|
|
141
|
+
isJoined ??= true;
|
|
142
|
+
|
|
143
|
+
return getUnits(func, options, isJoined);
|
|
144
|
+
}
|
|
86
145
|
}
|
|
@@ -1,77 +1,61 @@
|
|
|
1
|
+
import { RepeatOption } from './RepeatOption';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* Product units
|
|
3
|
-
*
|
|
4
|
+
* Product base units
|
|
5
|
+
* 1 - 9
|
|
4
6
|
*/
|
|
5
|
-
export enum
|
|
7
|
+
export enum ProductBaseUnit {
|
|
6
8
|
/**
|
|
7
9
|
* Picese
|
|
8
10
|
* 件
|
|
9
11
|
*/
|
|
10
|
-
PC =
|
|
12
|
+
PC = 1,
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Set
|
|
14
16
|
* 套
|
|
15
17
|
*/
|
|
16
|
-
SET =
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Year
|
|
20
|
-
* 年
|
|
21
|
-
*/
|
|
22
|
-
YEAR = 10,
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Quater
|
|
26
|
-
* 季
|
|
27
|
-
*/
|
|
28
|
-
QUATER = 11,
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Month
|
|
32
|
-
* 月
|
|
33
|
-
*/
|
|
34
|
-
MONTH = 12,
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Fortnight
|
|
38
|
-
* 两周
|
|
39
|
-
*/
|
|
40
|
-
FORNIGHT = 13,
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Week
|
|
44
|
-
* 周
|
|
45
|
-
*/
|
|
46
|
-
WEEK = 14,
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Day
|
|
50
|
-
* 天
|
|
51
|
-
*/
|
|
52
|
-
DAY = 15,
|
|
18
|
+
SET = 2
|
|
19
|
+
}
|
|
53
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Product weight units
|
|
23
|
+
* Range 40 - 49
|
|
24
|
+
*/
|
|
25
|
+
export enum ProductWeightUnit {
|
|
54
26
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
27
|
+
* Gram
|
|
28
|
+
* 克
|
|
57
29
|
*/
|
|
58
|
-
|
|
30
|
+
GRAM = 40,
|
|
59
31
|
|
|
60
32
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
33
|
+
* Half Kg
|
|
34
|
+
* 斤
|
|
63
35
|
*/
|
|
64
|
-
|
|
36
|
+
JIN = 41,
|
|
65
37
|
|
|
66
38
|
/**
|
|
67
39
|
* Kilogram
|
|
68
40
|
* 千克
|
|
69
41
|
*/
|
|
70
|
-
KILOGRAM =
|
|
42
|
+
KILOGRAM = 42,
|
|
71
43
|
|
|
72
44
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
45
|
+
* Ton
|
|
46
|
+
* 吨
|
|
75
47
|
*/
|
|
76
|
-
|
|
48
|
+
TON = 49
|
|
77
49
|
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Product units enum
|
|
53
|
+
* Repeat options take range 10 - 39
|
|
54
|
+
* See com.etsoo.CoreFramework.Business.ProductUnit
|
|
55
|
+
*/
|
|
56
|
+
export const ProductUnit = {
|
|
57
|
+
...ProductBaseUnit,
|
|
58
|
+
...RepeatOption,
|
|
59
|
+
...ProductWeightUnit
|
|
60
|
+
};
|
|
61
|
+
export type ProductUnit = ProductBaseUnit | RepeatOption | ProductWeightUnit;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repeat options
|
|
3
|
+
* Part of ProductUnit, range 10 - 39
|
|
4
|
+
*/
|
|
5
|
+
export enum RepeatOption {
|
|
6
|
+
/**
|
|
7
|
+
* Hour
|
|
8
|
+
* 小时
|
|
9
|
+
*/
|
|
10
|
+
HOUR = 10,
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Day
|
|
14
|
+
* 天
|
|
15
|
+
*/
|
|
16
|
+
DAY = 11,
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Year
|
|
20
|
+
* 年
|
|
21
|
+
*/
|
|
22
|
+
YEAR = 12,
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Week
|
|
26
|
+
* 周
|
|
27
|
+
*/
|
|
28
|
+
WEEK = 21,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Two weeks
|
|
32
|
+
* 两周
|
|
33
|
+
*/
|
|
34
|
+
FORTNIGHT = 22,
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Four weeks
|
|
38
|
+
* 四周
|
|
39
|
+
*/
|
|
40
|
+
FOURWEEK = 24,
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Month
|
|
44
|
+
* 月
|
|
45
|
+
*/
|
|
46
|
+
MONTH = 31,
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Two months
|
|
50
|
+
* 两月
|
|
51
|
+
*/
|
|
52
|
+
BIMONTH = 32,
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Quater(3 months)
|
|
56
|
+
* 季(三个月)
|
|
57
|
+
*/
|
|
58
|
+
QUATER = 33,
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Half a year
|
|
62
|
+
* 半年
|
|
63
|
+
*/
|
|
64
|
+
HALFYEAR = 36
|
|
65
|
+
}
|
package/src/i18n/en-US.json
CHANGED
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"pageNotFound": "Page Not Found",
|
|
45
45
|
"prompt": "Input",
|
|
46
46
|
"pullToRefresh": "Pull down to refresh",
|
|
47
|
+
"record": "Record",
|
|
47
48
|
"refresh": "Refresh",
|
|
48
49
|
"refreshing": "Refreshing",
|
|
49
50
|
"releaseToRefresh": "Release to refresh",
|
|
@@ -77,6 +78,22 @@
|
|
|
77
78
|
"tokenExpiry": "Your session is about to expire. Click the Cancel button to continue",
|
|
78
79
|
"yes": "Yes",
|
|
79
80
|
"unknownError": "Unknown Error",
|
|
81
|
+
"unitJoin": "per {0}",
|
|
82
|
+
"unitPC": "PC",
|
|
83
|
+
"unitSET": "SET",
|
|
84
|
+
"unitHOUR": "Hour",
|
|
85
|
+
"unitDAY": "Day",
|
|
86
|
+
"unitYEAR": "Year",
|
|
87
|
+
"unitWEEK": "Week",
|
|
88
|
+
"unitFORTNIGHT": "Fortnight",
|
|
89
|
+
"unitFOURWEEK": "4-week",
|
|
90
|
+
"unitMONTH": "Month",
|
|
91
|
+
"unitBIMONTH": "2-month",
|
|
92
|
+
"unitQUATER": "Quater",
|
|
93
|
+
"unitHALFYEAR": "6-month",
|
|
94
|
+
"unitGRAM": "g",
|
|
95
|
+
"unitJIN": "½Kg",
|
|
96
|
+
"unitKILOGRAM": "Kg",
|
|
80
97
|
"warning": "Warning",
|
|
81
98
|
"welcome": "{0}, welcome!"
|
|
82
99
|
}
|
package/src/i18n/zh-CN.json
CHANGED
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"pageNotFound": "找不到页面",
|
|
45
45
|
"prompt": "输入",
|
|
46
46
|
"pullToRefresh": "下拉刷新",
|
|
47
|
+
"record": "记录",
|
|
47
48
|
"refresh": "刷新",
|
|
48
49
|
"refreshing": "正在刷新",
|
|
49
50
|
"releaseToRefresh": "释放刷新",
|
|
@@ -77,6 +78,23 @@
|
|
|
77
78
|
"tokenExpiry": "您的会话即将过期。点击 取消 按钮继续使用",
|
|
78
79
|
"yes": "是",
|
|
79
80
|
"unknownError": "未知错误",
|
|
81
|
+
"unitJoin": "每{0}",
|
|
82
|
+
"unitPC": "件",
|
|
83
|
+
"unitSET": "套",
|
|
84
|
+
"unitHOUR": "小时",
|
|
85
|
+
"unitDAY": "天",
|
|
86
|
+
"unitYEAR": "年",
|
|
87
|
+
"unitWEEK": "周",
|
|
88
|
+
"unitFORTNIGHT": "两周",
|
|
89
|
+
"unitFOURWEEK": "四周",
|
|
90
|
+
"unitMONTH": "月",
|
|
91
|
+
"unitBIMONTH": "两月",
|
|
92
|
+
"unitQUATER": "季度",
|
|
93
|
+
"unitHALFYEAR": "半年",
|
|
94
|
+
"unitGRAM": "克",
|
|
95
|
+
"unitJIN": "斤",
|
|
96
|
+
"unitKILOGRAM": "公斤",
|
|
97
|
+
"unitTON": "吨",
|
|
80
98
|
"warning": "警告",
|
|
81
99
|
"welcome": "{0}, 欢迎光临!"
|
|
82
100
|
}
|
package/src/i18n/zh-HK.json
CHANGED
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"pageNotFound": "找不到頁面",
|
|
45
45
|
"prompt": "輸入",
|
|
46
46
|
"pullToRefresh": "下拉刷新",
|
|
47
|
+
"record": "記錄",
|
|
47
48
|
"refresh": "刷新",
|
|
48
49
|
"refreshing": "正在刷新",
|
|
49
50
|
"releaseToRefresh": "釋放刷新",
|
|
@@ -77,6 +78,22 @@
|
|
|
77
78
|
"tokenExpiry": "您的會話即將過期。點擊 取消 按鈕繼續使用",
|
|
78
79
|
"yes": "是",
|
|
79
80
|
"unknownError": "未知錯誤",
|
|
81
|
+
"unitJoin": "每{0}",
|
|
82
|
+
"unitPC": "件",
|
|
83
|
+
"unitSET": "套",
|
|
84
|
+
"unitHOUR": "小時",
|
|
85
|
+
"unitDAY": "天",
|
|
86
|
+
"unitYEAR": "年",
|
|
87
|
+
"unitWEEK": "週",
|
|
88
|
+
"unitFORTNIGHT": "兩週",
|
|
89
|
+
"unitFOURWEEK": "四周",
|
|
90
|
+
"unitMONTH": "月",
|
|
91
|
+
"unitBIMONTH": "兩月",
|
|
92
|
+
"unitQUATER": "季度",
|
|
93
|
+
"unitHALFYEAR": "半年",
|
|
94
|
+
"unitGRAM": "克",
|
|
95
|
+
"unitJIN": "斤",
|
|
96
|
+
"unitKILOGRAM": "公斤",
|
|
80
97
|
"warning": "警告",
|
|
81
98
|
"welcome": "{0}, 歡迎光臨!"
|
|
82
99
|
}
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ export * from './business/BusinessTax';
|
|
|
19
19
|
export * from './business/BusinessUtils';
|
|
20
20
|
export * from './business/EntityStatus';
|
|
21
21
|
export * from './business/ProductUnit';
|
|
22
|
+
export * from './business/RepeatOption';
|
|
22
23
|
|
|
23
24
|
// def
|
|
24
25
|
export * from './def/ListItem';
|