@sumaris-net/ngx-components 0.12.0 → 0.13.2

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.
@@ -10913,6 +10913,9 @@ class GraphqlService {
10913
10913
  get cache() {
10914
10914
  return this.apollo.client.cache;
10915
10915
  }
10916
+ get defaultFetchPolicy() {
10917
+ return this._defaultFetchPolicy;
10918
+ }
10916
10919
  ready() {
10917
10920
  if (this._started)
10918
10921
  return Promise.resolve();
@@ -11635,7 +11638,15 @@ class BaseGraphqlService {
11635
11638
  this._logPrefix = `[base-graphql-service] `;
11636
11639
  }
11637
11640
  mutableWatchQuery(opts) {
11641
+ opts.fetchPolicy = opts.fetchPolicy || this.graphql.defaultFetchPolicy;
11642
+ // Standard query (no cache)
11643
+ if (opts.fetchPolicy === 'no-cache') {
11644
+ return this.graphql.watchQuery(opts);
11645
+ }
11646
+ // No arrayFieldName
11638
11647
  if (!opts.arrayFieldName) {
11648
+ if (this._debug)
11649
+ console.warn(this._logPrefix + '̀Missing \'opts.arrayFieldName\' : unable to create a mutable watch query');
11639
11650
  return this.graphql.watchQuery(opts);
11640
11651
  }
11641
11652
  // Create the query id
@@ -11649,8 +11660,9 @@ class BaseGraphqlService {
11649
11660
  queryRef = mutableQuery.queryRef;
11650
11661
  if (this._debug)
11651
11662
  console.debug(this._logPrefix + `Find same mutable watch query (same variables) {${queryId}}. Skip register`);
11652
- // Refetch if need
11653
- if (opts.fetchPolicy && (opts.fetchPolicy === 'network-only' || opts.fetchPolicy === 'no-cache' || opts.fetchPolicy === 'cache-and-network')) {
11663
+ // Refetch if need data from network
11664
+ if (opts.fetchPolicy === 'network-only' || opts.fetchPolicy === 'cache-and-network') {
11665
+ console.warn(this._logPrefix + ' Mutable query already exists, and fetchPolicy=' + opts.fetchPolicy + '. Force refetch query...');
11654
11666
  queryRef.refetch(mutableQuery.variables);
11655
11667
  }
11656
11668
  //if (mutableQuery.counter > 3) {
@@ -11665,6 +11677,7 @@ class BaseGraphqlService {
11665
11677
  queryRef,
11666
11678
  variables: opts.variables,
11667
11679
  arrayFieldName: opts.arrayFieldName,
11680
+ totalFieldName: opts.totalFieldName,
11668
11681
  insertFilterFn: opts.insertFilterFn,
11669
11682
  sortFn: opts.sortFn,
11670
11683
  counter: 1
@@ -11687,6 +11700,7 @@ class BaseGraphqlService {
11687
11700
  query: query.query,
11688
11701
  variables: query.variables,
11689
11702
  arrayFieldName: query.arrayFieldName,
11703
+ totalFieldName: query.totalFieldName,
11690
11704
  sortFn: query.sortFn,
11691
11705
  data
11692
11706
  });
@@ -11700,6 +11714,7 @@ class BaseGraphqlService {
11700
11714
  query: query.query,
11701
11715
  variables: query.variables,
11702
11716
  arrayFieldName: query.arrayFieldName,
11717
+ totalFieldName: query.totalFieldName,
11703
11718
  sortFn: query.sortFn,
11704
11719
  data: opts.data
11705
11720
  });
@@ -11717,6 +11732,7 @@ class BaseGraphqlService {
11717
11732
  query: query.query,
11718
11733
  variables: query.variables,
11719
11734
  arrayFieldName: query.arrayFieldName,
11735
+ totalFieldName: query.totalFieldName,
11720
11736
  ids: opts.ids
11721
11737
  });
11722
11738
  }
@@ -11725,6 +11741,7 @@ class BaseGraphqlService {
11725
11741
  query: query.query,
11726
11742
  variables: query.variables,
11727
11743
  arrayFieldName: query.arrayFieldName,
11744
+ totalFieldName: query.totalFieldName,
11728
11745
  ids: opts.ids
11729
11746
  }) ? 1 : 0;
11730
11747
  }
