@singularsystems/neo-core 1.0.0-beta.3 → 1.0.0-beta.5
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/dist/Components/ErrorHandler.js +6 -5
- package/dist/Components/FileManager/FileManager.js +2 -1
- package/dist/Components/Modal/ModalUtils.js +21 -9
- package/dist/DebounceHelper.d.ts +3 -0
- package/dist/DebounceHelper.js +17 -0
- package/dist/Localisation/NeoStrings.d.ts +40 -0
- package/dist/Localisation/NeoStrings.js +40 -0
- package/dist/Model/Misc.d.ts +4 -2
- package/dist/Model/ObservableProperty.js +1 -1
- package/dist/Security/Oidc/OidcAuthService.d.ts +1 -0
- package/dist/Security/Oidc/OidcAuthService.js +31 -15
- package/dist/Settings.d.ts +5 -0
- package/dist/Settings.js +8 -0
- package/dist/Utils.d.ts +2 -1
- package/dist/Utils.js +4 -2
- package/dist/Validation/Decorators.js +4 -5
- package/dist/Validation/Rules.js +3 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
- package/CHANGELOG.md +0 -15
|
@@ -2,6 +2,7 @@ import { __awaiter, __decorate, __generator, __metadata, __param } from "tslib";
|
|
|
2
2
|
import { injectable, inject } from 'inversify';
|
|
3
3
|
import { ModalUtils } from './Modal/ModalUtils';
|
|
4
4
|
import NeoTypes from '../AppServices/NeoTypes';
|
|
5
|
+
import NeoStrings from '../Localisation/NeoStrings';
|
|
5
6
|
export var ErrorDisplayType;
|
|
6
7
|
(function (ErrorDisplayType) {
|
|
7
8
|
/** Show the error text in a modal. */
|
|
@@ -96,16 +97,16 @@ export var ErrorHandler = /** @class */ (function () {
|
|
|
96
97
|
});
|
|
97
98
|
};
|
|
98
99
|
ErrorHandler.prototype.get400Error = function (error) {
|
|
99
|
-
return this.parseAxiosError(
|
|
100
|
+
return this.parseAxiosError(NeoStrings.errors.invalidDataTitle, NeoStrings.errors.invalidDataBody, error);
|
|
100
101
|
};
|
|
101
102
|
ErrorHandler.prototype.get401Error = function (error) {
|
|
102
|
-
return this.parseAxiosError(
|
|
103
|
+
return this.parseAxiosError(NeoStrings.errors.notAuthenticatedTitle, NeoStrings.errors.notAuthenticatedBody, error);
|
|
103
104
|
};
|
|
104
105
|
ErrorHandler.prototype.get403Error = function (error) {
|
|
105
|
-
return this.parseAxiosError(
|
|
106
|
+
return this.parseAxiosError(NeoStrings.errors.unAuthorisedTitle, NeoStrings.errors.unAuthorisedBody, error);
|
|
106
107
|
};
|
|
107
108
|
ErrorHandler.prototype.get409Error = function (error) {
|
|
108
|
-
return this.parseAxiosError(
|
|
109
|
+
return this.parseAxiosError(NeoStrings.errors.concurrencyTitle, NeoStrings.errors.concurrencyBody, error);
|
|
109
110
|
};
|
|
110
111
|
/**
|
|
111
112
|
* Parses an axios response into an IErrorDisplay object.
|
|
@@ -182,7 +183,7 @@ export var ErrorHandler = /** @class */ (function () {
|
|
|
182
183
|
};
|
|
183
184
|
ErrorHandler.prototype.getGeneralError = function (error) {
|
|
184
185
|
var errorDescription = error.message ? error.message : error;
|
|
185
|
-
return { header:
|
|
186
|
+
return { header: NeoStrings.errors.generalTitle, body: errorDescription };
|
|
186
187
|
};
|
|
187
188
|
ErrorHandler.prototype.displayError = function (displayType, error, errorDisplay) {
|
|
188
189
|
if (error instanceof Error) {
|
|
@@ -7,6 +7,7 @@ import { NeoTypes } from '../../AppServices';
|
|
|
7
7
|
import { ErrorDisplayType } from '../ErrorHandler';
|
|
8
8
|
import { Settings } from '../../Settings';
|
|
9
9
|
import { FileUploadBatch } from './FileUploadBatch';
|
|
10
|
+
import NeoStrings from '../../Localisation/NeoStrings';
|
|
10
11
|
var fileInputSymbol = Symbol("FileInput");
|
|
11
12
|
export var FileManagerBase = /** @class */ (function () {
|
|
12
13
|
function FileManagerBase(uploadEndpointOrOptions, options) {
|
|
@@ -89,7 +90,7 @@ export var FileManagerBase = /** @class */ (function () {
|
|
|
89
90
|
return true;
|
|
90
91
|
}
|
|
91
92
|
else {
|
|
92
|
-
ModalUtils.showMessage(
|
|
93
|
+
ModalUtils.showMessage(NeoStrings.fileManager.uploadErrorTitle, NeoStrings.fileManager.uploadErrorBody.format(checkResult.extension));
|
|
93
94
|
return false;
|
|
94
95
|
}
|
|
95
96
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
1
2
|
import Globals from '../../Globals';
|
|
2
3
|
import { NeoTypes } from '../../AppServices';
|
|
4
|
+
import { Settings } from '../../Settings';
|
|
5
|
+
import NeoStrings from '../../Localisation/NeoStrings';
|
|
3
6
|
export var ModalResult;
|
|
4
7
|
(function (ModalResult) {
|
|
5
8
|
ModalResult[ModalResult["Yes"] = 1] = "Yes";
|
|
@@ -12,7 +15,16 @@ var ModalHelpers = /** @class */ (function () {
|
|
|
12
15
|
ModalHelpers.prototype.showMessage = function (title, message, resultValue) {
|
|
13
16
|
var _this = this;
|
|
14
17
|
return new Promise(function (resolve, reject) {
|
|
15
|
-
|
|
18
|
+
var button = { text: NeoStrings.modals.ok, onClick: function () { return resultValue ? resolve(resultValue) : resolve(); } };
|
|
19
|
+
var options = { onClose: resolve };
|
|
20
|
+
if (Settings.modal.okIsAccept) {
|
|
21
|
+
options.acceptButton = button;
|
|
22
|
+
options.closeButton = false;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
options.closeButton = button;
|
|
26
|
+
}
|
|
27
|
+
_this.showModal(title, message, options);
|
|
16
28
|
});
|
|
17
29
|
};
|
|
18
30
|
/**
|
|
@@ -47,8 +59,8 @@ var ModalHelpers = /** @class */ (function () {
|
|
|
47
59
|
_this.showModal(title, message, {
|
|
48
60
|
onClose: function () { return resolve(ModalResult.No); },
|
|
49
61
|
showCancelButton: allowCancel,
|
|
50
|
-
acceptButton: { text:
|
|
51
|
-
closeButton: { text:
|
|
62
|
+
acceptButton: { text: NeoStrings.modals.yes, onClick: onAccept },
|
|
63
|
+
closeButton: { text: NeoStrings.modals.no, onClick: function () { return resolve(ModalResult.No); } }
|
|
52
64
|
});
|
|
53
65
|
});
|
|
54
66
|
};
|
|
@@ -64,9 +76,9 @@ var ModalHelpers = /** @class */ (function () {
|
|
|
64
76
|
return new Promise(function (resolve, reject) {
|
|
65
77
|
_this.showModal(title, message, {
|
|
66
78
|
onClose: function () { return resolve(ModalResult.Cancel); },
|
|
67
|
-
acceptButton: { text:
|
|
68
|
-
closeButton: {
|
|
69
|
-
formProps: { model: model }
|
|
79
|
+
acceptButton: { text: NeoStrings.modals.ok, onClick: function () { return resolve(ModalResult.Yes); } },
|
|
80
|
+
closeButton: __assign(__assign({}, Settings.modal.cancelButton), { text: NeoStrings.modals.cancel, onClick: function () { return resolve(ModalResult.Cancel); } }),
|
|
81
|
+
formProps: { model: model },
|
|
70
82
|
});
|
|
71
83
|
});
|
|
72
84
|
};
|
|
@@ -88,9 +100,9 @@ var ModalHelpers = /** @class */ (function () {
|
|
|
88
100
|
_this.showModal(title, message, {
|
|
89
101
|
onClose: function () { return resolve(ModalResult.Cancel); },
|
|
90
102
|
buttons: [
|
|
91
|
-
{
|
|
92
|
-
{
|
|
93
|
-
{
|
|
103
|
+
__assign(__assign({}, Settings.modal.acceptButton), { text: NeoStrings.modals.yes, onClick: onAccept }),
|
|
104
|
+
__assign(__assign({}, Settings.modal.closeButton), { text: NeoStrings.modals.no, onClick: function () { return resolve(ModalResult.No); } }),
|
|
105
|
+
__assign(__assign({}, Settings.modal.cancelButton), { text: NeoStrings.modals.cancel, onClick: function () { return resolve(ModalResult.Cancel); } })
|
|
94
106
|
]
|
|
95
107
|
});
|
|
96
108
|
});
|
package/dist/DebounceHelper.d.ts
CHANGED
|
@@ -26,10 +26,13 @@ export declare class DebounceHelper<T = void, TState = any> {
|
|
|
26
26
|
* @param state State to pass to debounced method as an array of values for each time debounce was called.
|
|
27
27
|
*/
|
|
28
28
|
static debounce<T = any, TState = any>(syncInstance: any, callback: (state: TState[]) => T | Promise<T>, delayMs: number, state?: TState): Promise<IDebounceResult<T>>;
|
|
29
|
+
static hasPending(syncInstance: any): boolean;
|
|
29
30
|
/** Cancels pending execution of the callback. Pending promise will be resolved with cancelled: true. */
|
|
30
31
|
static cancelPending<TState = any>(syncInstance: any): TState[];
|
|
31
32
|
/** Fires the latest callback immediately. Pending promise from execute() will also be resolved with the return value of the callback. */
|
|
32
33
|
static executeImmediate(syncInstance: any): Promise<void>;
|
|
34
|
+
/** Indicates that there is a pending execution. */
|
|
35
|
+
get hasPending(): boolean;
|
|
33
36
|
/**
|
|
34
37
|
* Waits the interval defined in the constructor, then executes the callback.
|
|
35
38
|
* The callback will not execute if execute is called again within the interval.
|
package/dist/DebounceHelper.js
CHANGED
|
@@ -32,6 +32,15 @@ var DebounceHelper = /** @class */ (function () {
|
|
|
32
32
|
helper.delayMs = delayMs;
|
|
33
33
|
return helper.execute(state);
|
|
34
34
|
};
|
|
35
|
+
DebounceHelper.hasPending = function (syncInstance) {
|
|
36
|
+
var helper = syncInstance[stateSymbol];
|
|
37
|
+
if (helper) {
|
|
38
|
+
return helper.hasPending;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
35
44
|
/** Cancels pending execution of the callback. Pending promise will be resolved with cancelled: true. */
|
|
36
45
|
DebounceHelper.cancelPending = function (syncInstance) {
|
|
37
46
|
var helper = syncInstance[stateSymbol];
|
|
@@ -52,6 +61,14 @@ var DebounceHelper = /** @class */ (function () {
|
|
|
52
61
|
return Promise.resolve();
|
|
53
62
|
}
|
|
54
63
|
};
|
|
64
|
+
Object.defineProperty(DebounceHelper.prototype, "hasPending", {
|
|
65
|
+
/** Indicates that there is a pending execution. */
|
|
66
|
+
get: function () {
|
|
67
|
+
return this.currentResolver !== undefined;
|
|
68
|
+
},
|
|
69
|
+
enumerable: false,
|
|
70
|
+
configurable: true
|
|
71
|
+
});
|
|
55
72
|
/**
|
|
56
73
|
* Waits the interval defined in the constructor, then executes the callback.
|
|
57
74
|
* The callback will not execute if execute is called again within the interval.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
declare const NeoStrings: {
|
|
2
|
+
errors: {
|
|
3
|
+
concurrencyTitle: string;
|
|
4
|
+
concurrencyBody: string;
|
|
5
|
+
generalTitle: string;
|
|
6
|
+
invalidDataTitle: string;
|
|
7
|
+
invalidDataBody: string;
|
|
8
|
+
notAuthenticatedTitle: string;
|
|
9
|
+
notAuthenticatedBody: string;
|
|
10
|
+
unAuthorisedTitle: string;
|
|
11
|
+
unAuthorisedBody: string;
|
|
12
|
+
};
|
|
13
|
+
fileManager: {
|
|
14
|
+
uploadErrorTitle: string;
|
|
15
|
+
/** {0} is the extension of the file */
|
|
16
|
+
uploadErrorBody: string;
|
|
17
|
+
};
|
|
18
|
+
modals: {
|
|
19
|
+
cancel: string;
|
|
20
|
+
no: string;
|
|
21
|
+
ok: string;
|
|
22
|
+
yes: string;
|
|
23
|
+
};
|
|
24
|
+
validation: {
|
|
25
|
+
/** Default text to display for built in rules. */
|
|
26
|
+
rules: {
|
|
27
|
+
/** {0} is the field name */
|
|
28
|
+
required: string;
|
|
29
|
+
/** {0} is the current value */
|
|
30
|
+
emailAddress: string;
|
|
31
|
+
/** {0} is the field name */
|
|
32
|
+
regExp: string;
|
|
33
|
+
/** Displayed when the string is too short */
|
|
34
|
+
stringLengthLessThan: string;
|
|
35
|
+
/** Displayed when the string is too long */
|
|
36
|
+
stringLengthMoreThan: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export default NeoStrings;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var NeoStrings = {
|
|
2
|
+
errors: {
|
|
3
|
+
concurrencyTitle: "Concurrency error",
|
|
4
|
+
concurrencyBody: "Someone else modified the record before you saved it. Please reload it and try again.",
|
|
5
|
+
generalTitle: "Error",
|
|
6
|
+
invalidDataTitle: "Invalid data",
|
|
7
|
+
invalidDataBody: "Cannot continue due to the following validation errors:",
|
|
8
|
+
notAuthenticatedTitle: "Not authenticated",
|
|
9
|
+
notAuthenticatedBody: "You are not logged in. Please reload the page to login again.",
|
|
10
|
+
unAuthorisedTitle: "Unauthorised",
|
|
11
|
+
unAuthorisedBody: "You do not have access to perform this operation."
|
|
12
|
+
},
|
|
13
|
+
fileManager: {
|
|
14
|
+
uploadErrorTitle: "File upload error",
|
|
15
|
+
/** {0} is the extension of the file */
|
|
16
|
+
uploadErrorBody: "File extension: {0} is not allowed."
|
|
17
|
+
},
|
|
18
|
+
modals: {
|
|
19
|
+
cancel: "Cancel",
|
|
20
|
+
no: "No",
|
|
21
|
+
ok: "Ok",
|
|
22
|
+
yes: "Yes",
|
|
23
|
+
},
|
|
24
|
+
validation: {
|
|
25
|
+
/** Default text to display for built in rules. */
|
|
26
|
+
rules: {
|
|
27
|
+
/** {0} is the field name */
|
|
28
|
+
required: "{0} is required",
|
|
29
|
+
/** {0} is the current value */
|
|
30
|
+
emailAddress: "{0} is not a valid email address",
|
|
31
|
+
/** {0} is the field name */
|
|
32
|
+
regExp: "{0} is in an invalid format",
|
|
33
|
+
/** Displayed when the string is too short */
|
|
34
|
+
stringLengthLessThan: "{0} cannot be less than {1} characters in length",
|
|
35
|
+
/** Displayed when the string is too long */
|
|
36
|
+
stringLengthMoreThan: "{0} cannot be more than {1} characters in length"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export default NeoStrings;
|
package/dist/Model/Misc.d.ts
CHANGED
|
@@ -54,10 +54,12 @@ export interface IDisposable {
|
|
|
54
54
|
dispose(): void;
|
|
55
55
|
}
|
|
56
56
|
export interface IAutoRunner extends IDisposable {
|
|
57
|
+
/** Indicates whether there are any pending callbacks. */
|
|
58
|
+
readonly hasPending: boolean;
|
|
57
59
|
/** Dispose the auto runner. */
|
|
58
60
|
dispose(): void;
|
|
59
|
-
/** Cancels any pending callbacks. */
|
|
60
|
-
cancelPending():
|
|
61
|
+
/** Cancels any pending callbacks. Returns true if there were any pending callbacks. */
|
|
62
|
+
cancelPending(): boolean;
|
|
61
63
|
/** Cancels any pending callbacks, and fires the callback immediately. */
|
|
62
64
|
fireImmediate(): void;
|
|
63
65
|
}
|
|
@@ -25,7 +25,7 @@ var ObservableProperty = /** @class */ (function () {
|
|
|
25
25
|
var model = new ObservableModel();
|
|
26
26
|
model.value = defaultValue;
|
|
27
27
|
var propertyInfo = new PropertyInfo("value");
|
|
28
|
-
Utils.populatePartialWithDefaults(propertyInfo, options);
|
|
28
|
+
Utils.populatePartialWithDefaults(propertyInfo, options, true);
|
|
29
29
|
propertyInfo.displayName = displayName;
|
|
30
30
|
if (isRequired) {
|
|
31
31
|
propertyInfo.rules.push(new RequiredRule("{0} is required."));
|
|
@@ -38,6 +38,7 @@ export default abstract class OidcAuthService<TUser extends OidcUser = OidcUser>
|
|
|
38
38
|
endSignInSilent(): Promise<any>;
|
|
39
39
|
private onUserLoaded;
|
|
40
40
|
protected afterUserLoaded(): Promise<void> | void;
|
|
41
|
+
private completeAfterUserLoaded;
|
|
41
42
|
protected createUser(user: IOidcUser): OidcUser;
|
|
42
43
|
private onUserUnloaded;
|
|
43
44
|
private setUser;
|
|
@@ -37,11 +37,14 @@ var OidcAuthService = /** @class */ (function () {
|
|
|
37
37
|
case 0: return [4 /*yield*/, this.userManager.getUser()];
|
|
38
38
|
case 1:
|
|
39
39
|
user = _a.sent();
|
|
40
|
-
if (user)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
if (!user) return [3 /*break*/, 3];
|
|
41
|
+
// Get user does not raise the onUserLoaded event, so we call it manually.
|
|
42
|
+
this.onUserLoaded(user);
|
|
43
|
+
return [4 /*yield*/, this.completeAfterUserLoaded()];
|
|
44
|
+
case 2:
|
|
45
|
+
_a.sent();
|
|
46
|
+
_a.label = 3;
|
|
47
|
+
case 3: return [2 /*return*/, this.user];
|
|
45
48
|
}
|
|
46
49
|
});
|
|
47
50
|
});
|
|
@@ -102,24 +105,21 @@ var OidcAuthService = /** @class */ (function () {
|
|
|
102
105
|
loginErrorHandler = Misc.Globals.appService.get(NeoTypes.Security.LoginErrorHandler);
|
|
103
106
|
if (!(!stateKey || window.localStorage.getItem("oidc." + stateKey) === null)) return [3 /*break*/, 1];
|
|
104
107
|
loginErrorHandler.onMissingLoginState();
|
|
105
|
-
return [3 /*break*/,
|
|
108
|
+
return [3 /*break*/, 5];
|
|
106
109
|
case 1:
|
|
107
|
-
_a.trys.push([1,
|
|
110
|
+
_a.trys.push([1, 4, , 5]);
|
|
108
111
|
return [4 /*yield*/, this.endSignIn()];
|
|
109
112
|
case 2:
|
|
110
113
|
redirectPath = _a.sent();
|
|
111
|
-
|
|
112
|
-
return [4 /*yield*/, this.afterUserLoadedPromise];
|
|
114
|
+
return [4 /*yield*/, this.completeAfterUserLoaded()];
|
|
113
115
|
case 3:
|
|
114
116
|
_a.sent();
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
case 4: return [2 /*return*/, new SignInResult(true, redirectPath)];
|
|
118
|
-
case 5:
|
|
117
|
+
return [2 /*return*/, new SignInResult(true, redirectPath)];
|
|
118
|
+
case 4:
|
|
119
119
|
e_2 = _a.sent();
|
|
120
120
|
loginErrorHandler.onException(e_2);
|
|
121
|
-
return [3 /*break*/,
|
|
122
|
-
case
|
|
121
|
+
return [3 /*break*/, 5];
|
|
122
|
+
case 5: return [2 /*return*/, new SignInResult(false, "")];
|
|
123
123
|
}
|
|
124
124
|
});
|
|
125
125
|
});
|
|
@@ -133,6 +133,22 @@ var OidcAuthService = /** @class */ (function () {
|
|
|
133
133
|
};
|
|
134
134
|
OidcAuthService.prototype.afterUserLoaded = function () {
|
|
135
135
|
};
|
|
136
|
+
OidcAuthService.prototype.completeAfterUserLoaded = function () {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
138
|
+
return __generator(this, function (_a) {
|
|
139
|
+
switch (_a.label) {
|
|
140
|
+
case 0:
|
|
141
|
+
if (!this.afterUserLoadedPromise) return [3 /*break*/, 2];
|
|
142
|
+
return [4 /*yield*/, this.afterUserLoadedPromise];
|
|
143
|
+
case 1:
|
|
144
|
+
_a.sent();
|
|
145
|
+
this.afterUserLoadedPromise = undefined;
|
|
146
|
+
_a.label = 2;
|
|
147
|
+
case 2: return [2 /*return*/];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
136
152
|
OidcAuthService.prototype.createUser = function (user) {
|
|
137
153
|
return new OidcUser(user);
|
|
138
154
|
};
|
package/dist/Settings.d.ts
CHANGED
|
@@ -49,8 +49,13 @@ export declare const Settings: {
|
|
|
49
49
|
useStickyHeaders: boolean;
|
|
50
50
|
};
|
|
51
51
|
modal: {
|
|
52
|
+
/** Set to true if ModalUtils.showMessage() should show an accept button instead of close button. */
|
|
53
|
+
okIsAccept: boolean;
|
|
52
54
|
acceptButton: IButtonOptions;
|
|
55
|
+
/** Settings for close button shown in footer. */
|
|
53
56
|
closeButton: IButtonOptions;
|
|
57
|
+
/** Settings for cancel button shown in footer. */
|
|
58
|
+
cancelButton: IButtonOptions;
|
|
54
59
|
};
|
|
55
60
|
pager: {
|
|
56
61
|
firstText: string;
|
package/dist/Settings.js
CHANGED
|
@@ -72,14 +72,22 @@ export var Settings = {
|
|
|
72
72
|
useStickyHeaders: false,
|
|
73
73
|
},
|
|
74
74
|
modal: {
|
|
75
|
+
/** Set to true if ModalUtils.showMessage() should show an accept button instead of close button. */
|
|
76
|
+
okIsAccept: false,
|
|
75
77
|
acceptButton: {
|
|
76
78
|
text: "Ok",
|
|
77
79
|
variant: "primary"
|
|
78
80
|
},
|
|
81
|
+
/** Settings for close button shown in footer. */
|
|
79
82
|
closeButton: {
|
|
80
83
|
text: "Close",
|
|
81
84
|
variant: "secondary"
|
|
82
85
|
},
|
|
86
|
+
/** Settings for cancel button shown in footer. */
|
|
87
|
+
cancelButton: {
|
|
88
|
+
variant: "light",
|
|
89
|
+
isOutline: false,
|
|
90
|
+
},
|
|
83
91
|
},
|
|
84
92
|
pager: {
|
|
85
93
|
firstText: "«",
|
package/dist/Utils.d.ts
CHANGED
|
@@ -55,8 +55,9 @@ export declare class Utils {
|
|
|
55
55
|
* Completes a partially populated object using defaults specified in the defaults parameter.
|
|
56
56
|
* @param partial Partially populated object
|
|
57
57
|
* @param defaults Defaults object.
|
|
58
|
+
* @param force True if the properties in `partial` must be set even if they have a value.
|
|
58
59
|
*/
|
|
59
|
-
static populatePartialWithDefaults<T>(partial: Partial<T> | undefined, defaults: T): T;
|
|
60
|
+
static populatePartialWithDefaults<T>(partial: Partial<T> | undefined, defaults: T, force?: boolean): T;
|
|
60
61
|
/**
|
|
61
62
|
* Converts a string like 'user' to 'fa fa-user' or 'fa-user' to 'fa fa-user' or 'far-user' to 'far fa-user'
|
|
62
63
|
*/
|
package/dist/Utils.js
CHANGED
|
@@ -102,12 +102,14 @@ var Utils = /** @class */ (function () {
|
|
|
102
102
|
* Completes a partially populated object using defaults specified in the defaults parameter.
|
|
103
103
|
* @param partial Partially populated object
|
|
104
104
|
* @param defaults Defaults object.
|
|
105
|
+
* @param force True if the properties in `partial` must be set even if they have a value.
|
|
105
106
|
*/
|
|
106
|
-
Utils.populatePartialWithDefaults = function (partial, defaults) {
|
|
107
|
+
Utils.populatePartialWithDefaults = function (partial, defaults, force) {
|
|
108
|
+
if (force === void 0) { force = false; }
|
|
107
109
|
if (!partial)
|
|
108
110
|
partial = {};
|
|
109
111
|
for (var key in defaults) {
|
|
110
|
-
if (!partial[key])
|
|
112
|
+
if (force || !partial[key])
|
|
111
113
|
partial[key] = defaults[key];
|
|
112
114
|
}
|
|
113
115
|
return partial;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import * as Rules from './Rules';
|
|
3
3
|
import { ensureTypeInfo } from '../Model/NeoTypeInfo';
|
|
4
|
+
import NeoStrings from '../Localisation/NeoStrings';
|
|
4
5
|
function addRuleToType(type, propertyName, rule) {
|
|
5
6
|
ensureTypeInfo(type.constructor).neo.addAttributeRule(propertyName, rule);
|
|
6
7
|
}
|
|
7
8
|
export function Required(errorTextOrOptions) {
|
|
8
9
|
return function (type, propertyKey) {
|
|
9
|
-
var options = { errorText:
|
|
10
|
+
var options = { errorText: NeoStrings.validation.rules.required, allowZero: false };
|
|
10
11
|
if (errorTextOrOptions !== undefined) {
|
|
11
12
|
if (typeof errorTextOrOptions === "string") {
|
|
12
13
|
options.errorText = errorTextOrOptions;
|
|
@@ -20,16 +21,14 @@ export function Required(errorTextOrOptions) {
|
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
23
|
export function EmailAddress(errorText) {
|
|
23
|
-
if (errorText === void 0) { errorText = "{0} is not a valid email address"; }
|
|
24
24
|
return function (type, propertyKey) {
|
|
25
|
-
var emailAddressRule = new Rules.EmailAddressRule(errorText);
|
|
25
|
+
var emailAddressRule = new Rules.EmailAddressRule(errorText !== null && errorText !== void 0 ? errorText : NeoStrings.validation.rules.emailAddress);
|
|
26
26
|
addRuleToType(type, propertyKey, emailAddressRule);
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
export function RegExp(expression, errorText) {
|
|
30
|
-
if (errorText === void 0) { errorText = "{0} is in an invalid format"; }
|
|
31
30
|
return function (type, propertyKey) {
|
|
32
|
-
var regExpRule = new Rules.RegExpRule(expression, errorText);
|
|
31
|
+
var regExpRule = new Rules.RegExpRule(expression, errorText !== null && errorText !== void 0 ? errorText : NeoStrings.validation.rules.regExp);
|
|
33
32
|
addRuleToType(type, propertyKey, regExpRule);
|
|
34
33
|
};
|
|
35
34
|
}
|
package/dist/Validation/Rules.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __extends } from "tslib";
|
|
2
2
|
import { RuleSeverity } from './ValidationState';
|
|
3
3
|
import { Utils } from '../Utils';
|
|
4
|
+
import NeoStrings from '../Localisation/NeoStrings';
|
|
4
5
|
var Rule = /** @class */ (function () {
|
|
5
6
|
function Rule() {
|
|
6
7
|
this.ruleId = Utils.uuidv4();
|
|
@@ -40,12 +41,12 @@ var StringLengthRule = /** @class */ (function (_super) {
|
|
|
40
41
|
var errorTextValue = this.errorText;
|
|
41
42
|
if (this.minLength && (!value || value.length < this.minLength)) {
|
|
42
43
|
if (!errorTextValue)
|
|
43
|
-
errorTextValue =
|
|
44
|
+
errorTextValue = NeoStrings.validation.rules.stringLengthLessThan;
|
|
44
45
|
context.addError(errorTextValue.format(propertyInstance.propertyInfo.readableName, this.minLength.toString(), this.maxLength.toString()));
|
|
45
46
|
}
|
|
46
47
|
else if (value && value.length > this.maxLength) {
|
|
47
48
|
if (!errorTextValue)
|
|
48
|
-
errorTextValue =
|
|
49
|
+
errorTextValue = NeoStrings.validation.rules.stringLengthMoreThan;
|
|
49
50
|
context.addError(errorTextValue.format(propertyInstance.propertyInfo.readableName, this.maxLength.toString()));
|
|
50
51
|
}
|
|
51
52
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { MenuUtils } from './Components/ContextMenu/MenuUtils';
|
|
|
12
12
|
import FileUtils from "./FileUtils";
|
|
13
13
|
import { runInTask } from './Components/TaskRunner/Decorators';
|
|
14
14
|
import { createProperty } from "./Model/PropertyInstance";
|
|
15
|
+
import NeoStrings from "./Localisation/NeoStrings";
|
|
15
16
|
import * as Attributes from './Model/Decorators';
|
|
16
17
|
import * as Rules from './Validation/Decorators';
|
|
17
18
|
import * as AppServices from './AppServices';
|
|
@@ -28,7 +29,7 @@ import * as SignalR from './SignalR';
|
|
|
28
29
|
import * as Validation from './Validation';
|
|
29
30
|
import * as Views from './Views/IViewBase';
|
|
30
31
|
declare const NotifyUtils: Components.INotificationHelper;
|
|
31
|
-
export { AppServices, Attributes, Components, Data, DateUtils, DebounceHelper, EnumHelper, FileUtils, JsonSchema, Localisation, List, MenuUtils, Misc, ModalUtils, Model, NeoModel, Network, NotifyUtils, NumberUtils, Routing, Rules, Security, SignalR, StringUtils, Validation, Views, };
|
|
32
|
+
export { AppServices, Attributes, Components, Data, DateUtils, DebounceHelper, EnumHelper, FileUtils, JsonSchema, Localisation, List, MenuUtils, Misc, ModalUtils, Model, NeoModel, NeoStrings, Network, NotifyUtils, NumberUtils, Routing, Rules, Security, SignalR, StringUtils, Validation, Views, };
|
|
32
33
|
export { runInTask, createProperty };
|
|
33
34
|
export { default as ModelBase } from './Model/ModelBase';
|
|
34
35
|
export { default as ValueObject } from './Model/ValueObject';
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { MenuUtils } from './Components/ContextMenu/MenuUtils';
|
|
|
13
13
|
import FileUtils from "./FileUtils";
|
|
14
14
|
import { runInTask } from './Components/TaskRunner/Decorators';
|
|
15
15
|
import { createProperty } from "./Model/PropertyInstance";
|
|
16
|
+
import NeoStrings from "./Localisation/NeoStrings";
|
|
16
17
|
// Namespaced exports from 1 file
|
|
17
18
|
import * as Attributes from './Model/Decorators';
|
|
18
19
|
import * as Rules from './Validation/Decorators';
|
|
@@ -33,7 +34,7 @@ import * as Views from './Views/IViewBase';
|
|
|
33
34
|
import { NotificationHelper } from './Components/Notifications/NotificationHelper';
|
|
34
35
|
var NotifyUtils = new NotificationHelper();
|
|
35
36
|
// Types
|
|
36
|
-
export { AppServices, Attributes, Components, Data, DateUtils, DebounceHelper, EnumHelper, FileUtils, JsonSchema, Localisation, List, MenuUtils, Misc, ModalUtils, Model, NeoModel, Network, NotifyUtils, NumberUtils, Routing, Rules, Security, SignalR, StringUtils, Validation, Views, };
|
|
37
|
+
export { AppServices, Attributes, Components, Data, DateUtils, DebounceHelper, EnumHelper, FileUtils, JsonSchema, Localisation, List, MenuUtils, Misc, ModalUtils, Model, NeoModel, NeoStrings, Network, NotifyUtils, NumberUtils, Routing, Rules, Security, SignalR, StringUtils, Validation, Views, };
|
|
37
38
|
// Functions
|
|
38
39
|
export { runInTask, createProperty };
|
|
39
40
|
export { default as ModelBase } from './Model/ModelBase';
|
package/package.json
CHANGED
package/CHANGELOG.md
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
# Breaking changes
|
|
4
|
-
|
|
5
|
-
## 0.10.65 (6 March 2023)
|
|
6
|
-
|
|
7
|
-
* `IErrorHandler` now requires the return type to be `Promise<IErrorDisplay>` instead of `IErrorDisplay`.
|
|
8
|
-
* Most of the protected methods in `ErrorHandler` have been changed to `async`.
|
|
9
|
-
* These changes were required in order to be able to read errors from axios blob responses.
|
|
10
|
-
|
|
11
|
-
# Change Log
|
|
12
|
-
|
|
13
|
-
## 0.10.65 (6 March 2023)
|
|
14
|
-
|
|
15
|
-
* Fixed error handler not parsing axios responses when response type is `blob`.
|