@etsoo/appscript 1.2.17 → 1.2.21
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 +5 -3
- package/lib/cjs/app/CoreApp.js +10 -2
- package/lib/cjs/i18n/en-US.json +2 -0
- package/lib/cjs/i18n/zh-CN.json +2 -0
- package/lib/cjs/i18n/zh-HK.json +2 -0
- package/lib/cjs/result/ActionResultError.js +3 -1
- package/lib/cjs/result/IActionResult.d.ts +5 -1
- package/lib/mjs/app/CoreApp.d.ts +5 -3
- package/lib/mjs/app/CoreApp.js +10 -2
- package/lib/mjs/i18n/en-US.json +2 -0
- package/lib/mjs/i18n/zh-CN.json +2 -0
- package/lib/mjs/i18n/zh-HK.json +2 -0
- package/lib/mjs/result/ActionResultError.js +3 -1
- package/lib/mjs/result/IActionResult.d.ts +5 -1
- package/package.json +3 -3
- package/src/app/CoreApp.ts +16 -4
- package/src/i18n/en-US.json +2 -0
- package/src/i18n/zh-CN.json +2 -0
- package/src/i18n/zh-HK.json +2 -0
- package/src/result/ActionResultError.ts +2 -2
- package/src/result/IActionResult.ts +6 -1
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INotifier, NotificationAlign, NotificationCallProps, NotificationContent } from '@etsoo/notificationbase';
|
|
1
|
+
import { INotifier, NotificationAlign, NotificationCallProps, NotificationContent, NotificationReturn } from '@etsoo/notificationbase';
|
|
2
2
|
import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
|
|
3
3
|
import { DataTypes, DateUtils, IStorage } from '@etsoo/shared';
|
|
4
4
|
import { AddressRegion } from '../address/AddressRegion';
|
|
@@ -105,8 +105,9 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
105
105
|
/**
|
|
106
106
|
* Alert action result
|
|
107
107
|
* @param result Action result
|
|
108
|
+
* @param callback Callback
|
|
108
109
|
*/
|
|
109
|
-
alertResult(result: IActionResult): void;
|
|
110
|
+
alertResult(result: IActionResult, callback?: NotificationReturn<void>): void;
|
|
110
111
|
/**
|
|
111
112
|
* Authorize
|
|
112
113
|
* @param token New token
|
|
@@ -485,8 +486,9 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
485
486
|
/**
|
|
486
487
|
* Alert action result
|
|
487
488
|
* @param result Action result
|
|
489
|
+
* @param callback Callback
|
|
488
490
|
*/
|
|
489
|
-
alertResult(result: IActionResult): void;
|
|
491
|
+
alertResult(result: IActionResult, callback?: NotificationReturn<void>): void;
|
|
490
492
|
/**
|
|
491
493
|
* Authorize
|
|
492
494
|
* @param token New token
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -349,10 +349,11 @@ class CoreApp {
|
|
|
349
349
|
/**
|
|
350
350
|
* Alert action result
|
|
351
351
|
* @param result Action result
|
|
352
|
+
* @param callback Callback
|
|
352
353
|
*/
|
|
353
|
-
alertResult(result) {
|
|
354
|
+
alertResult(result, callback) {
|
|
354
355
|
this.formatResult(result);
|
|
355
|
-
this.notifier.alert(ActionResultError_1.ActionResultError.format(result));
|
|
356
|
+
this.notifier.alert(ActionResultError_1.ActionResultError.format(result), callback);
|
|
356
357
|
}
|
|
357
358
|
/**
|
|
358
359
|
* Authorize
|
|
@@ -649,6 +650,7 @@ class CoreApp {
|
|
|
649
650
|
* @param forceToLocal Force to local labels
|
|
650
651
|
*/
|
|
651
652
|
formatResult(result, forceToLocal) {
|
|
653
|
+
var _a;
|
|
652
654
|
const title = result.title;
|
|
653
655
|
if (title && /^\w+$/.test(title)) {
|
|
654
656
|
const key = title.formatInitial(false);
|
|
@@ -665,6 +667,12 @@ class CoreApp {
|
|
|
665
667
|
const key = result.type.formatInitial(false);
|
|
666
668
|
result.title = this.get(key);
|
|
667
669
|
}
|
|
670
|
+
// When title contains {0}, replace with the field label
|
|
671
|
+
if (result.field && ((_a = result.title) === null || _a === void 0 ? void 0 : _a.includes('{0}'))) {
|
|
672
|
+
const fieldLabel = this.get(result.field.formatInitial(false));
|
|
673
|
+
if (fieldLabel)
|
|
674
|
+
result.title = result.title.format(fieldLabel);
|
|
675
|
+
}
|
|
668
676
|
}
|
|
669
677
|
/**
|
|
670
678
|
* Get culture resource
|
package/lib/cjs/i18n/en-US.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"completeTip": "{0} completed",
|
|
11
11
|
"copy": "Copy",
|
|
12
12
|
"creation": "Creation",
|
|
13
|
+
"currency": "Currency",
|
|
13
14
|
"delete": "Delete",
|
|
14
15
|
"description": "Description",
|
|
15
16
|
"done": "Done",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"send": "Send",
|
|
60
61
|
"setAsDefault": "Set as default",
|
|
61
62
|
"settings": "Settings",
|
|
63
|
+
"showIt": "Show it",
|
|
62
64
|
"signout": "Sign out",
|
|
63
65
|
"smartERP": "SmartERP",
|
|
64
66
|
"status": "Status",
|
package/lib/cjs/i18n/zh-CN.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"completeTip": "已完成 {0}",
|
|
11
11
|
"copy": "复制",
|
|
12
12
|
"creation": "登记时间",
|
|
13
|
+
"currency": "币种",
|
|
13
14
|
"delete": "删除",
|
|
14
15
|
"description": "描述",
|
|
15
16
|
"done": "完成",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"send": "发送",
|
|
60
61
|
"setAsDefault": "设为默认",
|
|
61
62
|
"settings": "系统设置",
|
|
63
|
+
"showIt": "显示",
|
|
62
64
|
"signout": "退出",
|
|
63
65
|
"smartERP": "司友云ERP",
|
|
64
66
|
"status": "状态",
|
package/lib/cjs/i18n/zh-HK.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"completeTip": "已完成 {0}",
|
|
11
11
|
"copy": "複製",
|
|
12
12
|
"creation": "登記時間",
|
|
13
|
+
"currency": "幣種",
|
|
13
14
|
"delete": "刪除",
|
|
14
15
|
"description": "描述",
|
|
15
16
|
"done": "完成",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"send": "發送",
|
|
60
61
|
"setAsDefault": "設為默認",
|
|
61
62
|
"settings": "系統設置",
|
|
63
|
+
"showIt": "顯示",
|
|
62
64
|
"signout": "退出",
|
|
63
65
|
"smartERP": "司友雲ERP",
|
|
64
66
|
"status": "狀態",
|
|
@@ -26,8 +26,10 @@ class ActionResultError extends Error {
|
|
|
26
26
|
var addtions = [];
|
|
27
27
|
if (result.status != null)
|
|
28
28
|
addtions.push(result.status);
|
|
29
|
-
if (result.type
|
|
29
|
+
if (result.type)
|
|
30
30
|
addtions.push(result.type);
|
|
31
|
+
if (result.field)
|
|
32
|
+
addtions.push(result.field);
|
|
31
33
|
var add = addtions.length > 0 ? ` (${addtions.join(', ')})` : '';
|
|
32
34
|
return `${result.title || 'Error'}${add}`;
|
|
33
35
|
}
|
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { INotifier, NotificationAlign, NotificationCallProps, NotificationContent } from '@etsoo/notificationbase';
|
|
1
|
+
import { INotifier, NotificationAlign, NotificationCallProps, NotificationContent, NotificationReturn } from '@etsoo/notificationbase';
|
|
2
2
|
import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
|
|
3
3
|
import { DataTypes, DateUtils, IStorage } from '@etsoo/shared';
|
|
4
4
|
import { AddressRegion } from '../address/AddressRegion';
|
|
@@ -105,8 +105,9 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
|
|
|
105
105
|
/**
|
|
106
106
|
* Alert action result
|
|
107
107
|
* @param result Action result
|
|
108
|
+
* @param callback Callback
|
|
108
109
|
*/
|
|
109
|
-
alertResult(result: IActionResult): void;
|
|
110
|
+
alertResult(result: IActionResult, callback?: NotificationReturn<void>): void;
|
|
110
111
|
/**
|
|
111
112
|
* Authorize
|
|
112
113
|
* @param token New token
|
|
@@ -485,8 +486,9 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
|
|
|
485
486
|
/**
|
|
486
487
|
* Alert action result
|
|
487
488
|
* @param result Action result
|
|
489
|
+
* @param callback Callback
|
|
488
490
|
*/
|
|
489
|
-
alertResult(result: IActionResult): void;
|
|
491
|
+
alertResult(result: IActionResult, callback?: NotificationReturn<void>): void;
|
|
490
492
|
/**
|
|
491
493
|
* Authorize
|
|
492
494
|
* @param token New token
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -346,10 +346,11 @@ export class CoreApp {
|
|
|
346
346
|
/**
|
|
347
347
|
* Alert action result
|
|
348
348
|
* @param result Action result
|
|
349
|
+
* @param callback Callback
|
|
349
350
|
*/
|
|
350
|
-
alertResult(result) {
|
|
351
|
+
alertResult(result, callback) {
|
|
351
352
|
this.formatResult(result);
|
|
352
|
-
this.notifier.alert(ActionResultError.format(result));
|
|
353
|
+
this.notifier.alert(ActionResultError.format(result), callback);
|
|
353
354
|
}
|
|
354
355
|
/**
|
|
355
356
|
* Authorize
|
|
@@ -646,6 +647,7 @@ export class CoreApp {
|
|
|
646
647
|
* @param forceToLocal Force to local labels
|
|
647
648
|
*/
|
|
648
649
|
formatResult(result, forceToLocal) {
|
|
650
|
+
var _a;
|
|
649
651
|
const title = result.title;
|
|
650
652
|
if (title && /^\w+$/.test(title)) {
|
|
651
653
|
const key = title.formatInitial(false);
|
|
@@ -662,6 +664,12 @@ export class CoreApp {
|
|
|
662
664
|
const key = result.type.formatInitial(false);
|
|
663
665
|
result.title = this.get(key);
|
|
664
666
|
}
|
|
667
|
+
// When title contains {0}, replace with the field label
|
|
668
|
+
if (result.field && ((_a = result.title) === null || _a === void 0 ? void 0 : _a.includes('{0}'))) {
|
|
669
|
+
const fieldLabel = this.get(result.field.formatInitial(false));
|
|
670
|
+
if (fieldLabel)
|
|
671
|
+
result.title = result.title.format(fieldLabel);
|
|
672
|
+
}
|
|
665
673
|
}
|
|
666
674
|
/**
|
|
667
675
|
* Get culture resource
|
package/lib/mjs/i18n/en-US.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"completeTip": "{0} completed",
|
|
11
11
|
"copy": "Copy",
|
|
12
12
|
"creation": "Creation",
|
|
13
|
+
"currency": "Currency",
|
|
13
14
|
"delete": "Delete",
|
|
14
15
|
"description": "Description",
|
|
15
16
|
"done": "Done",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"send": "Send",
|
|
60
61
|
"setAsDefault": "Set as default",
|
|
61
62
|
"settings": "Settings",
|
|
63
|
+
"showIt": "Show it",
|
|
62
64
|
"signout": "Sign out",
|
|
63
65
|
"smartERP": "SmartERP",
|
|
64
66
|
"status": "Status",
|
package/lib/mjs/i18n/zh-CN.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"completeTip": "已完成 {0}",
|
|
11
11
|
"copy": "复制",
|
|
12
12
|
"creation": "登记时间",
|
|
13
|
+
"currency": "币种",
|
|
13
14
|
"delete": "删除",
|
|
14
15
|
"description": "描述",
|
|
15
16
|
"done": "完成",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"send": "发送",
|
|
60
61
|
"setAsDefault": "设为默认",
|
|
61
62
|
"settings": "系统设置",
|
|
63
|
+
"showIt": "显示",
|
|
62
64
|
"signout": "退出",
|
|
63
65
|
"smartERP": "司友云ERP",
|
|
64
66
|
"status": "状态",
|
package/lib/mjs/i18n/zh-HK.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"completeTip": "已完成 {0}",
|
|
11
11
|
"copy": "複製",
|
|
12
12
|
"creation": "登記時間",
|
|
13
|
+
"currency": "幣種",
|
|
13
14
|
"delete": "刪除",
|
|
14
15
|
"description": "描述",
|
|
15
16
|
"done": "完成",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"send": "發送",
|
|
60
61
|
"setAsDefault": "設為默認",
|
|
61
62
|
"settings": "系統設置",
|
|
63
|
+
"showIt": "顯示",
|
|
62
64
|
"signout": "退出",
|
|
63
65
|
"smartERP": "司友雲ERP",
|
|
64
66
|
"status": "狀態",
|
|
@@ -23,8 +23,10 @@ export class ActionResultError extends Error {
|
|
|
23
23
|
var addtions = [];
|
|
24
24
|
if (result.status != null)
|
|
25
25
|
addtions.push(result.status);
|
|
26
|
-
if (result.type
|
|
26
|
+
if (result.type)
|
|
27
27
|
addtions.push(result.type);
|
|
28
|
+
if (result.field)
|
|
29
|
+
addtions.push(result.field);
|
|
28
30
|
var add = addtions.length > 0 ? ` (${addtions.join(', ')})` : '';
|
|
29
31
|
return `${result.title || 'Error'}${add}`;
|
|
30
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.21",
|
|
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.
|
|
57
|
+
"@etsoo/shared": "^1.1.1",
|
|
58
58
|
"@types/crypto-js": "^4.1.0",
|
|
59
59
|
"crypto-js": "^4.1.1"
|
|
60
60
|
},
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"eslint": "^8.6.0",
|
|
71
71
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
72
72
|
"eslint-plugin-import": "^2.25.4",
|
|
73
|
-
"jest": "^27.4.
|
|
73
|
+
"jest": "^27.4.7",
|
|
74
74
|
"ts-jest": "^27.1.2",
|
|
75
75
|
"typescript": "^4.5.4"
|
|
76
76
|
}
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
NotificationAlign,
|
|
5
5
|
NotificationCallProps,
|
|
6
6
|
NotificationContent,
|
|
7
|
-
NotificationMessageType
|
|
7
|
+
NotificationMessageType,
|
|
8
|
+
NotificationReturn
|
|
8
9
|
} from '@etsoo/notificationbase';
|
|
9
10
|
import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
|
|
10
11
|
import {
|
|
@@ -161,8 +162,12 @@ export interface ICoreApp<
|
|
|
161
162
|
/**
|
|
162
163
|
* Alert action result
|
|
163
164
|
* @param result Action result
|
|
165
|
+
* @param callback Callback
|
|
164
166
|
*/
|
|
165
|
-
alertResult(
|
|
167
|
+
alertResult(
|
|
168
|
+
result: IActionResult,
|
|
169
|
+
callback?: NotificationReturn<void>
|
|
170
|
+
): void;
|
|
166
171
|
|
|
167
172
|
/**
|
|
168
173
|
* Authorize
|
|
@@ -938,10 +943,11 @@ export abstract class CoreApp<
|
|
|
938
943
|
/**
|
|
939
944
|
* Alert action result
|
|
940
945
|
* @param result Action result
|
|
946
|
+
* @param callback Callback
|
|
941
947
|
*/
|
|
942
|
-
alertResult(result: IActionResult) {
|
|
948
|
+
alertResult(result: IActionResult, callback?: NotificationReturn<void>) {
|
|
943
949
|
this.formatResult(result);
|
|
944
|
-
this.notifier.alert(ActionResultError.format(result));
|
|
950
|
+
this.notifier.alert(ActionResultError.format(result), callback);
|
|
945
951
|
}
|
|
946
952
|
|
|
947
953
|
/**
|
|
@@ -1325,6 +1331,12 @@ export abstract class CoreApp<
|
|
|
1325
1331
|
const key = result.type.formatInitial(false);
|
|
1326
1332
|
result.title = this.get(key);
|
|
1327
1333
|
}
|
|
1334
|
+
|
|
1335
|
+
// When title contains {0}, replace with the field label
|
|
1336
|
+
if (result.field && result.title?.includes('{0}')) {
|
|
1337
|
+
const fieldLabel = this.get(result.field.formatInitial(false));
|
|
1338
|
+
if (fieldLabel) result.title = result.title.format(fieldLabel);
|
|
1339
|
+
}
|
|
1328
1340
|
}
|
|
1329
1341
|
|
|
1330
1342
|
/**
|
package/src/i18n/en-US.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"completeTip": "{0} completed",
|
|
11
11
|
"copy": "Copy",
|
|
12
12
|
"creation": "Creation",
|
|
13
|
+
"currency": "Currency",
|
|
13
14
|
"delete": "Delete",
|
|
14
15
|
"description": "Description",
|
|
15
16
|
"done": "Done",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"send": "Send",
|
|
60
61
|
"setAsDefault": "Set as default",
|
|
61
62
|
"settings": "Settings",
|
|
63
|
+
"showIt": "Show it",
|
|
62
64
|
"signout": "Sign out",
|
|
63
65
|
"smartERP": "SmartERP",
|
|
64
66
|
"status": "Status",
|
package/src/i18n/zh-CN.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"completeTip": "已完成 {0}",
|
|
11
11
|
"copy": "复制",
|
|
12
12
|
"creation": "登记时间",
|
|
13
|
+
"currency": "币种",
|
|
13
14
|
"delete": "删除",
|
|
14
15
|
"description": "描述",
|
|
15
16
|
"done": "完成",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"send": "发送",
|
|
60
61
|
"setAsDefault": "设为默认",
|
|
61
62
|
"settings": "系统设置",
|
|
63
|
+
"showIt": "显示",
|
|
62
64
|
"signout": "退出",
|
|
63
65
|
"smartERP": "司友云ERP",
|
|
64
66
|
"status": "状态",
|
package/src/i18n/zh-HK.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"completeTip": "已完成 {0}",
|
|
11
11
|
"copy": "複製",
|
|
12
12
|
"creation": "登記時間",
|
|
13
|
+
"currency": "幣種",
|
|
13
14
|
"delete": "刪除",
|
|
14
15
|
"description": "描述",
|
|
15
16
|
"done": "完成",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"send": "發送",
|
|
60
61
|
"setAsDefault": "設為默認",
|
|
61
62
|
"settings": "系統設置",
|
|
63
|
+
"showIt": "顯示",
|
|
62
64
|
"signout": "退出",
|
|
63
65
|
"smartERP": "司友雲ERP",
|
|
64
66
|
"status": "狀態",
|
|
@@ -12,8 +12,8 @@ export class ActionResultError extends Error {
|
|
|
12
12
|
// Additional data
|
|
13
13
|
var addtions = [];
|
|
14
14
|
if (result.status != null) addtions.push(result.status);
|
|
15
|
-
if (result.type
|
|
16
|
-
|
|
15
|
+
if (result.type) addtions.push(result.type);
|
|
16
|
+
if (result.field) addtions.push(result.field);
|
|
17
17
|
|
|
18
18
|
var add = addtions.length > 0 ? ` (${addtions.join(', ')})` : '';
|
|
19
19
|
|