@singularsystems/neo-core 0.10.76 → 0.10.78

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.
@@ -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(taskRunner?: ITaskRunner): Promise<void>;
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(taskRunner?: ITaskRunner): Promise<void>;
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 (taskRunner) {
173
- return __awaiter(this, void 0, void 0, function () {
174
- return __generator(this, function (_a) {
175
- switch (_a.label) {
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])
@@ -88,7 +88,12 @@ Array.prototype.sortBy = function (valueFnOrKey, direction, dataType) {
88
88
  }
89
89
  };
90
90
  }
91
- return this.sort(comparer);
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,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 };
@@ -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
- // Get user does not raise the onUserLoaded event, so we call it manually.
42
- this.onUserLoaded(user);
43
- }
44
- return [2 /*return*/, this.user];
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*/, 6];
108
+ return [3 /*break*/, 5];
106
109
  case 1:
107
- _a.trys.push([1, 5, , 6]);
110
+ _a.trys.push([1, 4, , 5]);
108
111
  return [4 /*yield*/, this.endSignIn()];
109
112
  case 2:
110
113
  redirectPath = _a.sent();
111
- if (!this.afterUserLoadedPromise) return [3 /*break*/, 4];
112
- return [4 /*yield*/, this.afterUserLoadedPromise];
114
+ return [4 /*yield*/, this.completeAfterUserLoaded()];
113
115
  case 3:
114
116
  _a.sent();
115
- this.afterUserLoadedPromise = undefined;
116
- _a.label = 4;
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*/, 6];
122
- case 6: return [2 /*return*/, new SignInResult(false, "")];
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
  };
@@ -20,6 +20,8 @@ export declare const Settings: {
20
20
  collapsed: any;
21
21
  sortAsc: any;
22
22
  sortDesc: any;
23
+ /** Icon used in back buttons */
24
+ backIcon: any;
23
25
  };
24
26
  /** Grid default settings */
25
27
  grid: {
package/dist/Settings.js CHANGED
@@ -19,6 +19,8 @@ export var Settings = {
19
19
  collapsed: "far-plus-square",
20
20
  sortAsc: "sort-up",
21
21
  sortDesc: "sort-down",
22
+ /** Icon used in back buttons */
23
+ backIcon: "arrow-left",
22
24
  },
23
25
  /** Grid default settings */
24
26
  grid: {
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 isRegular = false;
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
- isRegular = true;
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 (isRegular ? 'far ' : 'fa ') + 'fa-' + faString;
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.76",
3
+ "version": "0.10.78",
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