@etsoo/appscript 1.3.59 → 1.3.61

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.
@@ -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
- protected 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[];
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
- 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[];
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
@@ -425,6 +425,21 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
425
425
  * @returns Result
426
426
  */
427
427
  hasPermission(roles: number | UserRole | number[] | UserRole[]): boolean;
428
+ /**
429
+ * Is admin user
430
+ * @returns Result
431
+ */
432
+ isAdminUser(): boolean;
433
+ /**
434
+ * Is Finance user
435
+ * @returns Result
436
+ */
437
+ isFinanceUser(): boolean;
438
+ /**
439
+ * Is HR user
440
+ * @returns Result
441
+ */
442
+ isHRUser(): boolean;
428
443
  /**
429
444
  * Navigate to Url or delta
430
445
  * @param url Url or delta
@@ -1019,6 +1019,27 @@ class CoreApp {
1019
1019
  return true;
1020
1020
  return false;
1021
1021
  }
1022
+ /**
1023
+ * Is admin user
1024
+ * @returns Result
1025
+ */
1026
+ isAdminUser() {
1027
+ return this.hasPermission([UserRole_1.UserRole.Admin, UserRole_1.UserRole.Founder]);
1028
+ }
1029
+ /**
1030
+ * Is Finance user
1031
+ * @returns Result
1032
+ */
1033
+ isFinanceUser() {
1034
+ return this.hasPermission(UserRole_1.UserRole.Finance) || this.isAdminUser();
1035
+ }
1036
+ /**
1037
+ * Is HR user
1038
+ * @returns Result
1039
+ */
1040
+ isHRUser() {
1041
+ return this.hasPermission(UserRole_1.UserRole.HRManager) || this.isAdminUser();
1042
+ }
1022
1043
  /**
1023
1044
  * Navigate to Url or delta
1024
1045
  * @param url Url or delta
@@ -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
@@ -352,6 +368,21 @@ export interface IApp {
352
368
  * @returns Result
353
369
  */
354
370
  initCall(callback?: (result: boolean) => void, resetKeys?: boolean): Promise<void>;
371
+ /**
372
+ * Is admin user
373
+ * @returns Result
374
+ */
375
+ isAdminUser(): boolean;
376
+ /**
377
+ * Is Finance user
378
+ * @returns Result
379
+ */
380
+ isFinanceUser(): boolean;
381
+ /**
382
+ * Is HR user
383
+ * @returns Result
384
+ */
385
+ isHRUser(): boolean;
355
386
  /**
356
387
  * Is valid password, override to implement custom check
357
388
  * @param password Input password
@@ -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
+ };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Repeat options
3
- * @see com.etsoo.CoreFramework.Business.RepeatOption
3
+ * com.etsoo.CoreFramework.Business.RepeatOption
4
4
  * Part of ProductUnit, range 10 - 39
5
5
  */
