@sumaris-net/ngx-components 1.0.9 → 1.2.0

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.
Files changed (28) hide show
  1. package/bundles/sumaris-net.ngx-components.umd.js +44 -24
  2. package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
  3. package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
  4. package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
  5. package/esm2015/src/app/core/form/editor.class.js +4 -2
  6. package/esm2015/src/app/core/form/entity-editor.class.js +1 -1
  7. package/esm2015/src/app/core/form/form.utils.js +2 -2
  8. package/esm2015/src/app/core/form/properties.form.js +2 -2
  9. package/esm2015/src/app/core/graphql/graphql.service.js +2 -2
  10. package/esm2015/src/app/core/services/base-graphql-service.class.js +3 -3
  11. package/esm2015/src/app/core/services/model/config.model.js +2 -2
  12. package/esm2015/src/app/core/services/model/entity.model.js +2 -2
  13. package/esm2015/src/app/core/services/pipes/department-to-string.pipe.js +2 -2
  14. package/esm2015/src/app/core/services/storage/entity-store.class.js +3 -3
  15. package/esm2015/src/app/shared/dates.js +9 -1
  16. package/esm2015/src/app/shared/form/field.component.js +2 -2
  17. package/esm2015/src/app/shared/functions.js +1 -1
  18. package/esm2015/src/app/shared/pipes/form.pipes.js +4 -4
  19. package/esm2015/src/app/shared/shared-routing.module.js +21 -11
  20. package/fesm2015/sumaris-net.ngx-components.js +44 -24
  21. package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
  22. package/package.json +1 -1
  23. package/src/app/shared/dates.d.ts +3 -1
  24. package/src/app/shared/shared-routing.module.d.ts +7 -0
  25. package/src/assets/i18n/en-US.json +26 -53
  26. package/src/assets/i18n/en.json +26 -53
  27. package/src/assets/i18n/fr.json +20 -51
  28. package/sumaris-net.ngx-components.metadata.json +1 -1
@@ -2489,6 +2489,14 @@
2489
2489
  DateUtils.max = function (date1, date2) {
2490
2490
  return !date1 ? date2 : (!date2 || date1.isSameOrAfter(date2) ? date1 : date2);
2491
2491
  };
2492
+ DateUtils.equals = function (date1, date2) {
2493
+ return DateUtils.isSame(date1, date2);
2494
+ };
2495
+ DateUtils.isSame = function (date1, date2, granularity) {
2496
+ var d1 = fromDateISOString(date1);
2497
+ var d2 = fromDateISOString(date2);
2498
+ return (!d1 && !d2) || d1.isSame(d2, granularity);
2499
+ };
2492
2500
  return DateUtils;
2493
2501
  }());
2494
2502
  function toDateISOString(value) {
@@ -3714,7 +3722,7 @@
3714
3722
  source = source.split('|');
3715
3723
  }
3716
3724
  // Skip if value is not an array
3717
- if (!(source instanceof Array) || control.length === 0) {
3725
+ if (!Array.isArray(source) || control.length === 0) {
3718
3726
  if (isNotEmptyArray(source))
3719
3727
  console.warn("WARN: please resize the FormArray '" + path + "' to the same length of the input array");
3720
3728
  return [];
@@ -4236,8 +4244,8 @@
4236
4244
  this.value = this.adapter.translateErrors(form, opts);
4237
4245
  this._ref.markForCheck();
4238
4246
  }
4239
- else if (isNotNilOrBlank(this.value)) {
4240
- this.value = '';
4247
+ else if (this.value !== undefined) {
4248
+ this.value = undefined;
4241
4249
  this._ref.markForCheck();
4242
4250
  }
4243
4251
  };
@@ -8656,7 +8664,7 @@
8656
8664
  };
8657
8665
  AppFormField.prototype.computeValuesFromToken = function (token) {
8658
8666
  var values = this.injector.get(token);
8659
- return values instanceof Array ? values : [];
8667
+ return Array.isArray(values) ? values : [];
8660
8668
  };
8661
8669
  AppFormField.prototype.checkAndResolveFormControl = function () {
8662
8670
  var _this = this;
@@ -9874,7 +9882,7 @@
9874
9882
  }, {});
9875
9883
  };
