@sumaris-net/ngx-components 2.8.3-beta23 → 2.8.3-beta25

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.
@@ -905,6 +905,15 @@ class DateUtils {
905
905
  const d2 = fromDateISOString(date2);
906
906
  return (!d1 && !d2) || (d1 && d1.isSame(d2, granularity));
907
907
  }
908
+ static compare(date1, date2, granularity) {
909
+ const d1 = fromDateISOString(date1);
910
+ const d2 = fromDateISOString(date2);
911
+ if ((!d1 && !d2) || d1?.isSame(d2, granularity))
912
+ return 0; // Equals
913
+ if (d1?.isAfter(d2, granularity))
914
+ return 1; // After
915
+ return -1; // Before
916
+ }
908
917
  /**
909
918
  * Create a copy of a date, without time fields (always return a new Moment object, or undefined).
910
919
  * Same implementation as the Java class Dates.resetTime() (see any SUMARiS like Pod)
@@ -28266,8 +28275,8 @@ class EntitiesTableDataSource extends TableDataSource {
28266
28275
  if (this._saving) {
28267
28276
  console.info(`[entities-table-datasource] Received ${this._entityName} data (from service), but still saving: skip`);
28268
28277
  }
28269
- else if (this.hasSomeEditingRow()) {
28270
- console.warn(`[entities-table-datasource] Received ${this._entityName} data, while some row still editing: skip; Please check save() implementation in the table!`);
28278
+ else if (this.hasSomeDirtyRow()) {
28279
+ console.warn(`[entities-table-datasource] Received ${this._entityName} data, while some row still dirty: skip; Please check save() implementation in the table!`);
28271
28280
  }
28272
28281
  else {
28273
28282
  this.updateDatasource((res.data || []));
@@ -28282,7 +28291,7 @@ class EntitiesTableDataSource extends TableDataSource {
28282
28291
  }
28283
28292
  updateDatasourceFromRows(rows) {
28284
28293
  // Avoid to update dataSourceSubject, when not need
28285
- if (this.datasourceSubject.observers?.length) {
28294
+ if (this.datasourceSubject.observed) {
28286
28295
  if (!this.config.suppressErrors)
28287
28296
  console.warn("[entities-table-datasource] Update datasource subject. Please prefer using 'rowsSubject' instead of 'datasourceSubject'");
28288
28297
  super.updateDatasourceFromRows(rows);
@@ -28494,6 +28503,9 @@ class EntitiesTableDataSource extends TableDataSource {
28494
28503
  hasSomeEditingRow() {
28495
28504
  return (this.rowsSubject.value || []).some((row) => row.editing);
28496
28505
  }
28506
+ hasSomeDirtyRow() {
28507
+ return (this.rowsSubject.value || []).some((row) => row.dirty);
28508
+ }
28497
28509
  async createNew(insertAt, opts = { editing: true }) {
28498
28510
  // Avoid multiple call (only one editing row is allowed)
28499
28511
  if (this._creating && opts.editing)
@@ -28526,8 +28538,8 @@ class EntitiesTableDataSource extends TableDataSource {
28526
28538
  async fetchMore(opts) {
28527
28539
  if (!this._fetchMoreFn)
28528
28540
  return false; // Avoid multiple call
28529
- if (this.hasSomeEditingRow()) {
28530
- console.warn(`Cannot fetch more ${this._entityName} because some row) still editing`);
28541
+ if (this.hasSomeDirtyRow()) {
28542
+ console.warn(`Cannot fetch more ${this._entityName} because some row) still dirty`);
28531
28543
  return;
28532
28544
  }
28533
28545
  console.debug(`Will fetching more row(s) still...`);
@@ -31504,8 +31516,8 @@ class EntitiesAsyncTableDataSource extends AsyncTableDataSource {
31504
31516
  if (this._saving) {
31505
31517
  console.info(`[entities-table-datasource] Received ${this._entityName} data (from service), but still saving: skip`);
31506
31518
  }
31507
- else if (this.hasSomeEditingRow()) {
31508
- console.warn(`[entities-table-datasource] Received ${this._entityName} data, while some row still editing: skip; Please check save() implementation in the table!`);
31519
+ else if (this.hasSomeDirtyRow()) {
31520
+ console.warn(`[entities-table-datasource] Received ${this._entityName} data, while some row still dirty: skip; Please check save() implementation in the table!`);
31509
31521
  }
31510
31522
  else {
31511
31523
  this.updateDatasource((res.data || []));
@@ -31520,7 +31532,7 @@ class EntitiesAsyncTableDataSource extends AsyncTableDataSource {
31520
31532
  }
31521
31533
  updateDatasourceFromRows(rows) {
31522
31534
  // Avoid to update dataSourceSubject, when not need
31523
- if (this.datasourceSubject.observers?.length) {
31535
+ if (this.datasourceSubject.observed) {
31524
31536
  if (!this.config.suppressErrors)
31525
31537
  console.warn("[entities-table-datasource] Update datasource subject. Please prefer using 'rowsSubject' instead of 'datasourceSubject'");
31526
31538
  super.updateDatasourceFromRows(rows);
@@ -31745,6 +31757,9 @@ class EntitiesAsyncTableDataSource extends AsyncTableDataSource {
31745
31757
  hasSomeEditingRow() {
31746
31758
  return this.getRows().some((row) => row.editing);
31747
31759
  }
31760
+ hasSomeDirtyRow() {
31761
+ return this.getRows().some((row) => row.dirty);
31762
+ }
31748
31763
  async createNew(insertAt, opts = { editing: true }) {
31749
31764
  // Avoid multiple call (only one editing row is allowed)
31750
31765
  if (this._creating && opts.editing)
@@ -31777,8 +31792,8 @@ class EntitiesAsyncTableDataSource extends AsyncTableDataSource {
31777
31792
  async fetchMore(opts) {
31778
31793
  if (!this._fetchMoreFn)
31779
31794
  return false; // Avoid multiple call
31780
- if (this.hasSomeEditingRow()) {
31781
- console.warn(`Cannot fetch more ${this._entityName} because some row) still editing`);
31795
+ if (this.hasSomeDirtyRow()) {
31796
+ console.warn(`Cannot fetch more ${this._entityName} because some row) still dirty`);
31782
31797
  return;
31783
31798
  }
31784
31799
  console.debug(`Will fetching more row(s) still...`);