@singularsystems/neo-core 0.10.75 → 0.10.77
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/Data/Paging/PageManager.d.ts +10 -3
- package/dist/Data/Paging/PageManager.js +34 -15
- package/dist/Extensions.js +6 -1
- package/dist/JsonSchema/ClassMetadata.d.ts +2 -1
- package/dist/JsonSchema/ClassMetadata.js +14 -9
- package/dist/JsonSchema/MetadataBase.d.ts +8 -0
- package/dist/JsonSchema/MetadataBase.js +12 -0
- package/dist/JsonSchema/PropertyMetadata.d.ts +7 -3
- package/dist/JsonSchema/PropertyMetadata.js +15 -4
- package/dist/JsonSchema/TypeCache.js +1 -0
- package/dist/Model/BaseModels/UserEvent.js +6 -1
- package/dist/Settings.d.ts +2 -0
- package/dist/Settings.js +2 -0
- package/dist/Utils.d.ts +4 -0
- package/dist/Utils.js +11 -3
- package/package.json +4 -3
- package/dist/Model/IModelFieldInfo.d.ts +0 -0
- package/dist/Model/IModelFieldInfo.js +0 -0
|
@@ -82,7 +82,7 @@ export interface IPageManager {
|
|
|
82
82
|
/**
|
|
83
83
|
* Refresh the data only if the page manager has initialised.
|
|
84
84
|
*/
|
|
85
|
-
invalidateData(
|
|
85
|
+
invalidateData(): void;
|
|
86
86
|
/**
|
|
87
87
|
* Refresh the data by calling the api endpoint with the current criteria.
|
|
88
88
|
* This will not reset the page index, and will not update the total record count, therefore should only be called if your criteria has not changed since the last full fetch using refreshData().
|
|
@@ -101,6 +101,7 @@ export declare class PageManager<TCriteria extends ValueObject, TModel extends I
|
|
|
101
101
|
private _totalRecords;
|
|
102
102
|
private currentData;
|
|
103
103
|
private initialFetchState;
|
|
104
|
+
private isInvalidated;
|
|
104
105
|
/**
|
|
105
106
|
* Gets or sets the criteria.
|
|
106
107
|
*/
|
|
@@ -125,6 +126,8 @@ export declare class PageManager<TCriteria extends ValueObject, TModel extends I
|
|
|
125
126
|
* Called by the pager component on first display. Will fetch data if options.fetchInitial is set to true.
|
|
126
127
|
*/
|
|
127
128
|
initialise(): void;
|
|
129
|
+
/** Called after a bound ui component has rendered. Used to refetch data if invalidateData() was called. */
|
|
130
|
+
afterRender(): void;
|
|
128
131
|
/**
|
|
129
132
|
* Refresh the data by calling the api endpoint with the current criteria.
|
|
130
133
|
* Note: the page index will be reset to zero. Use this when your criteria has changed
|
|
@@ -133,9 +136,9 @@ export declare class PageManager<TCriteria extends ValueObject, TModel extends I
|
|
|
133
136
|
*/
|
|
134
137
|
refreshData(getCount?: boolean, taskRunner?: ITaskRunner): Promise<void>;
|
|
135
138
|
/**
|
|
136
|
-
* Refresh the data only if the page manager has initialised.
|
|
139
|
+
* Refresh the data only if the page manager has initialised, and is currently being rendered.
|
|
137
140
|
*/
|
|
138
|
-
invalidateData(
|
|
141
|
+
invalidateData(): void;
|
|
139
142
|
/**
|
|
140
143
|
* Refresh the data by calling the api endpoint with the current criteria.
|
|
141
144
|
* This will not reset the page index, and will not update the total record count, therefore should only be called if your criteria has not changed since the last full fetch using refreshData().
|
|
@@ -144,6 +147,10 @@ export declare class PageManager<TCriteria extends ValueObject, TModel extends I
|
|
|
144
147
|
refreshPage(taskRunner?: ITaskRunner): Promise<void>;
|
|
145
148
|
private fetchAndSetData;
|
|
146
149
|
setData(pageRecords: PartialPlainObject<TModel>[], totalRecords?: number): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Adds an item to the current page, and increments the total record count.
|
|
152
|
+
*/
|
|
153
|
+
addRecord(item: TModel | Model.PlainObject<TModel>): void;
|
|
147
154
|
/**
|
|
148
155
|
* Resets the page manager to its initial state and clears the current data.
|
|
149
156
|
*/
|
|
@@ -16,6 +16,7 @@ var PageManager = /** @class */ (function (_super) {
|
|
|
16
16
|
_this._totalRecords = -1;
|
|
17
17
|
_this.currentData = new List(_this.modelType);
|
|
18
18
|
_this.initialFetchState = "none";
|
|
19
|
+
_this.isInvalidated = false;
|
|
19
20
|
_this.options = options || {};
|
|
20
21
|
_this.allowSort = _this.options.allowSort !== false;
|
|
21
22
|
_this.performsRemoteSorting = true;
|
|
@@ -59,6 +60,7 @@ var PageManager = /** @class */ (function (_super) {
|
|
|
59
60
|
if (this.initialFetchState === "loading") {
|
|
60
61
|
return null;
|
|
61
62
|
}
|
|
63
|
+
void this.isInvalidated;
|
|
62
64
|
return this.initialFetchState === "complete";
|
|
63
65
|
},
|
|
64
66
|
enumerable: false,
|
|
@@ -126,10 +128,21 @@ var PageManager = /** @class */ (function (_super) {
|
|
|
126
128
|
PageManager.prototype.initialise = function () {
|
|
127
129
|
if (!this.hasInitialised) {
|
|
128
130
|
this.hasInitialised = true;
|
|
131
|
+
this.isInvalidated = false;
|
|
129
132
|
if (this.options.fetchInitial) {
|
|
130
133
|
this.refreshData(true, this.options.initialTaskRunner);
|
|
131
134
|
}
|
|
132
135
|
}
|
|
136
|
+
else {
|
|
137
|
+
this.afterRender();
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
/** Called after a bound ui component has rendered. Used to refetch data if invalidateData() was called. */
|
|
141
|
+
PageManager.prototype.afterRender = function () {
|
|
142
|
+
if (this.isInvalidated) {
|
|
143
|
+
this.isInvalidated = false;
|
|
144
|
+
this.refreshPage();
|
|
145
|
+
}
|
|
133
146
|
};
|
|
134
147
|
/**
|
|
135
148
|
* Refresh the data by calling the api endpoint with the current criteria.
|
|
@@ -167,22 +180,12 @@ var PageManager = /** @class */ (function (_super) {
|
|
|
167
180
|
});
|
|
168
181
|
};
|
|
169
182
|
/**
|
|
170
|
-
* Refresh the data only if the page manager has initialised.
|
|
183
|
+
* Refresh the data only if the page manager has initialised, and is currently being rendered.
|
|
171
184
|
*/
|
|
172
|
-
PageManager.prototype.invalidateData = function (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
case 0:
|
|
177
|
-
if (!this.hasInitialised) return [3 /*break*/, 2];
|
|
178
|
-
return [4 /*yield*/, this.refreshData(true, taskRunner)];
|
|
179
|
-
case 1:
|
|
180
|
-
_a.sent();
|
|
181
|
-
_a.label = 2;
|
|
182
|
-
case 2: return [2 /*return*/];
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
});
|
|
185
|
+
PageManager.prototype.invalidateData = function () {
|
|
186
|
+
if (this.hasInitialised) {
|
|
187
|
+
this.isInvalidated = true;
|
|
188
|
+
}
|
|
186
189
|
};
|
|
187
190
|
/**
|
|
188
191
|
* Refresh the data by calling the api endpoint with the current criteria.
|
|
@@ -254,6 +257,18 @@ var PageManager = /** @class */ (function (_super) {
|
|
|
254
257
|
});
|
|
255
258
|
});
|
|
256
259
|
};
|
|
260
|
+
/**
|
|
261
|
+
* Adds an item to the current page, and increments the total record count.
|
|
262
|
+
*/
|
|
263
|
+
PageManager.prototype.addRecord = function (item) {
|
|
264
|
+
this._totalRecords += 1;
|
|
265
|
+
if (item.meta) {
|
|
266
|
+
this.data.push(item);
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
this.data.push(this.modelType.fromJSObject(item));
|
|
270
|
+
}
|
|
271
|
+
};
|
|
257
272
|
/**
|
|
258
273
|
* Resets the page manager to its initial state and clears the current data.
|
|
259
274
|
*/
|
|
@@ -345,6 +360,10 @@ var PageManager = /** @class */ (function (_super) {
|
|
|
345
360
|
Observable(),
|
|
346
361
|
__metadata("design:type", String)
|
|
347
362
|
], PageManager.prototype, "initialFetchState", void 0);
|
|
363
|
+
__decorate([
|
|
364
|
+
Observable(),
|
|
365
|
+
__metadata("design:type", Object)
|
|
366
|
+
], PageManager.prototype, "isInvalidated", void 0);
|
|
348
367
|
PageManager = __decorate([
|
|
349
368
|
NeoModel,
|
|
350
369
|
__metadata("design:paramtypes", [Object, Function, Function, Object])
|
package/dist/Extensions.js
CHANGED
|
@@ -88,7 +88,12 @@ Array.prototype.sortBy = function (valueFnOrKey, direction, dataType) {
|
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
var array = this;
|
|
92
|
+
if (this.addNew) {
|
|
93
|
+
// Mobx6 doesn't allow the array to be sorted in place, must create a new one.
|
|
94
|
+
array = this.slice();
|
|
95
|
+
}
|
|
96
|
+
return array.sort(comparer);
|
|
92
97
|
};
|
|
93
98
|
Array.prototype.remove = function (item) {
|
|
94
99
|
var index = this.indexOf(item);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { PropertyMetadata } from './PropertyMetadata';
|
|
2
2
|
import { IJsonObjectType } from './JsonSchemaTypes';
|
|
3
3
|
import { ITypeCacheInternal } from './TypeCache';
|
|
4
|
-
|
|
4
|
+
import { MetadataBase } from './MetadataBase';
|
|
5
|
+
export declare class ClassMetadata extends MetadataBase {
|
|
5
6
|
name: string;
|
|
6
7
|
constructor(name: string);
|
|
7
8
|
/**
|
|
@@ -1,31 +1,36 @@
|
|
|
1
|
+
import { __extends } from "tslib";
|
|
1
2
|
import { TypeMetadata } from './TypeMetadata';
|
|
2
3
|
import { PropertyMetadata } from './PropertyMetadata';
|
|
3
|
-
|
|
4
|
+
import { MetadataBase } from './MetadataBase';
|
|
5
|
+
var ClassMetadata = /** @class */ (function (_super) {
|
|
6
|
+
__extends(ClassMetadata, _super);
|
|
4
7
|
function ClassMetadata(name) {
|
|
5
|
-
|
|
8
|
+
var _this = _super.call(this) || this;
|
|
9
|
+
_this.name = name;
|
|
6
10
|
/**
|
|
7
11
|
* All properties.
|
|
8
12
|
*/
|
|
9
|
-
|
|
13
|
+
_this.properties = [];
|
|
10
14
|
/**
|
|
11
15
|
* Properties excluding child objects and lists.
|
|
12
16
|
*/
|
|
13
|
-
|
|
17
|
+
_this.simpleProperties = [];
|
|
14
18
|
/**
|
|
15
19
|
* Properties containing child object types.
|
|
16
20
|
*/
|
|
17
|
-
|
|
21
|
+
_this.childObjectProperties = [];
|
|
18
22
|
/**
|
|
19
23
|
* Properties containing child list types.
|
|
20
24
|
*/
|
|
21
|
-
|
|
25
|
+
_this.childListProperties = [];
|
|
26
|
+
return _this;
|
|
22
27
|
}
|
|
23
28
|
ClassMetadata.prototype.loadMetaData = function (schema, cache) {
|
|
29
|
+
_super.prototype.loadFromSchema.call(this, schema);
|
|
24
30
|
for (var propertyKey in schema.properties) {
|
|
25
31
|
var propertySchema = schema.properties[propertyKey];
|
|
26
32
|
var propertyMetaData = new PropertyMetadata(propertyKey, TypeMetadata.create(propertySchema, cache));
|
|
27
|
-
propertyMetaData.
|
|
28
|
-
propertyMetaData.description = propertySchema.description;
|
|
33
|
+
propertyMetaData.loadFromSchema(propertySchema);
|
|
29
34
|
if (propertyMetaData.type.basicType !== "unknown") {
|
|
30
35
|
this.properties.push(propertyMetaData);
|
|
31
36
|
if (propertyMetaData.type.basicType === "array") {
|
|
@@ -49,5 +54,5 @@ var ClassMetadata = /** @class */ (function () {
|
|
|
49
54
|
return clone;
|
|
50
55
|
};
|
|
51
56
|
return ClassMetadata;
|
|
52
|
-
}());
|
|
57
|
+
}(MetadataBase));
|
|
53
58
|
export { ClassMetadata };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var MetadataBase = /** @class */ (function () {
|
|
2
|
+
function MetadataBase() {
|
|
3
|
+
}
|
|
4
|
+
MetadataBase.prototype.loadFromSchema = function (schema) {
|
|
5
|
+
this.title = schema.title;
|
|
6
|
+
this.description = schema.description;
|
|
7
|
+
this.ordinal = schema["x-ordinal"];
|
|
8
|
+
this.hidden = schema["x-hidden"];
|
|
9
|
+
};
|
|
10
|
+
return MetadataBase;
|
|
11
|
+
}());
|
|
12
|
+
export { MetadataBase };
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { IJsonSchemaDescriptorType } from './JsonSchemaTypes';
|
|
2
|
+
import { MetadataBase } from './MetadataBase';
|
|
1
3
|
import { TypeMetadata } from './TypeMetadata';
|
|
2
|
-
export declare class PropertyMetadata {
|
|
4
|
+
export declare class PropertyMetadata extends MetadataBase {
|
|
3
5
|
propertyName: string;
|
|
4
6
|
type: TypeMetadata;
|
|
5
7
|
constructor(propertyName: string, type: TypeMetadata);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
formatString?: string;
|
|
9
|
+
width?: number;
|
|
10
|
+
hAlign?: "left" | "center" | "right";
|
|
11
|
+
loadFromSchema(schema: IJsonSchemaDescriptorType): void;
|
|
8
12
|
}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
import { MetadataBase } from './MetadataBase';
|
|
3
|
+
var PropertyMetadata = /** @class */ (function (_super) {
|
|
4
|
+
__extends(PropertyMetadata, _super);
|
|
2
5
|
function PropertyMetadata(propertyName, type) {
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
var _this = _super.call(this) || this;
|
|
7
|
+
_this.propertyName = propertyName;
|
|
8
|
+
_this.type = type;
|
|
9
|
+
return _this;
|
|
5
10
|
}
|
|
11
|
+
PropertyMetadata.prototype.loadFromSchema = function (schema) {
|
|
12
|
+
_super.prototype.loadFromSchema.call(this, schema);
|
|
13
|
+
this.formatString = schema["x-formatString"];
|
|
14
|
+
this.width = schema["x-width"];
|
|
15
|
+
this.hAlign = schema["x-hAlign"];
|
|
16
|
+
};
|
|
6
17
|
return PropertyMetadata;
|
|
7
|
-
}());
|
|
18
|
+
}(MetadataBase));
|
|
8
19
|
export { PropertyMetadata };
|
|
@@ -20,6 +20,7 @@ var TypeCache = /** @class */ (function () {
|
|
|
20
20
|
enumerable: false,
|
|
21
21
|
configurable: true
|
|
22
22
|
});
|
|
23
|
+
// This is an internal method used by TypeMetadata
|
|
23
24
|
TypeCache.prototype.getOrAddType = function (name) {
|
|
24
25
|
if (name.startsWith("#/definitions/")) {
|
|
25
26
|
name = name.replace("#/definitions/", "");
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { __decorate, __extends } from "tslib";
|
|
1
|
+
import { __decorate, __extends, __metadata } from "tslib";
|
|
2
2
|
import ValueObject from '../ValueObject';
|
|
3
|
+
import { Date as DateAttribute } from '../Decorators';
|
|
3
4
|
import NeoModel from '../NeoModel';
|
|
4
5
|
var UserEventBase = /** @class */ (function (_super) {
|
|
5
6
|
__extends(UserEventBase, _super);
|
|
@@ -16,6 +17,10 @@ var UserEventBase = /** @class */ (function (_super) {
|
|
|
16
17
|
enumerable: false,
|
|
17
18
|
configurable: true
|
|
18
19
|
});
|
|
20
|
+
__decorate([
|
|
21
|
+
DateAttribute(),
|
|
22
|
+
__metadata("design:type", Object)
|
|
23
|
+
], UserEventBase.prototype, "on", void 0);
|
|
19
24
|
return UserEventBase;
|
|
20
25
|
}(ValueObject));
|
|
21
26
|
export { UserEventBase };
|
package/dist/Settings.d.ts
CHANGED
package/dist/Settings.js
CHANGED
package/dist/Utils.d.ts
CHANGED
|
@@ -61,6 +61,10 @@ export declare class Utils {
|
|
|
61
61
|
* Converts a string like 'user' to 'fa fa-user' or 'fa-user' to 'fa fa-user' or 'far-user' to 'far fa-user'
|
|
62
62
|
*/
|
|
63
63
|
static getFontAwesomeClass(faString: string): string;
|
|
64
|
+
static getFontAwesomeIconProps(faString: string): {
|
|
65
|
+
name: string;
|
|
66
|
+
isSolid: boolean | undefined;
|
|
67
|
+
};
|
|
64
68
|
/** Concatenates an array of strings together, putting spaces in-between them. */
|
|
65
69
|
static joinWithSpaces(arg0?: string, ...args: (string | undefined)[]): string;
|
|
66
70
|
/**
|
package/dist/Utils.js
CHANGED
|
@@ -115,15 +115,23 @@ var Utils = /** @class */ (function () {
|
|
|
115
115
|
* Converts a string like 'user' to 'fa fa-user' or 'fa-user' to 'fa fa-user' or 'far-user' to 'far fa-user'
|
|
116
116
|
*/
|
|
117
117
|
Utils.getFontAwesomeClass = function (faString) {
|
|
118
|
-
var
|
|
118
|
+
var props = this.getFontAwesomeIconProps(faString);
|
|
119
|
+
return (props.isSolid === false ? 'far ' : (props.isSolid === true ? 'fas ' : 'fa ')) + 'fa-' + props.name;
|
|
120
|
+
};
|
|
121
|
+
Utils.getFontAwesomeIconProps = function (faString) {
|
|
122
|
+
var isSolid;
|
|
119
123
|
if (faString.indexOf("fa-") === 0) {
|
|
120
124
|
faString = faString.substring(3);
|
|
121
125
|
}
|
|
122
126
|
else if (faString.indexOf("far-") === 0) {
|
|
123
|
-
|
|
127
|
+
isSolid = false;
|
|
128
|
+
faString = faString.substring(4);
|
|
129
|
+
}
|
|
130
|
+
else if (faString.indexOf("fas-") === 0) {
|
|
131
|
+
isSolid = true;
|
|
124
132
|
faString = faString.substring(4);
|
|
125
133
|
}
|
|
126
|
-
return
|
|
134
|
+
return { name: faString, isSolid: isSolid };
|
|
127
135
|
};
|
|
128
136
|
/** Concatenates an array of strings together, putting spaces in-between them. */
|
|
129
137
|
Utils.joinWithSpaces = function (arg0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularsystems/neo-core",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.77",
|
|
4
4
|
"description": "Core functionality for the Neo client library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc",
|
|
12
|
-
"test": "jest"
|
|
12
|
+
"test": "jest --runInBand"
|
|
13
13
|
},
|
|
14
14
|
"author": "Singular Systems",
|
|
15
15
|
"license": "ISC",
|
|
@@ -31,5 +31,6 @@
|
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"axios": ">=0.21.1",
|
|
33
33
|
"inversify": ">=5.0.1"
|
|
34
|
-
}
|
|
34
|
+
},
|
|
35
|
+
"packageManager": "yarn@3.6.1"
|
|
35
36
|
}
|
|
File without changes
|
|
File without changes
|