@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.
Files changed (36) hide show
  1. package/__tests__/app/CoreApp.ts +15 -0
  2. package/lib/cjs/app/CoreApp.d.ts +13 -0
  3. package/lib/cjs/app/CoreApp.js +10 -0
  4. package/lib/cjs/business/BusinessUtils.d.ts +21 -2
  5. package/lib/cjs/business/BusinessUtils.js +32 -6
  6. package/lib/cjs/business/ProductUnit.d.ts +47 -45
  7. package/lib/cjs/business/ProductUnit.js +36 -48
  8. package/lib/cjs/business/RepeatOption.d.ts +56 -0
  9. package/lib/cjs/business/RepeatOption.js +60 -0
  10. package/lib/cjs/i18n/en-US.json +17 -0
  11. package/lib/cjs/i18n/zh-CN.json +18 -0
  12. package/lib/cjs/i18n/zh-HK.json +17 -0
  13. package/lib/cjs/index.d.ts +1 -0
  14. package/lib/cjs/index.js +1 -0
  15. package/lib/mjs/app/CoreApp.d.ts +13 -0
  16. package/lib/mjs/app/CoreApp.js +10 -0
  17. package/lib/mjs/business/BusinessUtils.d.ts +21 -2
  18. package/lib/mjs/business/BusinessUtils.js +32 -6
  19. package/lib/mjs/business/ProductUnit.d.ts +47 -45
  20. package/lib/mjs/business/ProductUnit.js +35 -47
  21. package/lib/mjs/business/RepeatOption.d.ts +56 -0
  22. package/lib/mjs/business/RepeatOption.js +57 -0
  23. package/lib/mjs/i18n/en-US.json +17 -0
  24. package/lib/mjs/i18n/zh-CN.json +18 -0
  25. package/lib/mjs/i18n/zh-HK.json +17 -0
  26. package/lib/mjs/index.d.ts +1 -0
  27. package/lib/mjs/index.js +1 -0
  28. package/package.json +6 -6
  29. package/src/app/CoreApp.ts +18 -0
  30. package/src/business/BusinessUtils.ts +66 -7
  31. package/src/business/ProductUnit.ts +35 -51
  32. package/src/business/RepeatOption.ts +65 -0
  33. package/src/i18n/en-US.json +17 -0
  34. package/src/i18n/zh-CN.json +18 -0
  35. package/src/i18n/zh-HK.json +17 -0
  36. package/src/index.ts +1 -0
@@ -740,6 +740,16 @@ export class CoreApp {
740
740
  // settings.timeZone = Utils.getTimeZone()
741
741
  return (_a = this.settings.timeZone) !== null && _a !== void 0 ? _a : (_b = this.ipData) === null || _b === void 0 ? void 0 : _b.timezone;
742
742
  }
743
+ /**
744
+ * Get product unit and repeat option label
745
+ * @param unit Product unit or repeat option
746
+ * @param isJoined Add the join label like 'per Kg' for Kg
747
+ */
748
+ getUnitLabel(unit, isJoined) {
749
+ if (unit == null)
750
+ return '';
751
+ return BusinessUtils.getUnitLabel(unit, this.labelDelegate, isJoined);
752
+ }
743
753
  /**
744
754
  * Hash message, SHA3 or HmacSHA512, 512 as Base64
745
755
  * https://cryptojs.gitbook.io/docs/
@@ -16,7 +16,7 @@ export declare namespace BusinessUtils {
16
16
  function addIdLabelBlankItem<T extends DataTypes.IdType = number>(input: IdLabelDto<T>[], copy?: boolean): IdLabelDto<T>[];
17
17
  /**
18
18
  * Get product unit's label
19
- * Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
19
+ * Please define the label in culture with key 'statusNormal' for Normal status
20
20
  * @param unit Unit
21
21
  * @param func Label delegate
22
22
  * @returns Label
@@ -38,13 +38,32 @@ export declare namespace BusinessUtils {
38
38
  * Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
39
39
  * @param unit Unit
40
40
  * @param func Label delegate
41
+ * @param isJoined Add the join label like 'per Kg' for Kg
41
42
  * @returns Label
42
43
  */