6
6
  export declare enum RepeatOption {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RepeatOption = void 0;
4
4
  /**
5
5
  * Repeat options
6
- * @see com.etsoo.CoreFramework.Business.RepeatOption
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
+ basetUnits(): ListType1[];
18
28
  /**
19
29
  * Get currencies
20
30
  * @param names Limited currency names for local data, undefined will try to retrive remoately
@@ -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
+ basetUnits() {
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('unit' + key)) !== null && _a !== void 0 ? _a : key;
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);
@@ -194,6 +194,8 @@
194
194
  "unitGRAM": "g",
195
195
  "unitJIN": "½Kg",
196
196
  "unitKILOGRAM": "Kg",
197
+ "unitTIME": "Time",
198
+ "unitTON": "Ton",
197
199
  "update": "Update",
198
200
  "updateReady": "Update ready",
199
201
  "updateTip": "Restart the application to use the latest features",
@@ -194,6 +194,7 @@
194
194
  "unitGRAM": "克",
195
195
  "unitJIN": "斤",
196
196
  "unitKILOGRAM": "公斤",
197
+ "unitTIME": "次",
197
198
  "unitTON": "吨",
198
199
  "update": "更新",
199
200
  "updateReady": "更新就绪",
@@ -194,6 +194,7 @@
194
194
  "unitGRAM": "克",
195
195
  "unitJIN": "斤",
196
196
  "unitKILOGRAM": "公斤",
197
+ "unitTIME": "次",
197
198
  "update": "更新",
198
199
  "updateReady": "更新就緒",
199
200
  "updateTip": "重新啟動應用程序以使用最新功能",
@@ -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
- protected 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[];
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
- 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[];
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
@@ -425,6 +425,21 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
425
425
  * @returns Result
426
426
  */
427
427
  hasPermission(roles: number | UserRole | number[] | UserRole[]): boolean;
428
+ /**
429
+ * Is admin user
430
+ * @returns Result
431
+ */
432
+ isAdminUser(): boolean;
433
+ /**
434
+ * Is Finance user
435
+ * @returns Result
436
+ */
437
+ isFinanceUser(): boolean;
438
+ /**
439
+ * Is HR user
440
+ * @returns Result
441
+ */
442
+ isHRUser(): boolean;
428
443
  /**
429
444
  * Navigate to Url or delta
430
445
  * @param url Url or delta
@@ -1016,6 +1016,27 @@ export class CoreApp {
1016
1016
  return true;
1017
1017
  return false;
1018
1018
  }
1019
+ /**
1020
+ * Is admin user
1021
+ * @returns Result
1022
+ */
1023
+ isAdminUser() {
1024
+ return this.hasPermission([UserRole.Admin, UserRole.Founder]);
1025
+ }
1026
+ /**
1027
+ * Is Finance user
1028
+ * @returns Result
1029
+ */
1030
+ isFinanceUser() {
1031
+ return this.hasPermission(UserRole.Finance) || this.isAdminUser();
1032
+ }
1033
+ /**
1034
+ * Is HR user
1035
+ * @returns Result
1036
+ */
1037
+ isHRUser() {
1038
+ return this.hasPermission(UserRole.HRManager) || this.isAdminUser();
1039
+ }
1019
1040
  /**
1020
1041
  * Navigate to Url or delta
1021
1042
  * @param url Url or delta
@@ -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
@@ -352,6 +368,21 @@ export interface IApp {
352
368
  * @returns Result
353
369
  */
354
370
  initCall(callback?: (result: boolean) => void, resetKeys?: boolean): Promise<void>;
371
+ /**
372
+ * Is admin user
373
+ * @returns Result
374
+ */
375
+ isAdminUser(): boolean;
376
+ /**
377
+ * Is Finance user
378
+ * @returns Result
379
+ */
380
+ isFinanceUser(): boolean;
381
+ /**
382
+ * Is HR user
383
+ * @returns Result
384
+ */
385
+ isHRUser(): boolean;
355
386
  /**
356
387
  * Is valid password, override to implement custom check
357
388
  * @param password Input password
@@ -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
+ };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Repeat options
3
- * @see com.etsoo.CoreFramework.Business.RepeatOption
3
+ * com.etsoo.CoreFramework.Business.RepeatOption
4
4
  * Part of ProductUnit, range 10 - 39
5
5
  */
6
6
  export declare enum RepeatOption {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Repeat options
3
- * @see com.etsoo.CoreFramework.Business.RepeatOption
3
+ * com.etsoo.CoreFramework.Business.RepeatOption
4
4
  * Part of ProductUnit, range 10 - 39
5
5
  */
6
6
  export 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
+ basetUnits(): ListType1[];
18
28
  /**
19
29
  * Get currencies
20
30
  * @param names Limited currency names for local data, undefined will try to retrive remoately
@@ -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
+ basetUnits() {
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('unit' + key)) !== null && _a !== void 0 ? _a : key;
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);
@@ -194,6 +194,8 @@
194
194
  "unitGRAM": "g",
195
195
  "unitJIN": "½Kg",
196
196
  "unitKILOGRAM": "Kg",
197
+ "unitTIME": "Time",
198
+ "unitTON": "Ton",
197
199
  "update": "Update",
198
200
  "updateReady": "Update ready",
199
201
  "updateTip": "Restart the application to use the latest features",
@@ -194,6 +194,7 @@
194
194
  "unitGRAM": "克",
195
195
  "unitJIN": "斤",
196
196
  "unitKILOGRAM": "公斤",
197
+ "unitTIME": "次",
197
198
  "unitTON": "吨",
198
199
  "update": "更新",
199
200
  "updateReady": "更新就绪",
@@ -194,6 +194,7 @@
194
194
  "unitGRAM": "克",
195
195
  "unitJIN": "斤",
196
196
  "unitKILOGRAM": "公斤",
197
+ "unitTIME": "次",
197
198
  "update": "更新",
198
199
  "updateReady": "更新就緒",
199
200
  "updateTip": "重新啟動應用程序以使用最新功能",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.3.59",
3
+ "version": "1.3.61",
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.4"
71
+ "typescript": "^4.9.5"
72
72
  }
73
73
  }
@@ -1195,7 +1195,7 @@ export abstract class CoreApp<
1195
1195
  * @param filter Filter
1196
1196
  * @returns List
1197
1197
  */
1198
- protected getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(
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
- protected getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(
1229
+ getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(
1230
1230
  em: E,
1231
1231
  prefix: string,
1232
1232
  filter?: (
@@ -1361,6 +1361,30 @@ export abstract class CoreApp<
1361
1361
  return false;
1362
1362
  }
1363
1363
 
1364
+ /**
1365
+ * Is admin user
1366
+ * @returns Result
1367
+ */
1368
+ isAdminUser() {
1369
+ return this.hasPermission([UserRole.Admin, UserRole.Founder]);
1370
+ }
1371
+
1372
+ /**
1373
+ * Is Finance user
1374
+ * @returns Result
1375
+ */
1376
+ isFinanceUser() {
1377
+ return this.hasPermission(UserRole.Finance) || this.isAdminUser();
1378
+ }
1379
+
1380
+ /**
1381
+ * Is HR user
1382
+ * @returns Result
1383
+ */
1384
+ isHRUser() {
1385
+ return this.hasPermission(UserRole.HRManager) || this.isAdminUser();
1386
+ }
1387
+
1364
1388
  /**
1365
1389
  * Navigate to Url or delta
1366
1390
  * @param url Url or delta
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 { DataTypes, DateUtils, IStorage, ListType } from '@etsoo/shared';
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
@@ -457,6 +495,24 @@ export interface IApp {
457
495
  resetKeys?: boolean
458
496
  ): Promise<void>;
459
497
 
498
+ /**
499
+ * Is admin user
500
+ * @returns Result
501
+ */
502
+ isAdminUser(): boolean;
503
+
504
+ /**
505
+ * Is Finance user
506
+ * @returns Result
507
+ */
508
+ isFinanceUser(): boolean;
509
+
510
+ /**
511
+ * Is HR user
512
+ * @returns Result
513
+ */
514
+ isHRUser(): boolean;
515
+
460
516
  /**
461
517
  * Is valid password, override to implement custom check
462
518
  * @param password Input password
@@ -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 = ProductBaseUnit | RepeatOption | ProductWeightUnit;
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;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Repeat options
3
- * @see com.etsoo.CoreFramework.Business.RepeatOption
3
+ * com.etsoo.CoreFramework.Business.RepeatOption
4
4
  * Part of ProductUnit, range 10 - 39
5
5
  */
6
6
  export enum RepeatOption {
@@ -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
+ basetUnits() {
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('unit' + key) ?? key;
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
@@ -194,6 +194,8 @@
194
194
  "unitGRAM": "g",
195
195
  "unitJIN": "½Kg",
196
196
  "unitKILOGRAM": "Kg",
197
+ "unitTIME": "Time",
198
+ "unitTON": "Ton",
197
199
  "update": "Update",
198
200
  "updateReady": "Update ready",
199
201
  "updateTip": "Restart the application to use the latest features",
@@ -194,6 +194,7 @@
194
194
  "unitGRAM": "克",
195
195
  "unitJIN": "斤",
196
196
  "unitKILOGRAM": "公斤",
197
+ "unitTIME": "次",
197
198
  "unitTON": "吨",
198
199
  "update": "更新",
199
200
  "updateReady": "更新就绪",
@@ -194,6 +194,7 @@
194
194
  "unitGRAM": "克",
195
195
  "unitJIN": "斤",
196
196
  "unitKILOGRAM": "公斤",
197
+ "unitTIME": "次",
197
198
  "update": "更新",
198
199
  "updateReady": "更新就緒",
199
200
  "updateTip": "重新啟動應用程序以使用最新功能",