9876
9884
  EntityUtils.getMapAsArray = function (source) {
9877
- if (source instanceof Array)
9885
+ if (Array.isArray(source))
9878
9886
  return source;
9879
9887
  return Object.getOwnPropertyNames(source || {})
9880
9888
  .map(function (key) { return ({
@@ -12380,8 +12388,8 @@
12380
12388
  ])];
12381
12389
  case 1:
12382
12390
  res = _a.sent();
12383
- values = res[0] && res[0] instanceof Array ? res[0] : null;
12384
- ids = res[1] && res[1] instanceof Array ? res[1] : null;
12391
+ values = res[0] && Array.isArray(res[0]) ? res[0] : null;
12392
+ ids = res[1] && Array.isArray(res[1]) ? res[1] : null;
12385
12393
  migration = false;
12386
12394
  if (!this.isByIdMode) return [3 /*break*/, 5];
12387
12395
  if (!isNotNil(ids)) return [3 /*break*/, 3];
@@ -13979,7 +13987,7 @@
13979
13987
  .pipe(operators.catchError(function (error) { return _this.onApolloError(error, opts.error); }), operators.first()).toPromise()];
13980
13988
  case 5:
13981
13989
  res = _b.sent();
13982
- if (res.errors instanceof Array) {
13990
+ if (Array.isArray(res.errors)) {
13983
13991
  throw res.errors[0];
13984
13992
  }
13985
13993
  return [2 /*return*/, res.data];
@@ -14653,7 +14661,7 @@
14653
14661
  if (!queries.length)
14654
14662
  return;
14655
14663
  queries.forEach(function (query) {
14656
- if (opts.data instanceof Array) {
14664
+ if (Array.isArray(opts.data)) {
14657
14665
  // Filter values, if a filter function exists
14658
14666
  var data = query.insertFilterFn ? opts.data.filter(function (i) { return query.insertFilterFn(i); }) : opts.data;
14659
14667
  if (isNotEmptyArray(data)) {
@@ -14691,7 +14699,7 @@
14691
14699
  return;
14692
14700
  console.debug("[base-data-service] Removing data from watching queries: ", queries);
14693
14701
  return queries.map(function (query) {
14694
- if (opts.ids instanceof Array) {
14702
+ if (Array.isArray(opts.ids)) {
14695
14703
  return _this.graphql.removeFromCachedQueryByIds(cache, {
14696
14704
  query: query.query,
14697
14705
  variables: query.variables,
@@ -16089,7 +16097,7 @@
16089
16097
  this.comments = source.comments;
16090
16098
  this.creationDate = fromDateISOString(source.creationDate);
16091
16099
  this.statusId = source.statusId;
16092
- if (source.properties && source.properties instanceof Array) {
16100
+ if (source.properties && Array.isArray(source.properties)) {
16093
16101
  this.properties = EntityUtils.getPropertyArrayAsObject(source.properties);
16094
16102
  }
16095
16103
  else {
@@ -17703,20 +17711,30 @@
17703
17711
  function CustomReuseStrategy() {
17704
17712
  return _super !== null && _super.apply(this, arguments) || this;
17705
17713
  }
17714
+ /**
17715
+ * Force to reuse the route when:
17716
+ * - path change from [/new] -> [/:id]
17717
+ * - or path change from [/new] -> [/new?id=:id]
17718
+ * @param future
17719
+ * @param curr
17720
+ */
17706
17721
  CustomReuseStrategy.prototype.shouldReuseRoute = function (future, curr) {
17707
17722
  var result = _super.prototype.shouldReuseRoute.call(this, future, curr);
17708
- // Force to reuse the route when:
17709
- // - path change from [/new] -> [/:id]
17710
- // - or path change from [/new] -> [/new?id=:id]
17723
+ // Is sam route config
17711
17724
  if (!result && future.routeConfig && future.routeConfig === curr.routeConfig) {
17725
+ // Read the parameter name, where id is stored
17712
17726
  var pathIdParam = future.routeConfig.data && future.routeConfig.data.pathIdParam || 'id';
17713
- var futureId = future.params[pathIdParam] === 'new' ?
17714
- (future.queryParams[pathIdParam] || future.queryParams['id']) : future.params[pathIdParam];
17715
- var currId = curr.params[pathIdParam] === 'new' ?
17716
- (curr.queryParams[pathIdParam] || curr.queryParams['id']) : curr.params[pathIdParam];
17717
- return futureId === currId &&
17718
- // Always reload 'new' page
17719
- currId !== 'new';
17727
+ // Read the current route id
17728
+ var currId = curr.params[pathIdParam] === 'new'
17729
+ ? (curr.queryParams[pathIdParam] || curr.queryParams['id'] || 'new') // e.g. path like '/new/?id=<ID>'
17730
+ : curr.params[pathIdParam]; // e.g. path like '/<ID>'
17731
+ // Read the future route id
17732
+ var futureId = future.params[pathIdParam] === 'new'
17733
+ ? (future.queryParams[pathIdParam] || future.queryParams['id'] || 'new') // e.g. path like '/new/?id=<ID>'
17734
+ : future.params[pathIdParam]; // e.g. path like '/<ID>'
17735
+ // Reuse if same ID, but never when 'new' expected
17736
+ return futureId !== 'new' && currId !== 'new'
17737
+ && futureId === currId;
17720
17738
  }
17721
17739
  return result;
17722
17740
  };
@@ -21456,7 +21474,7 @@
21456
21474
  AppPropertiesForm.decorators = [
21457
21475
  { type: i0.Component, args: [{
21458
21476
  selector: 'app-properties-form',
21459
- template: "\n<!-- Properties -->\n<form [formGroup]=\"form\" class=\"form-container\">\n <ion-grid *ngIf=\"!loading; else propertiesSkeleton\"\n formArrayName=\"properties\" class=\"ion-no-padding\" >\n <ion-row class=\"ion-no-padding\">\n <ion-col class=\"ion-no-padding ion-align-self-end\" size=\"12\">\n <span class=\"toolbar-spacer\"></span>\n\n <!-- Show more options -->\n <ion-button color=\"light\" *ngIf=\"formArray?.length === 0\"\n [title]=\"'SETTINGS.BTN_SHOW_MORE_HELP'|translate\"\n (click)=\"helper.add()\">\n <ion-label translate>COMMON.BTN_SHOW_MORE</ion-label>\n <mat-icon slot=\"end\">arrow_drop_down</mat-icon>\n </ion-button>\n </ion-col>\n </ion-row>\n\n <ng-container *ngFor=\"let fieldForm of fieldForms; let i=index\">\n <ion-row class=\"ion-no-padding\" [formGroupName]=\"i\">\n\n <!-- property key -->\n <ion-col size=\"6\" class=\"ion-no-padding\">\n <mat-form-field floatLabel=\"never\">\n <mat-select [formControl]=\"fieldForm.controls.key\"\n [placeholder]=\"'SETTINGS.PROPERTY_KEY'|translate\"\n (selectionChange)=\"updateDefinitionAt(i)\"\n [tabindex]=\"20+i*2\"\n required>\n\n <!-- When option's key not a well known option, add it as first select option -->\n <mat-option *ngIf=\"isUnknownField(fieldForm)\" [value]=\"fieldForm.controls.key.value\">\n {{fieldForm.controls.key.value}}\n </mat-option>\n\n <mat-option *ngFor=\"let item of definitions\" [value]=\"item.key\">{{ item.label | translate }}\n </mat-option>\n\n </mat-select>\n\n <mat-error *ngIf=\"fieldForm.controls.key.hasError('required') && !helper.isLast(i)\"\n translate>ERROR.FIELD_REQUIRED\n </mat-error>\n </mat-form-field>\n </ion-col>\n\n <!-- property value -->\n <ion-col class=\"ion-no-padding\" padding-left >\n <app-form-field *ngIf=\"getDefinitionAt(i) else unknownValue; let definition; \"\n floatLabel=\"never\"\n [definition]=\"definition\"\n [formControl]=\"fieldForm.controls.value\"\n [placeholder]=\"'SETTINGS.PROPERTY_VALUE' | translate\"\n [required]=\"true\"\n [tabindex]=\"20+i*2 + 1\">\n </app-form-field>\n <ng-template #unknownValue>\n <mat-form-field floatLabel=\"never\">\n <input type=\"text\" matInput\n [placeholder]=\"'SETTINGS.PROPERTY_VALUE' | translate\"\n [formControl]=\"fieldForm.controls.value\"\n [required]=\"true\"\n [tabindex]=\"20+i*2 + 1\">\n </mat-form-field>\n </ng-template>\n </ion-col>\n\n <ion-col size=\"auto\" class=\"ion-no-padding\">\n <button type=\"button\" mat-icon-button color=\"light\"\n [disabled]=\"disabled\"\n [title]=\"'COMMON.BTN_DELETE'|translate\"\n (click)=\"removeAt(i)\">\n <mat-icon>close</mat-icon>\n </button>\n <button [hidden]=\"!helper.isLast(i)\"\n type=\"button\"\n mat-icon-button\n color=\"light\"\n [disabled]=\"disabled\"\n [title]=\"'CONFIGURATION.BTN_ADD_PROPERTY'|translate\"\n (click)=\"helper.add()\">\n <mat-icon>add</mat-icon>\n </button>\n </ion-col>\n </ion-row>\n </ng-container>\n </ion-grid>\n</form>\n\n<ng-template #propertiesSkeleton>\n\n <ion-grid class=\"ion-no-padding\">\n <ng-container *ngTemplateOutlet=\"propertyRowSkeleton\"></ng-container>\n <ng-container *ngTemplateOutlet=\"propertyRowSkeleton\"></ng-container>\n <ng-container *ngTemplateOutlet=\"propertyRowSkeleton\"></ng-container>\n </ion-grid>\n\n</ng-template>\n\n<ng-template #propertyRowSkeleton>\n\n <ion-row>\n <!-- property key -->\n <ion-col>\n <mat-form-field>\n <input matInput hidden>\n <ion-skeleton-text animated style=\"width: 60%\"></ion-skeleton-text>\n <ion-icon name=\"arrow-dropdown\" matSuffix></ion-icon>\n </mat-form-field>\n </ion-col>\n <!-- value -->\n <ion-col>\n <mat-form-field>\n <input matInput hidden>\n <ion-skeleton-text animated style=\"width: 60%\"></ion-skeleton-text>\n </mat-form-field>\n </ion-col>\n <!-- buttons -->\n <ion-col size=\"2\">\n <button type=\"button\" mat-icon-button color=\"light\"\n [disabled]=\"true\">\n <mat-icon>close</mat-icon>\n </button>\n </ion-col>\n </ion-row>\n\n</ng-template>\n",
21477
+ template: "\n<!-- Properties -->\n<form [formGroup]=\"form\" class=\"form-container\">\n <ion-grid *ngIf=\"!loading; else propertiesSkeleton\"\n formArrayName=\"properties\" class=\"ion-no-padding\" >\n <ion-row class=\"ion-no-padding\">\n <ion-col class=\"ion-no-padding ion-align-self-end\" size=\"12\">\n <span class=\"toolbar-spacer\"></span>\n\n <!-- Show more options -->\n <ion-button color=\"light\" *ngIf=\"formArray?.length === 0\"\n [title]=\"'SETTINGS.BTN_SHOW_MORE_HELP'|translate\"\n (click)=\"helper.add()\">\n <ion-label translate>COMMON.BTN_SHOW_MORE</ion-label>\n <mat-icon slot=\"end\">arrow_drop_down</mat-icon>\n </ion-button>\n </ion-col>\n </ion-row>\n\n <ng-container *ngFor=\"let fieldForm of fieldForms; let i=index\">\n <ion-row class=\"ion-no-padding\" [formGroupName]=\"i\">\n\n <!-- property key -->\n <ion-col size=\"6\" class=\"ion-no-padding\">\n <mat-form-field floatLabel=\"never\">\n <mat-select [formControl]=\"fieldForm.controls.key\"\n [placeholder]=\"'SETTINGS.PROPERTY_KEY'|translate\"\n (selectionChange)=\"updateDefinitionAt(i)\"\n [tabindex]=\"20+i*2\"\n required>\n\n <!-- When option's key not a well known option, add it as first select option -->\n <mat-option *ngIf=\"isUnknownField(fieldForm)\" [value]=\"fieldForm.controls.key.value\">\n {{fieldForm.controls.key.value}}\n </mat-option>\n\n <mat-option *ngFor=\"let item of definitions\" [value]=\"item.key\">{{ item.label | translate }}\n </mat-option>\n\n </mat-select>\n\n <mat-error *ngIf=\"fieldForm.controls.key.hasError('required') && !helper.isLast(i)\"\n translate>ERROR.FIELD_REQUIRED\n </mat-error>\n </mat-form-field>\n </ion-col>\n\n <!-- property value -->\n <ion-col class=\"ion-no-padding\" padding-left >\n <app-form-field *ngIf=\"getDefinitionAt(i) else unknownValue; let definition; \"\n floatLabel=\"never\"\n [definition]=\"definition\"\n [formControl]=\"fieldForm.controls.value\"\n [placeholder]=\"'SETTINGS.PROPERTY_VALUE' | translate\"\n [required]=\"true\"\n [tabindex]=\"20+i*2 + 1\">\n </app-form-field>\n <ng-template #unknownValue>\n <mat-form-field floatLabel=\"never\">\n <input type=\"text\" matInput\n [placeholder]=\"'SETTINGS.PROPERTY_VALUE' | translate\"\n [formControl]=\"fieldForm.controls.value\"\n [required]=\"true\"\n [tabindex]=\"20+i*2 + 1\">\n </mat-form-field>\n </ng-template>\n </ion-col>\n\n <ion-col size=\"auto\" class=\"ion-no-padding\">\n <button type=\"button\" mat-icon-button color=\"light\"\n [disabled]=\"disabled\"\n [title]=\"'COMMON.BTN_DELETE'|translate\"\n (click)=\"removeAt(i)\">\n <mat-icon>close</mat-icon>\n </button>\n <button [hidden]=\"!helper.isLast(i)\"\n type=\"button\"\n mat-icon-button\n color=\"light\"\n [disabled]=\"disabled\"\n [title]=\"'SETTINGS.BTN_ADD_PROPERTY'|translate\"\n (click)=\"helper.add()\">\n <mat-icon>add</mat-icon>\n </button>\n </ion-col>\n </ion-row>\n </ng-container>\n </ion-grid>\n</form>\n\n<ng-template #propertiesSkeleton>\n\n <ion-grid class=\"ion-no-padding\">\n <ng-container *ngTemplateOutlet=\"propertyRowSkeleton\"></ng-container>\n <ng-container *ngTemplateOutlet=\"propertyRowSkeleton\"></ng-container>\n <ng-container *ngTemplateOutlet=\"propertyRowSkeleton\"></ng-container>\n </ion-grid>\n\n</ng-template>\n\n<ng-template #propertyRowSkeleton>\n\n <ion-row>\n <!-- property key -->\n <ion-col>\n <mat-form-field>\n <input matInput hidden>\n <ion-skeleton-text animated style=\"width: 60%\"></ion-skeleton-text>\n <ion-icon name=\"arrow-dropdown\" matSuffix></ion-icon>\n </mat-form-field>\n </ion-col>\n <!-- value -->\n <ion-col>\n <mat-form-field>\n <input matInput hidden>\n <ion-skeleton-text animated style=\"width: 60%\"></ion-skeleton-text>\n </mat-form-field>\n </ion-col>\n <!-- buttons -->\n <ion-col size=\"2\">\n <button type=\"button\" mat-icon-button color=\"light\"\n [disabled]=\"true\">\n <mat-icon>close</mat-icon>\n </button>\n </ion-col>\n </ion-row>\n\n</ng-template>\n",
21460
21478
  changeDetection: i0.ChangeDetectionStrategy.OnPush
21461
21479
  },] }
21462
21480
  ];
@@ -22224,7 +22242,7 @@
22224
22242
  function DepartmentToStringPipe() {
22225
22243
  }
22226
22244
  DepartmentToStringPipe.prototype.transform = function (value, separator) {
22227
- if (value instanceof Array)
22245
+ if (Array.isArray(value))
22228
22246
  return departmentsToString(value, separator);
22229
22247
  return departmentToString(value);
22230
22248
  };
@@ -25816,10 +25834,12 @@
25816
25834
  var _a;
25817
25835
  if (this._loading) {
25818
25836
  this._loading = false;
25819
- if (!opts || opts.emitEvent !== false) {
25837
+ if (!opts || opts.onlySelf !== true) {
25820
25838
  // Emit to children forms
25821
25839
  // Tables should be changed by parent
25822
25840
  (_a = this.forms) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return c.markAsLoaded(opts); });
25841
+ }
25842
+ if (!opts || opts.emitEvent !== false) {
25823
25843
  this.markForCheck();
25824
25844
  }
25825
25845
  }