43
- function getUnitLabel(unit: ProductUnit, func: ICultureGet): string;
44
+ function getUnitLabel(unit: ProductUnit, func: ICultureGet, isJoined?: boolean): string;
44
45
  /**
45
46
  * Get all product units
46
47
  * @param func Label delegate
47
48
  * @returns Units
48
49
  */
49
50
  function getUnits(func: ICultureGet): IdLabelDto[];
51
+ /**
52
+ *
53
+ * Get all product units
54
+ * @param func Label delegate
55
+ * @param options Define the order and limit the items
56
+ * @param isJoined Add the join label like 'per Kg' for Kg
57
+ * @returns Units
58
+ */
59
+ function getUnits(func: ICultureGet, options?: string[], isJoined?: boolean): IdLabelDto[];
60
+ /**
61
+ *
62
+ * Get all repeat options
63
+ * @param func Label delegate
64
+ * @param options Define the order and limit the items
65
+ * @param isJoined Add the join label like 'per Kg' for Kg
66
+ * @returns Units
67
+ */
68
+ function getRepeatOptions(func: ICultureGet, options?: string[], isJoined?: boolean): IdLabelDto[];
50
69
  }
@@ -1,4 +1,5 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
+ import { RepeatOption } from '..';
2
3
  import { EntityStatus } from './EntityStatus';
3
4
  import { ProductUnit } from './ProductUnit';
4
5
  /**
@@ -22,7 +23,7 @@ export var BusinessUtils;
22
23
  BusinessUtils.addIdLabelBlankItem = addIdLabelBlankItem;
23
24
  /**
24
25
  * Get product unit's label
25
- * Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
26
+ * Please define the label in culture with key 'statusNormal' for Normal status
26
27
  * @param unit Unit
27
28
  * @param func Label delegate
28
29
  * @returns Label
@@ -55,27 +56,52 @@ export var BusinessUtils;
55
56
  * Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
56
57
  * @param unit Unit
57
58
  * @param func Label delegate
59
+ * @param isJoined Add the join label like 'per Kg' for Kg
58
60
  * @returns Label
59
61
  */
