remult 3.2.2-next.2 → 3.2.3

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.
@@ -30,12 +30,14 @@ export interface FieldUIInfo {
30
30
  caption: string;
31
31
  type: FieldUIInfoType;
32
32
  inputType: string;
33
+ allowNull: boolean;
33
34
  relationToOne?: FieldRelationToOneInfo;
34
35
  }
35
36
  export interface FieldRelationToOneInfo extends RelationFields {
36
37
  entityKey: string;
37
38
  idField: string;
38
39
  captionField: string;
40
+ allowNull: boolean;
39
41
  where?: any;
40
42
  }
41
43
  export interface AdminEntitiesOptions {
@@ -65,7 +65,7 @@ function buildEntityInfo(options) {
65
65
  }
66
66
  }
67
67
  if (relRepo.metadata.apiReadAllowed) {
68
- relation = tslib_1.__assign(tslib_1.__assign({}, relInfo), { where: where, entityKey: relRepo.metadata.key, idField: idField_1, captionField: (_b = relRepo.metadata.fields
68
+ relation = tslib_1.__assign(tslib_1.__assign({}, relInfo), { allowNull: x.allowNull, where: where, entityKey: relRepo.metadata.key, idField: idField_1, captionField: (_b = relRepo.metadata.fields
69
69
  .toArray()
70
70
  .find(function (x) { return x.key != idField_1 && x.valueType == String; })) === null || _b === void 0 ? void 0 : _b.key });
71
71
  }
@@ -85,6 +85,7 @@ function buildEntityInfo(options) {
85
85
  caption: x.label,
86
86
  relationToOne: relation,
87
87
  inputType: x.inputType,
88
+ allowNull: x.allowNull,
88
89
  type: x.inputType === inputTypes_js_1.InputTypes.json
89
90
  ? 'json'
90
91
  : x.valueType === Number
@@ -6,7 +6,7 @@ import type { EntityOptions } from '../entity.js';
6
6
  import { Filter } from '../filter/filter-interfaces.js';
7
7
  import { type GroupByOptions, type GroupByResult, type ControllerRef, type ControllerRefForControllerBase, type EntityFilter, type EntityMetadata, type EntityOrderBy, type EntityRef, type EntityRefForEntityBase, type FieldRef, type FieldsMetadata, type FieldsRef, type FieldsRefForEntityBase, type FindFirstOptions, type FindFirstOptionsBase, type FindOptions, type IdMetadata, type LiveQuery, type LoadOptions, type MembersOnly, type NumericKeys, type Repository, type RepositoryRelations, type idType } from './remult3.js';
8
8
  import type { QueryOptions, RefSubscriber, UpsertOptions } from './remult3.js';
9
- import type { entityEventListener } from '../__EntityValueProvider.js';
9
+ import type { entityEventListener, packedRowInfo } from '../__EntityValueProvider.js';
10
10
  import { type DataProvider, type EntityDataProvider, type EntityDataProviderGroupByOptions, type EntityDataProviderFindOptions, type ErrorInfo, EntityError } from '../data-interfaces.js';
11
11
  import type { Unsubscribe } from '../live-query/SubscriptionChannel.js';
12
12
  import { RelationLoader } from './relation-loader.js';
@@ -136,6 +136,7 @@ export declare class rowHelperImplementation<T> extends rowHelperBase<T> impleme
136
136
  private repo;
137
137
  private edp;
138
138
  private _isNew;
139
+ _updateResultsFromServerAction(rowInfo: packedRowInfo): Promise<void>;
139
140
  constructor(info: EntityFullInfo<T>, instance: T, repo: RepositoryImplementation<T>, edp: EntityDataProvider, remult: Remult, _isNew: boolean, excludeRelationMembers?: Set<string>);
140
141
  repository: Repository<unknown>;
141
142
  clone(): T;
@@ -2273,6 +2273,24 @@ var rowHelperImplementation = /** @class */ (function (_super) {
2273
2273
  context_js_1.Remult.entityRefInit(_this, instance);
2274
2274
  return _this;
2275
2275
  }
2276
+ rowHelperImplementation.prototype._updateResultsFromServerAction = function (rowInfo) {
2277
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
2278
+ return tslib_1.__generator(this, function (_a) {
2279
+ switch (_a.label) {
2280
+ case 0: return [4 /*yield*/, this._updateEntityBasedOnApi(rowInfo.data, true)];
2281
+ case 1:
2282
+ _a.sent();
2283
+ if (this._isNew != rowInfo.isNewRow) {
2284
+ this._isNew = rowInfo.isNewRow;
2285
+ this.originalId = rowInfo.id;
2286
+ }
2287
+ if (!rowInfo.wasChanged)
2288
+ this.originalValues = this.copyDataToObject();
2289
+ return [2 /*return*/];
2290
+ }
2291
+ });
2292
+ });
2293
+ };
2276
2294
  rowHelperImplementation.prototype.clone = function () {
2277
2295
  var data = this.toApiJson(true, true);
2278
2296
  return this.repo.fromJson(data, this.isNew());
@@ -295,7 +295,7 @@ function BackendMethod(options) {
295
295
  reg(controllerOptions.key +
296
296
  '/' +
297
297
  ((options === null || options === void 0 ? void 0 : options.apiPrefix) ? options.apiPrefix + '/' : '') +
298
- key, options ? (_b = options.queue) !== null && _b !== void 0 ? _b : false : false, options.allowed, function (d, req, res) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
298
+ key, options ? ((_b = options.queue) !== null && _b !== void 0 ? _b : false) : false, options.allowed, function (d, req, res) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
299
299
  var allowed, remult_1, r_1, err_3;
300
300
  var _this = this;
301
301
  return tslib_1.__generator(this, function (_a) {
@@ -475,7 +475,7 @@ function BackendMethod(options) {
475
475
  http])];
476
476
  case 4:
477
477
  r = _k.sent();
478
- return [4 /*yield*/, defs._updateEntityBasedOnApi(r.rowInfo.data, true)];
478
+ return [4 /*yield*/, defs._updateResultsFromServerAction(r.rowInfo)];
479
479
  case 5:
480
480
  _k.sent();
481
481
  return [2 /*return*/, r.result];