@etsoo/appscript 1.2.74 → 1.2.75
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 +33 -7
- package/lib/cjs/app/CoreApp.js +67 -16
- package/lib/cjs/business/BusinessUtils.d.ts +0 -19
- package/lib/cjs/business/BusinessUtils.js +0 -30
- 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/mjs/app/CoreApp.d.ts +33 -7
- package/lib/mjs/app/CoreApp.js +67 -16
- package/lib/mjs/business/BusinessUtils.d.ts +0 -19
- package/lib/mjs/business/BusinessUtils.js +0 -30
- 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/package.json +3 -3
- package/src/app/CoreApp.ts +88 -22
- package/src/business/BusinessUtils.ts +0 -32
- 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/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -260,11 +260,6 @@ export interface ICoreApp<U extends IUser, S extends IAppSettings, N, C extends
|
|
|
260
260
|
* @returns Cached token
|
|
261
261
|
*/
|
|
262
262
|
getCacheToken(): string | undefined;
|
|
263
|
-
/**
|
|
264
|
-
* Get entity status label
|
|
265
|
-
* @param status Status value
|
|
266
|
-
*/
|
|
267
|
-
getEntityStatusLabel(status: number | null | undefined): string;
|
|
268
263
|
/**
|
|
269
264
|
* Get all regions
|
|
270
265
|
* @returns Regions
|
|
@@ -275,6 +270,16 @@ export interface ICoreApp<U extends IUser, S extends IAppSettings, N, C extends
|
|
|
275
270
|
* @param role Combination role value
|
|
276
271
|
*/
|
|
277
272
|
getRoles(role: number): IdLabelDto[];
|
|
273
|
+
/**
|
|
274
|
+
* Get status label
|
|
275
|
+
* @param status Status value
|
|
276
|
+
*/
|
|
277
|
+
getStatusLabel(status: number | null | undefined): string;
|
|
278
|
+
/**
|
|
279
|
+
* Get status list
|
|
280
|
+
* @returns list
|
|
281
|
+
*/
|
|
282
|
+
getStatusList(): IdLabelDto[];
|
|
278
283
|
/**
|
|
279
284
|
* Get refresh token from response headers
|
|
280
285
|
* @param rawResponse Raw response from API call
|
|
@@ -705,6 +710,22 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
705
710
|
* @returns Cached token
|
|
706
711
|
*/
|
|
707
712
|
getCacheToken(): string | undefined;
|
|
713
|
+
/**
|
|
714
|
+
* Get enum item number id list
|
|
715
|
+
* @param em Enum
|
|
716
|
+
* @param prefix Label prefix
|
|
717
|
+
* @param filter Filter
|
|
718
|
+
* @returns List
|
|
719
|
+
*/
|
|
720
|
+
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): IdLabelDto[];
|
|
721
|
+
/**
|
|
722
|
+
* Get enum item string id list
|
|
723
|
+
* @param em Enum
|
|
724
|
+
* @param prefix Label prefix
|
|
725
|
+
* @param filter Filter
|
|
726
|
+
* @returns List
|
|
727
|
+
*/
|
|
728
|
+
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): IdLabelDto<string>[];
|
|
708
729
|
/**
|
|
709
730
|
* Get all regions
|
|
710
731
|
* @returns Regions
|
|
@@ -716,10 +737,15 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
716
737
|
*/
|
|
717
738
|
getRoles(role: number): IdLabelDto<number>[];
|
|
718
739
|
/**
|
|
719
|
-
* Get
|
|
740
|
+
* Get status list
|
|
741
|
+
* @returns list
|
|
742
|
+
*/
|
|
743
|
+
getStatusList(): IdLabelDto<number>[];
|
|
744
|
+
/**
|
|
745
|
+
* Get status label
|
|
720
746
|
* @param status Status value
|
|
721
747
|
*/
|
|
722
|
-
|
|
748
|
+
getStatusLabel(status: number | null | undefined): string;
|
|
723
749
|
/**
|
|
724
750
|
* Get refresh token from response headers
|
|
725
751
|
* @param rawResponse Raw response from API call
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -9,6 +9,7 @@ const AddressRegion_1 = require("../address/AddressRegion");
|
|
|
9
9
|
const AddressUtils_1 = require("../address/AddressUtils");
|
|
10
10
|
const BridgeUtils_1 = require("../bridges/BridgeUtils");
|
|
11
11
|
const BusinessUtils_1 = require("../business/BusinessUtils");
|
|
12
|
+
const EntityStatus_1 = require("../business/EntityStatus");
|
|
12
13
|
const ActionResultError_1 = require("../result/ActionResultError");
|
|
13
14
|
const UserRole_1 = require("./UserRole");
|
|
14
15
|
/**
|
|
@@ -829,6 +830,56 @@ class CoreApp {
|
|
|
829
830
|
return this.cachedRefreshToken;
|
|
830
831
|
return this.storage.getData(this.fields.headerToken);
|
|
831
832
|
}
|
|
833
|
+
/**
|
|
834
|
+
* Get enum item number id list
|
|
835
|
+
* @param em Enum
|
|
836
|
+
* @param prefix Label prefix
|
|
837
|
+
* @param filter Filter
|
|
838
|
+
* @returns List
|
|
839
|
+
*/
|
|
840
|
+
getEnumList(em, prefix, filter) {
|
|
841
|
+
var _a;
|
|
842
|
+
const list = [];
|
|
843
|
+
const keys = shared_1.DataTypes.getEnumKeys(em);
|
|
844
|
+
for (const key of keys) {
|
|
845
|
+
let id = em[key];
|
|
846
|
+
if (filter) {
|
|
847
|
+
const fid = filter(id, key);
|
|
848
|
+
if (fid == null)
|
|
849
|
+
continue;
|
|
850
|
+
id = fid;
|
|
851
|
+
}
|
|
852
|
+
if (typeof id !== 'number')
|
|
853
|
+
continue;
|
|
854
|
+
var label = (_a = this.get(prefix + key)) !== null && _a !== void 0 ? _a : key;
|
|
855
|
+
list.push({ id, label });
|
|
856
|
+
}
|
|
857
|
+
return list;
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Get enum item string id list
|
|
861
|
+
* @param em Enum
|
|
862
|
+
* @param prefix Label prefix
|
|
863
|
+
* @param filter Filter
|
|
864
|
+
* @returns List
|
|
865
|
+
*/
|
|
866
|
+
getEnumStrList(em, prefix, filter) {
|
|
867
|
+
var _a;
|
|
868
|
+
const list = [];
|
|
869
|
+
const keys = shared_1.DataTypes.getEnumKeys(em);
|
|
870
|
+
for (const key of keys) {
|
|
871
|
+
let id = em[key];
|
|
872
|
+
if (filter) {
|
|
873
|
+
const fid = filter(id, key);
|
|
874
|
+
if (fid == null)
|
|
875
|
+
continue;
|
|
876
|
+
id = fid;
|
|
877
|
+
}
|
|
878
|
+
var label = (_a = this.get(prefix + key)) !== null && _a !== void 0 ? _a : key;
|
|
879
|
+
list.push({ id: id.toString(), label });
|
|
880
|
+
}
|
|
881
|
+
return list;
|
|
882
|
+
}
|
|
832
883
|
/**
|
|
833
884
|
* Get all regions
|
|
834
885
|
* @returns Regions
|
|
@@ -843,28 +894,28 @@ class CoreApp {
|
|
|
843
894
|
* @param role Combination role value
|
|
844
895
|
*/
|
|
845
896
|
getRoles(role) {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
var id = UserRole_1.UserRole[key];
|
|
851
|
-
if ((id & role) > 0) {
|
|
852
|
-
roles.push({
|
|
853
|
-
id,
|
|
854
|
-
label: (_a = this.get(`role${key}`)) !== null && _a !== void 0 ? _a : key
|
|
855
|
-
});
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
return roles;
|
|
897
|
+
return this.getEnumList(UserRole_1.UserRole, 'role', (id, _key) => {
|
|
898
|
+
if ((id & role) > 0)
|
|
899
|
+
return id;
|
|
900
|
+
});
|
|
859
901
|
}
|
|
860
902
|
/**
|
|
861
|
-
* Get
|
|
903
|
+
* Get status list
|
|
904
|
+
* @returns list
|
|
905
|
+
*/
|
|
906
|
+
getStatusList() {
|
|
907
|
+
return this.getEnumList(EntityStatus_1.EntityStatus, 'status');
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Get status label
|
|
862
911
|
* @param status Status value
|
|
863
912
|
*/
|
|
864
|
-
|
|
913
|
+
getStatusLabel(status) {
|
|
914
|
+
var _a;
|
|
865
915
|
if (status == null)
|
|
866
916
|
return '';
|
|
867
|
-
|
|
917
|
+
const key = EntityStatus_1.EntityStatus[status];
|
|
918
|
+
return (_a = this.get('status' + key)) !== null && _a !== void 0 ? _a : key;
|
|
868
919
|
}
|
|
869
920
|
/**
|
|
870
921
|
* Get refresh token from response headers
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DataTypes } from '@etsoo/shared';
|
|
2
2
|
import { IdLabelDto } from '../dto/IdLabelDto';
|
|
3
3
|
import { ICultureGet } from '../state/Culture';
|
|
4
|
-
import { EntityStatus } from './EntityStatus';
|
|
5
4
|
import { ProductUnit } from './ProductUnit';
|
|
6
5
|
/**
|
|
7
6
|
* Business utils
|
|
@@ -14,24 +13,6 @@ export declare namespace BusinessUtils {
|
|
|
14
13
|
* @returns Collection
|
|
15
14
|
*/
|
|
16
15
|
function getCurrencies(currencyNames: string[], func: ICultureGet): IdLabelDto<string>[];
|
|
17
|
-
/**
|
|
18
|
-
* Get entity status's label
|
|
19
|
-
* Please define the label with key 'statusNormal' for Normal status
|
|
20
|
-
* @param unit Unit
|
|
21
|
-
* @param func Label delegate
|
|
22
|
-
* @returns Label
|
|
23
|
-
*/
|
|
24
|
-
function getEntityStatusLabel(status: EntityStatus, func: ICultureGet): string;
|
|
25
|
-
/**
|
|
26
|
-
* Get entity status collection
|
|
27
|
-
* @param unit Unit
|
|
28
|
-
* @param func Label delegate
|
|
29
|
-
* @returns Label
|
|
30
|
-
*/
|
|
31
|
-
function getEntityStatus(func: ICultureGet): {
|
|
32
|
-
id: EntityStatus;
|
|
33
|
-
label: string;
|
|
34
|
-
}[];
|
|
35
16
|
/**
|
|
36
17
|
* Get 12-month items
|
|
37
18
|
* @param monthLabels Month labels
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BusinessUtils = void 0;
|
|
4
4
|
const shared_1 = require("@etsoo/shared");
|
|
5
5
|
const __1 = require("..");
|
|
6
|
-
const EntityStatus_1 = require("./EntityStatus");
|
|
7
6
|
const ProductUnit_1 = require("./ProductUnit");
|
|
8
7
|
/**
|
|
9
8
|
* Business utils
|
|
@@ -26,35 +25,6 @@ var BusinessUtils;
|
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
27
|
BusinessUtils.getCurrencies = getCurrencies;
|
|
29
|
-
/**
|
|
30
|
-
* Get entity status's label
|
|
31
|
-
* Please define the label with key 'statusNormal' for Normal status
|
|
32
|
-
* @param unit Unit
|
|
33
|
-
* @param func Label delegate
|
|
34
|
-
* @returns Label
|
|
35
|
-
*/
|
|
36
|
-
function getEntityStatusLabel(status, func) {
|
|
37
|
-
var _a;
|
|
38
|
-
const key = EntityStatus_1.EntityStatus[status];
|
|
39
|
-
return (_a = func('status' + key)) !== null && _a !== void 0 ? _a : key;
|
|
40
|
-
}
|
|
41
|
-
BusinessUtils.getEntityStatusLabel = getEntityStatusLabel;
|
|
42
|
-
/**
|
|
43
|
-
* Get entity status collection
|
|
44
|
-
* @param unit Unit
|
|
45
|
-
* @param func Label delegate
|
|
46
|
-
* @returns Label
|
|
47
|
-
*/
|
|
48
|
-
function getEntityStatus(func) {
|
|
49
|
-
return shared_1.DataTypes.getEnumKeys(EntityStatus_1.EntityStatus).map((key) => {
|
|
50
|
-
const id = shared_1.DataTypes.getEnumByKey(EntityStatus_1.EntityStatus, key);
|
|
51
|
-
return {
|
|
52
|
-
id,
|
|
53
|
-
label: getEntityStatusLabel(id, func)
|
|
54
|
-
};
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
BusinessUtils.getEntityStatus = getEntityStatus;
|
|
58
28
|
/**
|
|
59
29
|
* Get 12-month items
|
|
60
30
|
* @param monthLabels Month labels
|
package/lib/cjs/i18n/en-US.json
CHANGED
package/lib/cjs/i18n/zh-CN.json
CHANGED
package/lib/cjs/i18n/zh-HK.json
CHANGED
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -260,11 +260,6 @@ export interface ICoreApp<U extends IUser, S extends IAppSettings, N, C extends
|
|
|
260
260
|
* @returns Cached token
|
|
261
261
|
*/
|
|
262
262
|
getCacheToken(): string | undefined;
|
|
263
|
-
/**
|
|
264
|
-
* Get entity status label
|
|
265
|
-
* @param status Status value
|
|
266
|
-
*/
|
|
267
|
-
getEntityStatusLabel(status: number | null | undefined): string;
|
|
268
263
|
/**
|
|
269
264
|
* Get all regions
|
|
270
265
|
* @returns Regions
|
|
@@ -275,6 +270,16 @@ export interface ICoreApp<U extends IUser, S extends IAppSettings, N, C extends
|
|
|
275
270
|
* @param role Combination role value
|
|
276
271
|
*/
|
|
277
272
|
getRoles(role: number): IdLabelDto[];
|
|
273
|
+
/**
|
|
274
|
+
* Get status label
|
|
275
|
+
* @param status Status value
|
|
276
|
+
*/
|
|
277
|
+
getStatusLabel(status: number | null | undefined): string;
|
|
278
|
+
/**
|
|
279
|
+
* Get status list
|
|
280
|
+
* @returns list
|
|
281
|
+
*/
|
|
282
|
+
getStatusList(): IdLabelDto[];
|
|
278
283
|
/**
|
|
279
284
|
* Get refresh token from response headers
|
|
280
285
|
* @param rawResponse Raw response from API call
|
|
@@ -705,6 +710,22 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
705
710
|
* @returns Cached token
|
|
706
711
|
*/
|
|
707
712
|
getCacheToken(): string | undefined;
|
|
713
|
+
/**
|
|
714
|
+
* Get enum item number id list
|
|
715
|
+
* @param em Enum
|
|
716
|
+
* @param prefix Label prefix
|
|
717
|
+
* @param filter Filter
|
|
718
|
+
* @returns List
|
|
719
|
+
*/
|
|
720
|
+
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): IdLabelDto[];
|
|
721
|
+
/**
|
|
722
|
+
* Get enum item string id list
|
|
723
|
+
* @param em Enum
|
|
724
|
+
* @param prefix Label prefix
|
|
725
|
+
* @param filter Filter
|
|
726
|
+
* @returns List
|
|
727
|
+
*/
|
|
728
|
+
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): IdLabelDto<string>[];
|
|
708
729
|
/**
|
|
709
730
|
* Get all regions
|
|
710
731
|
* @returns Regions
|
|
@@ -716,10 +737,15 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
716
737
|
*/
|
|
717
738
|
getRoles(role: number): IdLabelDto<number>[];
|
|
718
739
|
/**
|
|
719
|
-
* Get
|
|
740
|
+
* Get status list
|
|
741
|
+
* @returns list
|
|
742
|
+
*/
|
|
743
|
+
getStatusList(): IdLabelDto<number>[];
|
|
744
|
+
/**
|
|
745
|
+
* Get status label
|
|
720
746
|
* @param status Status value
|
|
721
747
|
*/
|
|
722
|
-
|
|
748
|
+
getStatusLabel(status: number | null | undefined): string;
|
|
723
749
|
/**
|
|
724
750
|
* Get refresh token from response headers
|
|
725
751
|
* @param rawResponse Raw response from API call
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -6,6 +6,7 @@ import { AddressRegion } from '../address/AddressRegion';
|
|
|
6
6
|
import { AddressUtils } from '../address/AddressUtils';
|
|
7
7
|
import { BridgeUtils } from '../bridges/BridgeUtils';
|
|
8
8
|
import { BusinessUtils } from '../business/BusinessUtils';
|
|
9
|
+
import { EntityStatus } from '../business/EntityStatus';
|
|
9
10
|
import { ActionResultError } from '../result/ActionResultError';
|
|
10
11
|
import { UserRole } from './UserRole';
|
|
11
12
|
/**
|
|
@@ -826,6 +827,56 @@ export class CoreApp {
|
|
|
826
827
|
return this.cachedRefreshToken;
|
|
827
828
|
return this.storage.getData(this.fields.headerToken);
|
|
828
829
|
}
|
|
830
|
+
/**
|
|
831
|
+
* Get enum item number id list
|
|
832
|
+
* @param em Enum
|
|
833
|
+
* @param prefix Label prefix
|
|
834
|
+
* @param filter Filter
|
|
835
|
+
* @returns List
|
|
836
|
+
*/
|
|
837
|
+
getEnumList(em, prefix, filter) {
|
|
838
|
+
var _a;
|
|
839
|
+
const list = [];
|
|
840
|
+
const keys = DataTypes.getEnumKeys(em);
|
|
841
|
+
for (const key of keys) {
|
|
842
|
+
let id = em[key];
|
|
843
|
+
if (filter) {
|
|
844
|
+
const fid = filter(id, key);
|
|
845
|
+
if (fid == null)
|
|
846
|
+
continue;
|
|
847
|
+
id = fid;
|
|
848
|
+
}
|
|
849
|
+
if (typeof id !== 'number')
|
|
850
|
+
continue;
|
|
851
|
+
var label = (_a = this.get(prefix + key)) !== null && _a !== void 0 ? _a : key;
|
|
852
|
+
list.push({ id, label });
|
|
853
|
+
}
|
|
854
|
+
return list;
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* Get enum item string id list
|
|
858
|
+
* @param em Enum
|
|
859
|
+
* @param prefix Label prefix
|
|
860
|
+
* @param filter Filter
|
|
861
|
+
* @returns List
|
|
862
|
+
*/
|
|
863
|
+
getEnumStrList(em, prefix, filter) {
|
|
864
|
+
var _a;
|
|
865
|
+
const list = [];
|
|
866
|
+
const keys = DataTypes.getEnumKeys(em);
|
|
867
|
+
for (const key of keys) {
|
|
868
|
+
let id = em[key];
|
|
869
|
+
if (filter) {
|
|
870
|
+
const fid = filter(id, key);
|
|
871
|
+
if (fid == null)
|
|
872
|
+
continue;
|
|
873
|
+
id = fid;
|
|
874
|
+
}
|
|
875
|
+
var label = (_a = this.get(prefix + key)) !== null && _a !== void 0 ? _a : key;
|
|
876
|
+
list.push({ id: id.toString(), label });
|
|
877
|
+
}
|
|
878
|
+
return list;
|
|
879
|
+
}
|
|
829
880
|
/**
|
|
830
881
|
* Get all regions
|
|
831
882
|
* @returns Regions
|
|
@@ -840,28 +891,28 @@ export class CoreApp {
|
|
|
840
891
|
* @param role Combination role value
|
|
841
892
|
*/
|
|
842
893
|
getRoles(role) {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
var id = UserRole[key];
|
|
848
|
-
if ((id & role) > 0) {
|
|
849
|
-
roles.push({
|
|
850
|
-
id,
|
|
851
|
-
label: (_a = this.get(`role${key}`)) !== null && _a !== void 0 ? _a : key
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
return roles;
|
|
894
|
+
return this.getEnumList(UserRole, 'role', (id, _key) => {
|
|
895
|
+
if ((id & role) > 0)
|
|
896
|
+
return id;
|
|
897
|
+
});
|
|
856
898
|
}
|
|
857
899
|
/**
|
|
858
|
-
* Get
|
|
900
|
+
* Get status list
|
|
901
|
+
* @returns list
|
|
902
|
+
*/
|
|
903
|
+
getStatusList() {
|
|
904
|
+
return this.getEnumList(EntityStatus, 'status');
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Get status label
|
|
859
908
|
* @param status Status value
|
|
860
909
|
*/
|
|
861
|
-
|
|
910
|
+
getStatusLabel(status) {
|
|
911
|
+
var _a;
|
|
862
912
|
if (status == null)
|
|
863
913
|
return '';
|
|
864
|
-
|
|
914
|
+
const key = EntityStatus[status];
|
|
915
|
+
return (_a = this.get('status' + key)) !== null && _a !== void 0 ? _a : key;
|
|
865
916
|
}
|
|
866
917
|
/**
|
|
867
918
|
* Get refresh token from response headers
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DataTypes } from '@etsoo/shared';
|
|
2
2
|
import { IdLabelDto } from '../dto/IdLabelDto';
|
|
3
3
|
import { ICultureGet } from '../state/Culture';
|
|
4
|
-
import { EntityStatus } from './EntityStatus';
|
|
5
4
|
import { ProductUnit } from './ProductUnit';
|
|
6
5
|
/**
|
|
7
6
|
* Business utils
|
|
@@ -14,24 +13,6 @@ export declare namespace BusinessUtils {
|
|
|
14
13
|
* @returns Collection
|
|
15
14
|
*/
|
|
16
15
|
function getCurrencies(currencyNames: string[], func: ICultureGet): IdLabelDto<string>[];
|
|
17
|
-
/**
|
|
18
|
-
* Get entity status's label
|
|
19
|
-
* Please define the label with key 'statusNormal' for Normal status
|
|
20
|
-
* @param unit Unit
|
|
21
|
-
* @param func Label delegate
|
|
22
|
-
* @returns Label
|
|
23
|
-
*/
|
|
24
|
-
function getEntityStatusLabel(status: EntityStatus, func: ICultureGet): string;
|
|
25
|
-
/**
|
|
26
|
-
* Get entity status collection
|
|
27
|
-
* @param unit Unit
|
|
28
|
-
* @param func Label delegate
|
|
29
|
-
* @returns Label
|
|
30
|
-
*/
|
|
31
|
-
function getEntityStatus(func: ICultureGet): {
|
|
32
|
-
id: EntityStatus;
|
|
33
|
-
label: string;
|
|
34
|
-
}[];
|
|
35
16
|
/**
|
|
36
17
|
* Get 12-month items
|
|
37
18
|
* @param monthLabels Month labels
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DataTypes } from '@etsoo/shared';
|
|
2
2
|
import { RepeatOption } from '..';
|
|
3
|
-
import { EntityStatus } from './EntityStatus';
|
|
4
3
|
import { ProductUnit } from './ProductUnit';
|
|
5
4
|
/**
|
|
6
5
|
* Business utils
|
|
@@ -23,35 +22,6 @@ export var BusinessUtils;
|
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
24
|
BusinessUtils.getCurrencies = getCurrencies;
|
|
26
|
-
/**
|
|
27
|
-
* Get entity status's label
|
|
28
|
-
* Please define the label with key 'statusNormal' for Normal status
|
|
29
|
-
* @param unit Unit
|
|
30
|
-
* @param func Label delegate
|
|
31
|
-
* @returns Label
|
|
32
|
-
*/
|
|
33
|
-
function getEntityStatusLabel(status, func) {
|
|
34
|
-
var _a;
|
|
35
|
-
const key = EntityStatus[status];
|
|
36
|
-
return (_a = func('status' + key)) !== null && _a !== void 0 ? _a : key;
|
|
37
|
-
}
|
|
38
|
-
BusinessUtils.getEntityStatusLabel = getEntityStatusLabel;
|
|
39
|
-
/**
|
|
40
|
-
* Get entity status collection
|
|
41
|
-
* @param unit Unit
|
|
42
|
-
* @param func Label delegate
|
|
43
|
-
* @returns Label
|
|
44
|
-
*/
|
|
45
|
-
function getEntityStatus(func) {
|
|
46
|
-
return DataTypes.getEnumKeys(EntityStatus).map((key) => {
|
|
47
|
-
const id = DataTypes.getEnumByKey(EntityStatus, key);
|
|
48
|
-
return {
|
|
49
|
-
id,
|
|
50
|
-
label: getEntityStatusLabel(id, func)
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
BusinessUtils.getEntityStatus = getEntityStatus;
|
|
55
25
|
/**
|
|
56
26
|
* Get 12-month items
|
|
57
27
|
* @param monthLabels Month labels
|
package/lib/mjs/i18n/en-US.json
CHANGED
package/lib/mjs/i18n/zh-CN.json
CHANGED
package/lib/mjs/i18n/zh-HK.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.75",
|
|
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.5",
|
|
56
56
|
"@etsoo/restclient": "^1.0.70",
|
|
57
|
-
"@etsoo/shared": "^1.1.
|
|
57
|
+
"@etsoo/shared": "^1.1.44",
|
|
58
58
|
"@types/crypto-js": "^4.1.1",
|
|
59
59
|
"crypto-js": "^4.1.1"
|
|
60
60
|
},
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@types/jest": "^28.1.6",
|
|
68
68
|
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
|
69
69
|
"@typescript-eslint/parser": "^5.33.0",
|
|
70
|
-
"eslint": "^8.
|
|
70
|
+
"eslint": "^8.22.0",
|
|
71
71
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
72
72
|
"eslint-plugin-import": "^2.26.0",
|
|
73
73
|
"jest": "^28.1.3",
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -31,6 +31,7 @@ import { AddressRegion } from '../address/AddressRegion';
|
|
|
31
31
|
import { AddressUtils } from '../address/AddressUtils';
|
|
32
32
|
import { BridgeUtils } from '../bridges/BridgeUtils';
|
|
33
33
|
import { BusinessUtils } from '../business/BusinessUtils';
|
|
34
|
+
import { EntityStatus } from '../business/EntityStatus';
|
|
34
35
|
import { ProductUnit } from '../business/ProductUnit';
|
|
35
36
|
import { IdLabelDto } from '../dto/IdLabelDto';
|
|
36
37
|
import { InitCallDto } from '../dto/InitCallDto';
|
|
@@ -374,12 +375,6 @@ export interface ICoreApp<
|
|
|
374
375
|
*/
|
|
375
376
|
getCacheToken(): string | undefined;
|
|
376
377
|
|
|
377
|
-
/**
|
|
378
|
-
* Get entity status label
|
|
379
|
-
* @param status Status value
|
|
380
|
-
*/
|
|
381
|
-
getEntityStatusLabel(status: number | null | undefined): string;
|
|
382
|
-
|
|
383
378
|
/**
|
|
384
379
|
* Get all regions
|
|
385
380
|
* @returns Regions
|
|
@@ -392,6 +387,18 @@ export interface ICoreApp<
|
|
|
392
387
|
*/
|
|
393
388
|
getRoles(role: number): IdLabelDto[];
|
|
394
389
|
|
|
390
|
+
/**
|
|
391
|
+
* Get status label
|
|
392
|
+
* @param status Status value
|
|
393
|
+
*/
|
|
394
|
+
getStatusLabel(status: number | null | undefined): string;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Get status list
|
|
398
|
+
* @returns list
|
|
399
|
+
*/
|
|
400
|
+
getStatusList(): IdLabelDto[];
|
|
401
|
+
|
|
395
402
|
/**
|
|
396
403
|
* Get refresh token from response headers
|
|
397
404
|
* @param rawResponse Raw response from API call
|
|
@@ -1598,6 +1605,67 @@ export abstract class CoreApp<
|
|
|
1598
1605
|
return this.storage.getData<string>(this.fields.headerToken);
|
|
1599
1606
|
}
|
|
1600
1607
|
|
|
1608
|
+
/**
|
|
1609
|
+
* Get enum item number id list
|
|
1610
|
+
* @param em Enum
|
|
1611
|
+
* @param prefix Label prefix
|
|
1612
|
+
* @param filter Filter
|
|
1613
|
+
* @returns List
|
|
1614
|
+
*/
|
|
1615
|
+
protected getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(
|
|
1616
|
+
em: E,
|
|
1617
|
+
prefix: string,
|
|
1618
|
+
filter?: (
|
|
1619
|
+
id: E[keyof E],
|
|
1620
|
+
key: keyof E & string
|
|
1621
|
+
) => E[keyof E] | undefined
|
|
1622
|
+
): IdLabelDto[] {
|
|
1623
|
+
const list: IdLabelDto<number>[] = [];
|
|
1624
|
+
const keys = DataTypes.getEnumKeys(em);
|
|
1625
|
+
for (const key of keys) {
|
|
1626
|
+
let id = em[key as keyof E];
|
|
1627
|
+
if (filter) {
|
|
1628
|
+
const fid = filter(id, key);
|
|
1629
|
+
if (fid == null) continue;
|
|
1630
|
+
id = fid;
|
|
1631
|
+
}
|
|
1632
|
+
if (typeof id !== 'number') continue;
|
|
1633
|
+
var label = this.get<string>(prefix + key) ?? key;
|
|
1634
|
+
list.push({ id, label });
|
|
1635
|
+
}
|
|
1636
|
+
return list;
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
/**
|
|
1640
|
+
* Get enum item string id list
|
|
1641
|
+
* @param em Enum
|
|
1642
|
+
* @param prefix Label prefix
|
|
1643
|
+
* @param filter Filter
|
|
1644
|
+
* @returns List
|
|
1645
|
+
*/
|
|
1646
|
+
protected getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(
|
|
1647
|
+
em: E,
|
|
1648
|
+
prefix: string,
|
|
1649
|
+
filter?: (
|
|
1650
|
+
id: E[keyof E],
|
|
1651
|
+
key: keyof E & string
|
|
1652
|
+
) => E[keyof E] | undefined
|
|
1653
|
+
): IdLabelDto<string>[] {
|
|
1654
|
+
const list: IdLabelDto<string>[] = [];
|
|
1655
|
+
const keys = DataTypes.getEnumKeys(em);
|
|
1656
|
+
for (const key of keys) {
|
|
1657
|
+
let id = em[key as keyof E];
|
|
1658
|
+
if (filter) {
|
|
1659
|
+
const fid = filter(id, key);
|
|
1660
|
+
if (fid == null) continue;
|
|
1661
|
+
id = fid;
|
|
1662
|
+
}
|
|
1663
|
+
var label = this.get<string>(prefix + key) ?? key;
|
|
1664
|
+
list.push({ id: id.toString(), label });
|
|
1665
|
+
}
|
|
1666
|
+
return list;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1601
1669
|
/**
|
|
1602
1670
|
* Get all regions
|
|
1603
1671
|
* @returns Regions
|
|
@@ -1613,29 +1681,27 @@ export abstract class CoreApp<
|
|
|
1613
1681
|
* @param role Combination role value
|
|
1614
1682
|
*/
|
|
1615
1683
|
getRoles(role: number) {
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
var id = UserRole[key as keyof typeof UserRole];
|
|
1621
|
-
if ((id & role) > 0) {
|
|
1622
|
-
roles.push({
|
|
1623
|
-
id,
|
|
1624
|
-
label: this.get<string>(`role${key}`) ?? key
|
|
1625
|
-
});
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1684
|
+
return this.getEnumList(UserRole, 'role', (id, _key) => {
|
|
1685
|
+
if ((id & role) > 0) return id;
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1628
1688
|
|
|
1629
|
-
|
|
1689
|
+
/**
|
|
1690
|
+
* Get status list
|
|
1691
|
+
* @returns list
|
|
1692
|
+
*/
|
|
1693
|
+
getStatusList() {
|
|
1694
|
+
return this.getEnumList(EntityStatus, 'status');
|
|
1630
1695
|
}
|
|
1631
1696
|
|
|
1632
1697
|
/**
|
|
1633
|
-
* Get
|
|
1698
|
+
* Get status label
|
|
1634
1699
|
* @param status Status value
|
|
1635
1700
|
*/
|
|
1636
|
-
|
|
1701
|
+
getStatusLabel(status: number | null | undefined) {
|
|
1637
1702
|
if (status == null) return '';
|
|
1638
|
-
|
|
1703
|
+
const key = EntityStatus[status];
|
|
1704
|
+
return this.get<string>('status' + key) ?? key;
|
|
1639
1705
|
}
|
|
1640
1706
|
|
|
1641
1707
|
/**
|
|
@@ -2,7 +2,6 @@ import { DataTypes } from '@etsoo/shared';
|
|
|
2
2
|
import { RepeatOption } from '..';
|
|
3
3
|
import { IdLabelDto } from '../dto/IdLabelDto';
|
|
4
4
|
import { ICultureGet } from '../state/Culture';
|
|
5
|
-
import { EntityStatus } from './EntityStatus';
|
|
6
5
|
import { ProductUnit } from './ProductUnit';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -25,37 +24,6 @@ export namespace BusinessUtils {
|
|
|
25
24
|
}));
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
/**
|
|
29
|
-
* Get entity status's label
|
|
30
|
-
* Please define the label with key 'statusNormal' for Normal status
|
|
31
|
-
* @param unit Unit
|
|
32
|
-
* @param func Label delegate
|
|
33
|
-
* @returns Label
|
|
34
|
-
*/
|
|
35
|
-
export function getEntityStatusLabel(
|
|
36
|
-
status: EntityStatus,
|
|
37
|
-
func: ICultureGet
|
|
38
|
-
) {
|
|
39
|
-
const key = EntityStatus[status];
|
|
40
|
-
return func('status' + key) ?? key;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Get entity status collection
|
|
45
|
-
* @param unit Unit
|
|
46
|
-
* @param func Label delegate
|
|
47
|
-
* @returns Label
|
|
48
|
-
*/
|
|
49
|
-
export function getEntityStatus(func: ICultureGet) {
|
|
50
|
-
return DataTypes.getEnumKeys(EntityStatus).map((key) => {
|
|
51
|
-
const id = DataTypes.getEnumByKey(EntityStatus, key)!;
|
|
52
|
-
return {
|
|
53
|
-
id,
|
|
54
|
-
label: getEntityStatusLabel(id, func)
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
27
|
/**
|
|
60
28
|
* Get 12-month items
|
|
61
29
|
* @param monthLabels Month labels
|
package/src/i18n/en-US.json
CHANGED
package/src/i18n/zh-CN.json
CHANGED