@etsoo/appscript 1.2.17 → 1.2.18

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.
@@ -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
@@ -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, _b;
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
+ (_b = result.title) === null || _b === void 0 ? void 0 : _b.format(fieldLabel);
675
+ }
668
676
  }
669
677
  /**
670
678
  * Get culture resource
@@ -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 && result.type != 'about:blank')
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
  }
@@ -52,7 +52,11 @@ export interface IActionResult<D extends IResultData = IResultData> {
52
52
  /**
53
53
  * Type
54
54
  */
55
- type: string;
55
+ type?: string;
56
+ /**
57
+ * Field name
58
+ */
59
+ field?: string;
56
60
  /**
57
61
  * Success or not
58
62
  */
@@ -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
@@ -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, _b;
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
+ (_b = result.title) === null || _b === void 0 ? void 0 : _b.format(fieldLabel);
672
+ }
665
673
  }
666
674
  /**
667
675
  * Get culture resource
@@ -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 && result.type != 'about:blank')
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
  }
@@ -52,7 +52,11 @@ export interface IActionResult<D extends IResultData = IResultData> {
52
52
  /**
53
53
  * Type
54
54
  */
55
- type: string;
55
+ type?: string;
56
+ /**
57
+ * Field name
58
+ */
59
+ field?: string;
56
60
  /**
57
61
  * Success or not
58
62
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.2.17",
3
+ "version": "1.2.18",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -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(result: IActionResult): void;
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?.format(fieldLabel);
1339
+ }
1328
1340
  }
1329
1341
 
1330
1342
  /**
@@ -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 && result.type != 'about:blank')
16
- addtions.push(result.type);
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
 
@@ -61,7 +61,12 @@ export interface IActionResult<D extends IResultData = IResultData> {
61
61
  /**
62
62
  * Type
63
63
  */
64
- type: string;
64
+ type?: string;
65
+
66
+ /**
67
+ * Field name
68
+ */
69
+ field?: string;
65
70
 
66
71
  /**
67
72
  * Success or not