60
- function getUnitLabel(unit, func) {
62
+ function getUnitLabel(unit, func, isJoined) {
61
63
  var _a;
62
64
  const key = ProductUnit[unit];
63
- return (_a = func('unit' + key)) !== null && _a !== void 0 ? _a : key;
65
+ const label = (_a = func('unit' + key)) !== null && _a !== void 0 ? _a : key;
66
+ if (isJoined) {
67
+ const jLabel = func('unitJoin');
68
+ if (jLabel)
69
+ return jLabel.format(label);
70
+ }
71
+ return label;
64
72
  }
65
73
  BusinessUtils.getUnitLabel = getUnitLabel;
66
74
  /**
75
+ *
67
76
  * Get all product units
68
77
  * @param func Label delegate
78
+ * @param options Define the order and limit the items
79
+ * @param isJoined Add the join label like 'per Kg' for Kg
69
80
  * @returns Units
70
81
  */
71
- function getUnits(func) {
72
- return DataTypes.getEnumKeys(ProductUnit).map((key) => {
82
+ function getUnits(func, options, isJoined) {
83
+ options !== null && options !== void 0 ? options : (options = DataTypes.getEnumKeys(ProductUnit));
84
+ return options.map((key) => {
73
85
  const id = DataTypes.getEnumByKey(ProductUnit, key);
74
86
  return {
75
87
  id,
76
- label: getUnitLabel(id, func)
88
+ label: getUnitLabel(id, func, isJoined).formatInitial(true)
77
89
  };
78
90
  });
79
91
  }
80
92
  BusinessUtils.getUnits = getUnits;
93
+ /**
94
+ *
95
+ * Get all repeat options
96
+ * @param func Label delegate
97
+ * @param options Define the order and limit the items
98
+ * @param isJoined Add the join label like 'per Kg' for Kg
99
+ * @returns Units
100
+ */
101
+ function getRepeatOptions(func, options, isJoined = true) {
102
+ options !== null && options !== void 0 ? options : (options = DataTypes.getEnumKeys(RepeatOption));
103
+ isJoined !== null && isJoined !== void 0 ? isJoined : (isJoined = true);
104
+ return getUnits(func, options, isJoined);
105
+ }
106
+ BusinessUtils.getRepeatOptions = getRepeatOptions;
81
107
  })(BusinessUtils || (BusinessUtils = {}));
@@ -1,66 +1,68 @@
1
+ import { RepeatOption } from './RepeatOption';
1
2
  /**
2
- * Product units enum
3
- * See com.etsoo.CoreFramework.Business.ProductUnit
3
+ * Product base units
4
+ * 1 - 9
4
5
  */
5
- export declare enum ProductUnit {
6
+ export declare enum ProductBaseUnit {
6
7
  /**
7
8
  * Picese
8
9
  * 件
9
10
  */
10
- PC = 0,
11
+ PC = 1,
11
12
  /**
12
13
  * Set
13
14
  * 套
14
15
  */
15
- SET = 1,
16
- /**
17
- * Year
18
- *
19
- */
20
- YEAR = 10,
21
- /**
22
- * Quater
23
- * 季
24
- */
25
- QUATER = 11,
26
- /**
27
- * Month
28
- * 月
29
- */
30
- MONTH = 12,
31
- /**
32
- * Fortnight
33
- * 两周
34
- */
35
- FORNIGHT = 13,
36
- /**
37
- * Week
38
- * 周
39
- */
40
- WEEK = 14,
41
- /**
42
- * Day
43
- * 天
44
- */
45
- DAY = 15,
16
+ SET = 2
17
+ }
18
+ /**
19
+ * Product weight units
20
+ * Range 40 - 49
21
+ */
22
+ export declare enum ProductWeightUnit {
46
23
  /**
47
- * Hour
48
- * 小时
24
+ * Gram
25
+ *
49
26
  */
50
- HOUR = 16,
27
+ GRAM = 40,
51
28
  /**
52
- * Ton
53
- *
29
+ * Half Kg
30
+ *
54
31
  */
55
- TON = 31,
32
+ JIN = 41,
56
33
  /**
57
34
  * Kilogram
58
35
  * 千克
59
36
  */
60
- KILOGRAM = 32,
37
+ KILOGRAM = 42,
61
38
  /**
62
- * Gram
63
- *
39
+ * Ton
40
+ *
64
41
  */
65
- GRAM = 33
42
+ TON = 49
66
43
  }
44
+ /**
45
+ * Product units enum
46
+ * Repeat options take range 10 - 39
47
+ * See com.etsoo.CoreFramework.Business.ProductUnit
48
+ */
49
+ export declare const ProductUnit: {
50
+ [x: number]: string;
51
+ GRAM: ProductWeightUnit.GRAM;
52
+ JIN: ProductWeightUnit.JIN;
53
+ KILOGRAM: ProductWeightUnit.KILOGRAM;
54
+ TON: ProductWeightUnit.TON;
55
+ HOUR: RepeatOption.HOUR;
56
+ DAY: RepeatOption.DAY;
57
+ YEAR: RepeatOption.YEAR;
58
+ WEEK: RepeatOption.WEEK;
59
+ FORTNIGHT: RepeatOption.FORTNIGHT;
60
+ FOURWEEK: RepeatOption.FOURWEEK;
61
+ MONTH: RepeatOption.MONTH;
62
+ BIMONTH: RepeatOption.BIMONTH;
63
+ QUATER: RepeatOption.QUATER;
64
+ HALFYEAR: RepeatOption.HALFYEAR;
65
+ PC: ProductBaseUnit.PC;
66
+ SET: ProductBaseUnit.SET;
67
+ };
68
+ export declare type ProductUnit = ProductBaseUnit | RepeatOption | ProductWeightUnit;
@@ -1,67 +1,55 @@
1
+ import { RepeatOption } from './RepeatOption';
1
2
  /**
2
- * Product units enum
3
- * See com.etsoo.CoreFramework.Business.ProductUnit
3
+ * Product base units
4
+ * 1 - 9
4
5
  */
5
- export var ProductUnit;
6
- (function (ProductUnit) {
6
+ export var ProductBaseUnit;
7
+ (function (ProductBaseUnit) {
7
8
  /**
8
9
  * Picese
9
10
  * 件
10
11
  */
11
- ProductUnit[ProductUnit["PC"] = 0] = "PC";
12
+ ProductBaseUnit[ProductBaseUnit["PC"] = 1] = "PC";
12
13
  /**
13
14
  * Set
14
15
  * 套
15
16
  */
16
- ProductUnit[ProductUnit["SET"] = 1] = "SET";
17
- /**
18
- * Year
19
- *
20
- */
21
- ProductUnit[ProductUnit["YEAR"] = 10] = "YEAR";
22
- /**
23
- * Quater
24
- * 季
25
- */
26
- ProductUnit[ProductUnit["QUATER"] = 11] = "QUATER";
27
- /**
28
- * Month
29
- * 月
30
- */
31
- ProductUnit[ProductUnit["MONTH"] = 12] = "MONTH";
32
- /**
33
- * Fortnight
34
- * 两周
35
- */
36
- ProductUnit[ProductUnit["FORNIGHT"] = 13] = "FORNIGHT";
37
- /**
38
- * Week
39
- * 周
40
- */
41
- ProductUnit[ProductUnit["WEEK"] = 14] = "WEEK";
42
- /**
43
- * Day
44
- * 天
45
- */
46
- ProductUnit[ProductUnit["DAY"] = 15] = "DAY";
17
+ ProductBaseUnit[ProductBaseUnit["SET"] = 2] = "SET";
18
+ })(ProductBaseUnit || (ProductBaseUnit = {}));
19
+ /**
20
+ * Product weight units
21
+ * Range 40 - 49
22
+ */
23
+ export var ProductWeightUnit;
24
+ (function (ProductWeightUnit) {
47
25
  /**
48
- * Hour
49
- * 小时
26
+ * Gram
27
+ *
50
28
  */
51
- ProductUnit[ProductUnit["HOUR"] = 16] = "HOUR";
29
+ ProductWeightUnit[ProductWeightUnit["GRAM"] = 40] = "GRAM";
52
30
  /**
53
- * Ton
54
- *
31
+ * Half Kg
32
+ *
55
33
  */
56
- ProductUnit[ProductUnit["TON"] = 31] = "TON";
34
+ ProductWeightUnit[ProductWeightUnit["JIN"] = 41] = "JIN";
57
35
  /**
58
36
  * Kilogram
59
37
  * 千克
60
38
  */
61
- ProductUnit[ProductUnit["KILOGRAM"] = 32] = "KILOGRAM";
39
+ ProductWeightUnit[ProductWeightUnit["KILOGRAM"] = 42] = "KILOGRAM";
62
40
  /**
63
- * Gram
64
- *
41
+ * Ton
42
+ *
65
43
  */
66
- ProductUnit[ProductUnit["GRAM"] = 33] = "GRAM";
67
- })(ProductUnit || (ProductUnit = {}));
44
+ ProductWeightUnit[ProductWeightUnit["TON"] = 49] = "TON";
45
+ })(ProductWeightUnit || (ProductWeightUnit = {}));
46
+ /**
47
+ * Product units enum
48
+ * Repeat options take range 10 - 39
49
+ * See com.etsoo.CoreFramework.Business.ProductUnit
50
+ */
51
+ export const ProductUnit = {
52
+ ...ProductBaseUnit,
53
+ ...RepeatOption,
54
+ ...ProductWeightUnit
55
+ };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Repeat options
3
+ * Part of ProductUnit, range 10 - 39
4
+ */
5
+ export declare enum RepeatOption {
6
+ /**
7
+ * Hour
8
+ * 小时
9
+ */
10
+ HOUR = 10,
11
+ /**
12
+ * Day
13
+ * 天
14
+ */
15
+ DAY = 11,
16
+ /**
17
+ * Year
18
+ * 年
19
+ */
20
+ YEAR = 12,
21
+ /**
22
+ * Week
23
+ * 周
24
+ */
25
+ WEEK = 21,
26
+ /**
27
+ * Two weeks
28
+ * 两周
29
+ */
30
+ FORTNIGHT = 22,
31
+ /**
32
+ * Four weeks
33
+ * 四周
34
+ */
35
+ FOURWEEK = 24,
36
+ /**
37
+ * Month
38
+ * 月
39
+ */
40
+ MONTH = 31,
41
+ /**
42
+ * Two months
43
+ * 两月
44
+ */
45
+ BIMONTH = 32,
46
+ /**
47
+ * Quater(3 months)
48
+ * 季(三个月)
49
+ */
50
+ QUATER = 33,
51
+ /**
52
+ * Half a year
53
+ * 半年
54
+ */
55
+ HALFYEAR = 36
56
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Repeat options
3
+ * Part of ProductUnit, range 10 - 39
4
+ */
5
+ export var RepeatOption;
6
+ (function (RepeatOption) {
7
+ /**
8
+ * Hour
9
+ * 小时
10
+ */
11
+ RepeatOption[RepeatOption["HOUR"] = 10] = "HOUR";
12
+ /**
13
+ * Day
14
+ * 天
15
+ */
16
+ RepeatOption[RepeatOption["DAY"] = 11] = "DAY";
17
+ /**
18
+ * Year
19
+ * 年
20
+ */
21
+ RepeatOption[RepeatOption["YEAR"] = 12] = "YEAR";
22
+ /**
23
+ * Week
24
+ * 周
25
+ */
26
+ RepeatOption[RepeatOption["WEEK"] = 21] = "WEEK";
27
+ /**
28
+ * Two weeks
29
+ * 两周
30
+ */
31
+ RepeatOption[RepeatOption["FORTNIGHT"] = 22] = "FORTNIGHT";
32
+ /**
33
+ * Four weeks
34
+ * 四周
35
+ */
36
+ RepeatOption[RepeatOption["FOURWEEK"] = 24] = "FOURWEEK";
37
+ /**
38
+ * Month
39
+ * 月
40
+ */
41
+ RepeatOption[RepeatOption["MONTH"] = 31] = "MONTH";
42
+ /**
43
+ * Two months
44
+ * 两月
45
+ */
46
+ RepeatOption[RepeatOption["BIMONTH"] = 32] = "BIMONTH";
47
+ /**
48
+ * Quater(3 months)
49
+ * 季(三个月)
50
+ */
51
+ RepeatOption[RepeatOption["QUATER"] = 33] = "QUATER";
52
+ /**
53
+ * Half a year
54
+ * 半年
55
+ */
56
+ RepeatOption[RepeatOption["HALFYEAR"] = 36] = "HALFYEAR";
57
+ })(RepeatOption || (RepeatOption = {}));
@@ -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
  }
@@ -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
  }
@@ -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
  }
@@ -12,6 +12,7 @@ export * from './business/BusinessTax';
12
12
  export * from './business/BusinessUtils';
13
13
  export * from './business/EntityStatus';
14
14
  export * from './business/ProductUnit';
15
+ export * from './business/RepeatOption';
15
16
  export * from './def/ListItem';
16
17
  export * from './dto/IdDto';
17
18
  export * from './dto/IdLabelDto';
package/lib/mjs/index.js CHANGED
@@ -16,6 +16,7 @@ export * from './business/BusinessTax';
16
16
  export * from './business/BusinessUtils';
17
17
  export * from './business/EntityStatus';
18
18
  export * from './business/ProductUnit';
19
+ export * from './business/RepeatOption';
19
20
  // def
20
21
  export * from './def/ListItem';
21
22
  // dto
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.2.24",
3
+ "version": "1.2.25",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -54,7 +54,7 @@
54
54
  "dependencies": {
55
55
  "@etsoo/notificationbase": "^1.1.0",
56
56
  "@etsoo/restclient": "^1.0.64",
57
- "@etsoo/shared": "^1.1.3",
57
+ "@etsoo/shared": "^1.1.5",
58
58
  "@types/crypto-js": "^4.1.0",
59
59
  "crypto-js": "^4.1.1"
60
60
  },
@@ -65,13 +65,13 @@
65
65
  "@babel/preset-env": "^7.16.8",
66
66
  "@babel/runtime-corejs3": "^7.16.8",
67
67
  "@types/jest": "^27.4.0",
68
- "@typescript-eslint/eslint-plugin": "^5.9.1",
69
- "@typescript-eslint/parser": "^5.9.1",
70
- "eslint": "^8.6.0",
68
+ "@typescript-eslint/eslint-plugin": "^5.10.0",
69
+ "@typescript-eslint/parser": "^5.10.0",
70
+ "eslint": "^8.7.0",
71
71
  "eslint-config-airbnb-base": "^15.0.0",
72
72
  "eslint-plugin-import": "^2.25.4",
73
73
  "jest": "^27.4.7",
74
- "ts-jest": "^27.1.2",
74
+ "ts-jest": "^27.1.3",
75
75
  "typescript": "^4.5.4"
76
76
  }
