@sumaris-net/ngx-components 0.18.8 → 0.18.12

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.
@@ -10616,6 +10616,7 @@ const StatusList = Object.freeze([
10616
10616
  label: 'REFERENTIAL.STATUS_ENUM.TEMPORARY'
10617
10617
  }
10618
10618
  ]);
10619
+ const StatusById = Object.freeze(splitById(StatusList));
10619
10620
  //@dynamic
10620
10621
  class BaseReferential extends Entity {
10621
10622
  constructor(__typename) {
@@ -14240,7 +14241,6 @@ class InMemoryEntitiesService extends EntitiesService {
14240
14241
  // Detect rankOrder on the entity class
14241
14242
  id: (Object.getOwnPropertyNames(new dataType()).findIndex(key => key === 'rankOrder') !== -1) ? 'rankOrder' : undefined }, options.sortByReplacement);
14242
14243
  }
14243
- // TODO add test see sub-batches.modal.ts onLoadData & _hiddenData
14244
14244
  set value(data) {
14245
14245
  this.setValue(data);
14246
14246
  }
@@ -14272,61 +14272,67 @@ class InMemoryEntitiesService extends EntitiesService {
14272
14272
  }
14273
14273
  return this._onChange
14274
14274
  .pipe(filter(isNotNil), mergeMap((_) => __awaiter(this, void 0, void 0, function* () {
14275
- this._hiddenData = [];
14276
- if (isEmptyArray(this.data)) {
14277
- return { data: [], total: 0 };
14278
- }
14279
- // Apply sort
14280
- let data = this._sortFn(this.data || [], sortBy, sortDirection);
14281
- if (this._onLoad) {
14282
- const promiseOrData = this._onLoad(data);
14283
- data = ((promiseOrData instanceof Promise)) ? yield promiseOrData : promiseOrData;
14284
- }
14285
- // Apply filter (will update hiddenData)
14286
- data = this.filter(data, filterData, this._hiddenData);
14287
- // Compute the total length
14288
- const total = data.length;
14289
- // If page size=0 (e.g. only need total)
14290
- if (size === 0) {
14291
- this._hiddenData.push(...data);
14292
- return { data: [], total };
14293
- }
14294
- // Slice in a page (using offset and size)
14295
- if (offset > 0) {
14296
- // Offset after the end: no result
14297
- if (offset >= data.length) {
14298
- this._hiddenData.push(...data);
14299
- data = [];
14275
+ const excludedDataByFilter = [];
14276
+ let excludedDataByPagination;
14277
+ try {
14278
+ if (isEmptyArray(this.data)) {
14279
+ return { data: [], total: 0 };
14300
14280
  }
14301
- else {
14302
- const hiddenData = (size > 0 && ((offset + size) < data.length)) ?
14303
- // Slice using limit to size
14304
- data.slice(0, offset - 1).concat(data.slice(offset + size)) :
14305
- // Slice without limit
14306
- data.slice(0, offset - 1);
14307
- this._hiddenData.push(...hiddenData);
14308
- data = (size > 0 && ((offset + size) < data.length)) ?
14309
- // Slice using limit to size
14310
- data.slice(offset, offset + size) :
14311
- // Slice without limit
14312
- data.slice(offset);
14281
+ // Apply sort
14282
+ let data = this._sortFn(this.data || [], sortBy, sortDirection);
14283
+ if (this._onLoad) {
14284
+ const promiseOrData = this._onLoad(data);
14285
+ data = ((promiseOrData instanceof Promise)) ? yield promiseOrData : promiseOrData;
14313
14286
  }
14287
+ // Apply filter (will update hiddenData)
14288
+ data = this.filter(data, filterData, excludedDataByFilter);
14289
+ // Compute the total length
14290
+ const total = data.length;
14291
+ // If page size=0 (e.g. only need total)
14292
+ if (size === 0) {
14293
+ excludedDataByPagination = data;
14294
+ return { data: [], total };
14295
+ }
14296
+ // Slice in a page (using offset and size)
14297
+ if (offset > 0) {
14298
+ // Offset after the end: no result
14299
+ if (offset >= data.length) {
14300
+ excludedDataByPagination = data;
14301
+ data = [];
14302
+ }
14303
+ else {
14304
+ excludedDataByPagination = (size > 0 && ((offset + size) < data.length)) ?
14305
+ // Slice using limit to size
14306
+ data.slice(0, offset - 1).concat(data.slice(offset + size)) :
14307
+ // Slice without limit
14308
+ data.slice(0, offset - 1);
14309
+ data = (size > 0 && ((offset + size) < data.length)) ?
14310
+ // Slice using limit to size
14311
+ data.slice(offset, offset + size) :
14312
+ // Slice without limit
14313
+ data.slice(offset);
14314
+ }
14315
+ }
14316
+ // Apply a limit
14317
+ else if (size > 0) {
14318
+ excludedDataByPagination = data.slice(size);
14319
+ data = data.slice(0, size);
14320
+ }
14321
+ // No limit:
14322
+ else if (size === -1) {
14323
+ // Keep all data
14324
+ }
14325
+ // /!\ If already observed, then always create a copy of the original array
14326
+ // Because datasource will only update if the array changed
14327
+ if (data === this.data) {
14328
+ data = data.slice(0);
14329
+ }
14330
+ return { data, total };
14314
14331
  }
14315
- // Apply a limit
14316
- else if (size > 0) {
14317
- this._hiddenData.push(...data.slice(size));
14318
- data = data.slice(0, size);
14319
- }
14320
- // No limit:
14321
- else if (size === -1) {
14322
- // Keep all data
14323
- }
14324
- // /!\ If already observed, then always create a copy of the original array
14325
- // Because datasource will only update if the array changed
14326
- if (data === this.data) {
14327
- data = data.slice(0);
14332
+ finally {
14333
+ // Remember hidden data
14334
+ this._hiddenData = [...excludedDataByFilter, ...excludedDataByPagination];
14328
14335
  }
14329
- return { data, total };
14330
14336
  })));
14331
14337
  }
14332
14338
  saveAll(data, options) {
@@ -14349,10 +14355,12 @@ class InMemoryEntitiesService extends EntitiesService {
14349
14355
  return __awaiter(this, void 0, void 0, function* () {
14350
14356
  if (!this.data)
14351
14357
  throw new Error('[memory-service] Could not delete, because value not set');
14358
+ if (!this._equalsFn)
14359
+ throw new Error(`[memory-service] Could not delete, because no 'options.equals' has been set in the memory service`);
14352
14360
  // Remove deleted item, from data
14353
14361
  const updatedData = this.data.filter(entity => {
14354
- const shouldRemoved = dataToRemove.findIndex(entityToRemove => this._equalsFn(entityToRemove, entity)) !== -1;
14355
- return !shouldRemoved;
14362
+ const removed = dataToRemove.findIndex(entityToRemove => this._equalsFn(entityToRemove, entity)) !== -1;
14363
+ return !removed;
14356
14364
  });
14357
14365
  const deleteCount = this.data.length - updatedData.length;
14358
14366
  if (deleteCount > 0) {
@@ -15762,7 +15770,7 @@ function markAsUntouched(form, opts) {
15762
15770
  });
15763
15771
  }
15764
15772
  /**
15765
- * Wait end of async validation
15773
+ * Wait end of async validation (not pending)
15766
15774
  * return false
15767
15775
  */
15768
15776
  function waitWhilePending(form, opts) {
@@ -15775,7 +15783,7 @@ function waitWhilePending(form, opts) {
15775
15783
  * @param opts
15776
15784
  */
15777
15785
  function waitIdle(form, opts) {
15778
- const predicate = () => form.loading !== false;
15786
+ const predicate = () => form.loading !== true;
15779
15787
  return waitFor(predicate, opts);
15780
15788
  }
15781
15789
  function isControlHasInput(controls, controlName) {
@@ -22436,9 +22444,6 @@ AppEntityEditor.ctorParameters = () => [
22436
22444
  // @dynamic
22437
22445
  // eslint-disable-next-line @angular-eslint/directive-class-suffix
22438
22446
  class AppInMemoryTable extends AppTable {
22439
- /* get dirty(): boolean {
22440
- return this._dirty || this.memoryDataService.dirty;
22441
- }*/
22442
22447
  constructor(injector, columns, dataType, memoryDataService, validatorService, options, filter) {
22443
22448
  super(injector.get(ActivatedRoute), injector.get(Router), injector.get(Platform), injector.get(Location), injector.get(ModalController), injector.get(LocalSettingsService), columns, new EntitiesTableDataSource(dataType, memoryDataService, validatorService, options), filter, injector);
22444
22449
  this.injector = injector;
@@ -22465,10 +22470,8 @@ class AppInMemoryTable extends AppTable {
22465
22470
  this.setError(null);
22466
22471
  this.markForCheck();
22467
22472
  }
22468
- const firstCall = isEmptyArray(this.memoryDataService.value);
22469
- const emitRefreshEvent = firstCall || (opts && opts.emitEvent !== false);
22470
- this.memoryDataService.setValue(value, { emitEvent: !firstCall && !emitRefreshEvent });
22471
- if (emitRefreshEvent) {
22473
+ this.memoryDataService.value = value;
22474
+ if (!opts || opts.emitEvent !== false) {
22472
22475
  this.onRefresh.emit();
22473
22476
  }
22474
22477
  }
@@ -23345,9 +23348,9 @@ class UsersPage extends AppTable {
23345
23348
  this.cd = cd;
23346
23349
  this.canEdit = false;
23347
23350
  this.profiles = [...PRIORITIZED_AUTHORITIES].reverse();
23348
- this.statusList = StatusList;
23349
- this.statusById = splitById(StatusList);
23350
23351
  this.filterCriteriaCount = 0;
23352
+ this.statusList = StatusList;
23353
+ this.statusById = StatusById;
23351
23354
  this.referentialToString = referentialToString;
23352
23355
  this.inlineEdition = accountService.isAdmin(); // Allow inline edition only if admin
23353
23356
  this.canEdit = accountService.isAdmin();