@@ -17142,7 +17159,7 @@ class FormButtonsBarComponent {
17142
17159
  FormButtonsBarComponent.decorators = [
17143
17160
  { type: Component, args: [{
17144
17161
  selector: 'app-form-buttons-bar',
17145
- template: "<ion-toolbar [class]=\"classList\">\n <ion-row class=\"ion-no-padding\" nowrap>\n <ion-col>\n <ng-content></ng-content>\n </ion-col>\n\n <ion-col size=\"auto\">\n\n <ion-button fill=\"clear\" color=\"dark\" (click)=\"onBack.emit($event)\" (keyup.enter)=\"onBack.emit($event)\" *ngIf=\"onBack.observers.length\">\n <ion-label translate>COMMON.BTN_CLOSE</ion-label>\n </ion-button>\n\n <ion-button fill=\"clear\" color=\"dark\" (click)=\"onCancel.emit($event)\" (keyup.enter)=\"onCancel.emit($event)\" [disabled]=\"disabledCancel\">\n <ion-icon slot=\"start\" name=\"refresh\"></ion-icon>\n <ion-label translate>COMMON.BTN_RESET</ion-label>\n </ion-button>\n\n\n <ion-button fill=\"solid\" (click)=\"onNext.emit($event)\" (keyup.enter)=\"onNext.emit($event)\" *ngIf=\"onNext.observers.length\">\n <ion-label translate>COMMON.BTN_NEXT</ion-label>\n <ion-icon slot=\"end\" name=\"arrow-forward\"></ion-icon>\n </ion-button>\n\n <ion-button [fill]=\"disabled? 'clear' : 'solid'\" (click)=\"onSave.emit($event)\" (keyup.enter)=\"onSave.emit($event)\" color=\"danger\" [disabled]=\"disabled\">\n <ion-label [innerHTML]=\"'COMMON.BTN_SAVE_WITH_SHORTCUT'|translate\" [title]=\"'COMMON.BTN_SAVE_WITH_SHORTCUT_HELP'|translate\"></ion-label>\n </ion-button>\n </ion-col>\n </ion-row>\n</ion-toolbar>\n",
17162
+ template: "<ion-toolbar [class]=\"classList\">\n <ion-row class=\"ion-no-padding\" nowrap>\n <ion-col>\n <ng-content></ng-content>\n </ion-col>\n\n <ion-col size=\"auto\">\n\n <!-- close (go back) -->\n <ion-button fill=\"clear\" color=\"dark\" (click)=\"onBack.emit($event)\" (keyup.enter)=\"onBack.emit($event)\" *ngIf=\"onBack.observers | isNotEmptyArray\">\n <ion-label translate>COMMON.BTN_CLOSE</ion-label>\n </ion-button>\n\n <!-- reload -->\n <ion-button fill=\"clear\" color=\"dark\" (click)=\"onCancel.emit($event)\" (keyup.enter)=\"onCancel.emit($event)\" [disabled]=\"disabledCancel\">\n <ion-icon slot=\"start\" name=\"refresh\"></ion-icon>\n <ion-label translate>COMMON.BTN_RESET</ion-label>\n </ion-button>\n\n <!-- next -->\n <ion-button fill=\"solid\" (click)=\"onNext.emit($event)\" (keyup.enter)=\"onNext.emit($event)\" *ngIf=\"onNext.observers | isNotEmptyArray\">\n <ion-label translate>COMMON.BTN_NEXT</ion-label>\n <ion-icon slot=\"end\" name=\"arrow-forward\"></ion-icon>\n </ion-button>\n\n <!-- save -->\n <ion-button [fill]=\"disabled ? 'clear' : 'solid'\" (click)=\"onSave.emit($event)\" (keyup.enter)=\"onSave.emit($event)\" color=\"danger\"\n [disabled]=\"disabled\">\n <ion-label [innerHTML]=\"'COMMON.BTN_SAVE_WITH_SHORTCUT'|translate\" [title]=\"'COMMON.BTN_SAVE_WITH_SHORTCUT_HELP'|translate\"></ion-label>\n </ion-button>\n </ion-col>\n </ion-row>\n</ion-toolbar>\n",
17146
17163
  providers: [
17147
17164
  { provide: FormButtonsBarToken, useExisting: FormButtonsBarComponent }
17148
17165
  ],
@@ -20152,14 +20169,14 @@ class AppTable {
20152
20169
  return true;
20153
20170
  }
20154
20171
  save(opts) {
20155
- var _a;
20156
20172
  return __awaiter(this, void 0, void 0, function* () {
20173
+ opts = Object.assign({ keepEditing: this.keepEditedRowOnSave }, opts);
20157
20174
  if (this.readOnly) {
20158
20175
  throw { code: ErrorCodes$2.TABLE_READ_ONLY, message: 'ERROR.TABLE_READ_ONLY' };
20159
20176
  }
20160
20177
  this.resetError();
20161
20178
  // Keep edited row id (should be done BEFORE confirmEditCreate() )
20162
- const editedRowId = toBoolean(opts === null || opts === void 0 ? void 0 : opts.keepEditing, this.keepEditedRowOnSave) && ((_a = this.editedRow) === null || _a === void 0 ? void 0 : _a.editing) && this.editedRow.id;
20179
+ const editedRowId = opts.keepEditing && this.editedRow && this.editedRow.editing && this.editedRow.id;
20163
20180
  if (!this.confirmEditCreate()) {
20164
20181
  throw { code: ErrorCodes$2.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
20165
20182
  }
@@ -20361,7 +20378,7 @@ class AppTable {
20361
20378
  return false;
20362
20379
  }
20363
20380
  // DEBUG
20364
- console.debug("[table] Detect click on row");
20381
+ //console.debug("[table] Detect click on row");
20365
20382
  if (row.id === -1 || row.editing)
20366
20383
  return true; // Already in edition
20367
20384
  if (event === null || event === void 0 ? void 0 : event.defaultPrevented)
@@ -21093,6 +21110,9 @@ class AppTabEditor {
21093
21110
  this.registerSubscription(this.formButtonsBar.onBack.subscribe(event => this.onBackClick(event)));
21094
21111
  }
21095
21112
  }
21113
+ ngAfterViewInit() {
21114
+ // Can be override by subclasses
21115
+ }
21096
21116
  ngOnDestroy() {
21097
21117
  this._subscription.unsubscribe();
21098
21118
  }
@@ -21592,6 +21612,7 @@ class AppEntityEditor extends AppTabEditor {
21592
21612
  this.disable();
21593
21613
  }
21594
21614
  ngAfterViewInit() {
21615
+ super.ngAfterViewInit();
21595
21616
  // Load data
21596
21617
  if (this._autoLoad) {
21597
21618
  setTimeout(() => this.loadFromRoute(), this._autoLoadDelay);