@etsoo/appscript 1.3.91 → 1.3.92
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 +1 -1
- package/lib/cjs/app/CoreApp.d.ts +1 -1
- package/lib/cjs/app/CoreApp.js +25 -15
- package/lib/cjs/app/IApp.d.ts +1 -1
- package/lib/mjs/app/CoreApp.d.ts +1 -1
- package/lib/mjs/app/CoreApp.js +25 -15
- package/lib/mjs/app/IApp.d.ts +1 -1
- package/package.json +2 -2
- package/src/app/CoreApp.ts +28 -22
- package/src/app/IApp.ts +6 -4
package/__tests__/app/CoreApp.ts
CHANGED
|
@@ -215,7 +215,7 @@ test('Tests for getStatusList', () => {
|
|
|
215
215
|
EntityStatus.Deleted
|
|
216
216
|
]);
|
|
217
217
|
expect(statuses.length).toBe(5);
|
|
218
|
-
expect(statuses.
|
|
218
|
+
expect(statuses.map((s) => s.id)).toStrictEqual([0, 100, 110, 250, 255]);
|
|
219
219
|
|
|
220
220
|
expect(app.getStatusList().length).toBe(9);
|
|
221
221
|
});
|
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -376,7 +376,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
376
376
|
* @param filter Filter
|
|
377
377
|
* @returns List
|
|
378
378
|
*/
|
|
379
|
-
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[];
|
|
379
|
+
getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: ((id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined) | E[keyof E][]): ListType[];
|
|
380
380
|
/**
|
|
381
381
|
* Get enum item string id list
|
|
382
382
|
* @param em Enum
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -908,19 +908,31 @@ class CoreApp {
|
|
|
908
908
|
getEnumList(em, prefix, filter) {
|
|
909
909
|
var _a;
|
|
910
910
|
const list = [];
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
911
|
+
if (Array.isArray(filter)) {
|
|
912
|
+
filter.forEach((id) => {
|
|
913
|
+
var _a;
|
|
914
|
+
if (typeof id !== 'number')
|
|
915
|
+
return;
|
|
916
|
+
const key = shared_1.DataTypes.getEnumKey(em, id);
|
|
917
|
+
var label = (_a = this.get(prefix + key)) !== null && _a !== void 0 ? _a : key;
|
|
918
|
+
list.push({ id, label });
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
else {
|
|
922
|
+
const keys = shared_1.DataTypes.getEnumKeys(em);
|
|
923
|
+
for (const key of keys) {
|
|
924
|
+
let id = em[key];
|
|
925
|
+
if (filter) {
|
|
926
|
+
const fid = filter(id, key);
|
|
927
|
+
if (fid == null)
|
|
928
|
+
continue;
|
|
929
|
+
id = fid;
|
|
930
|
+
}
|
|
931
|
+
if (typeof id !== 'number')
|
|
917
932
|
continue;
|
|
918
|
-
|
|
933
|
+
var label = (_a = this.get(prefix + key)) !== null && _a !== void 0 ? _a : key;
|
|
934
|
+
list.push({ id, label });
|
|
919
935
|
}
|
|
920
|
-
if (typeof id !== 'number')
|
|
921
|
-
continue;
|
|
922
|
-
var label = (_a = this.get(prefix + key)) !== null && _a !== void 0 ? _a : key;
|
|
923
|
-
list.push({ id, label });
|
|
924
936
|
}
|
|
925
937
|
return list;
|
|
926
938
|
}
|
|
@@ -981,10 +993,8 @@ class CoreApp {
|
|
|
981
993
|
* @param ids Limited ids
|
|
982
994
|
* @returns list
|
|
983
995
|
*/
|
|
984
|
-
getStatusList(ids
|
|
985
|
-
return this.getEnumList(EntityStatus_1.EntityStatus, 'status', ids
|
|
986
|
-
? (id, _key) => (ids.includes(id) ? id : undefined)
|
|
987
|
-
: undefined);
|
|
996
|
+
getStatusList(ids) {
|
|
997
|
+
return this.getEnumList(EntityStatus_1.EntityStatus, 'status', ids);
|
|
988
998
|
}
|
|
989
999
|
/**
|
|
990
1000
|
* Get status label
|
package/lib/cjs/app/IApp.d.ts
CHANGED
|
@@ -320,7 +320,7 @@ export interface IApp {
|
|
|
320
320
|
* @param filter Filter
|
|
321
321
|
* @returns List
|
|
322
322
|
*/
|
|
323
|
-
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[];
|
|
323
|
+
getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: ((id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined) | E[keyof E][]): ListType1[];
|
|
324
324
|
/**
|
|
325
325
|
* Get region label
|
|
326
326
|
* @param id Region id
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -376,7 +376,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
376
376
|
* @param filter Filter
|
|
377
377
|
* @returns List
|
|
378
378
|
*/
|
|
379
|
-
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[];
|
|
379
|
+
getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: ((id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined) | E[keyof E][]): ListType[];
|
|
380
380
|
/**
|
|
381
381
|
* Get enum item string id list
|
|
382
382
|
* @param em Enum
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -905,19 +905,31 @@ export class CoreApp {
|
|
|
905
905
|
getEnumList(em, prefix, filter) {
|
|
906
906
|
var _a;
|
|
907
907
|
const list = [];
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
908
|
+
if (Array.isArray(filter)) {
|
|
909
|
+
filter.forEach((id) => {
|
|
910
|
+
var _a;
|
|
911
|
+
if (typeof id !== 'number')
|
|
912
|
+
return;
|
|
913
|
+
const key = DataTypes.getEnumKey(em, id);
|
|
914
|
+
var label = (_a = this.get(prefix + key)) !== null && _a !== void 0 ? _a : key;
|
|
915
|
+
list.push({ id, label });
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
else {
|
|
919
|
+
const keys = DataTypes.getEnumKeys(em);
|
|
920
|
+
for (const key of keys) {
|
|
921
|
+
let id = em[key];
|
|
922
|
+
if (filter) {
|
|
923
|
+
const fid = filter(id, key);
|
|
924
|
+
if (fid == null)
|
|
925
|
+
continue;
|
|
926
|
+
id = fid;
|
|
927
|
+
}
|
|
928
|
+
if (typeof id !== 'number')
|
|
914
929
|
continue;
|
|
915
|
-
|
|
930
|
+
var label = (_a = this.get(prefix + key)) !== null && _a !== void 0 ? _a : key;
|
|
931
|
+
list.push({ id, label });
|
|
916
932
|
}
|
|
917
|
-
if (typeof id !== 'number')
|
|
918
|
-
continue;
|
|
919
|
-
var label = (_a = this.get(prefix + key)) !== null && _a !== void 0 ? _a : key;
|
|
920
|
-
list.push({ id, label });
|
|
921
933
|
}
|
|
922
934
|
return list;
|
|
923
935
|
}
|
|
@@ -978,10 +990,8 @@ export class CoreApp {
|
|
|
978
990
|
* @param ids Limited ids
|
|
979
991
|
* @returns list
|
|
980
992
|
*/
|
|
981
|
-
getStatusList(ids
|
|
982
|
-
return this.getEnumList(EntityStatus, 'status', ids
|
|
983
|
-
? (id, _key) => (ids.includes(id) ? id : undefined)
|
|
984
|
-
: undefined);
|
|
993
|
+
getStatusList(ids) {
|
|
994
|
+
return this.getEnumList(EntityStatus, 'status', ids);
|
|
985
995
|
}
|
|
986
996
|
/**
|
|
987
997
|
* Get status label
|
package/lib/mjs/app/IApp.d.ts
CHANGED
|
@@ -320,7 +320,7 @@ export interface IApp {
|
|
|
320
320
|
* @param filter Filter
|
|
321
321
|
* @returns List
|
|
322
322
|
*/
|
|
323
|
-
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[];
|
|
323
|
+
getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(em: E, prefix: string, filter?: ((id: E[keyof E], key: keyof E & string) => E[keyof E] | undefined) | E[keyof E][]): ListType1[];
|
|
324
324
|
/**
|
|
325
325
|
* Get region label
|
|
326
326
|
* @param id Region id
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.92",
|
|
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.24",
|
|
56
56
|
"@etsoo/restclient": "^1.0.87",
|
|
57
|
-
"@etsoo/shared": "^1.2.
|
|
57
|
+
"@etsoo/shared": "^1.2.1",
|
|
58
58
|
"@types/crypto-js": "^4.1.1",
|
|
59
59
|
"crypto-js": "^4.1.1"
|
|
60
60
|
},
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -1237,23 +1237,35 @@ export abstract class CoreApp<
|
|
|
1237
1237
|
getEnumList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(
|
|
1238
1238
|
em: E,
|
|
1239
1239
|
prefix: string,
|
|
1240
|
-
filter?:
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1240
|
+
filter?:
|
|
1241
|
+
| ((
|
|
1242
|
+
id: E[keyof E],
|
|
1243
|
+
key: keyof E & string
|
|
1244
|
+
) => E[keyof E] | undefined)
|
|
1245
|
+
| E[keyof E][]
|
|
1244
1246
|
): ListType[] {
|
|
1245
1247
|
const list: ListType[] = [];
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
const
|
|
1251
|
-
|
|
1252
|
-
id
|
|
1248
|
+
|
|
1249
|
+
if (Array.isArray(filter)) {
|
|
1250
|
+
filter.forEach((id) => {
|
|
1251
|
+
if (typeof id !== 'number') return;
|
|
1252
|
+
const key = DataTypes.getEnumKey(em, id);
|
|
1253
|
+
var label = this.get<string>(prefix + key) ?? key;
|
|
1254
|
+
list.push({ id, label });
|
|
1255
|
+
});
|
|
1256
|
+
} else {
|
|
1257
|
+
const keys = DataTypes.getEnumKeys(em);
|
|
1258
|
+
for (const key of keys) {
|
|
1259
|
+
let id = em[key as keyof E];
|
|
1260
|
+
if (filter) {
|
|
1261
|
+
const fid = filter(id, key);
|
|
1262
|
+
if (fid == null) continue;
|
|
1263
|
+
id = fid;
|
|
1264
|
+
}
|
|
1265
|
+
if (typeof id !== 'number') continue;
|
|
1266
|
+
var label = this.get<string>(prefix + key) ?? key;
|
|
1267
|
+
list.push({ id, label });
|
|
1253
1268
|
}
|
|
1254
|
-
if (typeof id !== 'number') continue;
|
|
1255
|
-
var label = this.get<string>(prefix + key) ?? key;
|
|
1256
|
-
list.push({ id, label });
|
|
1257
1269
|
}
|
|
1258
1270
|
return list;
|
|
1259
1271
|
}
|
|
@@ -1322,14 +1334,8 @@ export abstract class CoreApp<
|
|
|
1322
1334
|
* @param ids Limited ids
|
|
1323
1335
|
* @returns list
|
|
1324
1336
|
*/
|
|
1325
|
-
getStatusList(ids
|
|
1326
|
-
return this.getEnumList(
|
|
1327
|
-
EntityStatus,
|
|
1328
|
-
'status',
|
|
1329
|
-
ids.length > 0
|
|
1330
|
-
? (id, _key) => (ids.includes(id) ? id : undefined)
|
|
1331
|
-
: undefined
|
|
1332
|
-
);
|
|
1337
|
+
getStatusList(ids?: EntityStatus[]) {
|
|
1338
|
+
return this.getEnumList(EntityStatus, 'status', ids);
|
|
1333
1339
|
}
|
|
1334
1340
|
|
|
1335
1341
|
/**
|
package/src/app/IApp.ts
CHANGED
|
@@ -434,10 +434,12 @@ export interface IApp {
|
|
|
434
434
|
getEnumStrList<E extends DataTypes.EnumBase = DataTypes.EnumBase>(
|
|
435
435
|
em: E,
|
|
436
436
|
prefix: string,
|
|
437
|
-
filter?:
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
437
|
+
filter?:
|
|
438
|
+
| ((
|
|
439
|
+
id: E[keyof E],
|
|
440
|
+
key: keyof E & string
|
|
441
|
+
) => E[keyof E] | undefined)
|
|
442
|
+
| E[keyof E][]
|
|
441
443
|
): ListType1[];
|
|
442
444
|
|
|
443
445
|
/**
|