77
77
  }
@@ -30,6 +30,7 @@ import {
30
30
  import { AddressRegion } from '../address/AddressRegion';
31
31
  import { AddressUtils } from '../address/AddressUtils';
32
32
  import { BusinessUtils } from '../business/BusinessUtils';
33
+ import { ProductUnit } from '../business/ProductUnit';
33
34
  import { IdLabelDto } from '../dto/IdLabelDto';
34
35
  import { InitCallDto } from '../dto/InitCallDto';
35
36
  import { ActionResultError } from '../result/ActionResultError';
@@ -356,6 +357,13 @@ export interface ICoreApp<
356
357
  */
357
358
  getTimeZone(): string | undefined;
358
359
 
360
+ /**
361
+ * Get product unit and repeat option label
362
+ * @param unit Product unit or repeat option
363
+ * @param isJoined Add the join label like 'per Kg' for Kg
364
+ */
365
+ getUnitLabel(unit?: ProductUnit, isJoined?: boolean): string;
366
+
359
367
  /**
360
368
  * Hash message, SHA3 or HmacSHA512, 512 as Base64
361
369
  * https://cryptojs.gitbook.io/docs/
@@ -1427,6 +1435,16 @@ export abstract class CoreApp<
1427
1435
  return this.settings.timeZone ?? this.ipData?.timezone;
1428
1436
  }
1429
1437
 
1438
+ /**
1439
+ * Get product unit and repeat option label
1440
+ * @param unit Product unit or repeat option
1441
+ * @param isJoined Add the join label like 'per Kg' for Kg
1442
+ */
1443
+ getUnitLabel(unit?: ProductUnit, isJoined?: boolean): string {
1444
+ if (unit == null) return '';
1445
+ return BusinessUtils.getUnitLabel(unit, this.labelDelegate, isJoined);
1446
+ }
1447
+
1430
1448
  /**
1431
1449
  * Hash message, SHA3 or HmacSHA512, 512 as Base64
1432
1450
  * https://cryptojs.gitbook.io/docs/