@sumaris-net/ngx-components 0.27.20 → 0.28.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.
- package/bundles/sumaris-net.ngx-components.umd.js +94 -10
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/esm2015/src/app/core/form/form.class.js +2 -2
- package/esm2015/src/app/core/table/table.class.js +2 -2
- package/esm2015/src/app/shared/functions.js +55 -1
- package/esm2015/src/app/shared/pipes/ng-init.pipe.js +1 -1
- package/esm2015/src/app/shared/pipes/translate-context.pipe.js +34 -9
- package/esm2015/src/app/shared/services/translate-context.service.js +3 -3
- package/fesm2015/sumaris-net.ngx-components.js +92 -13
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/shared/functions.d.ts +14 -0
- package/src/app/shared/pipes/translate-context.pipe.d.ts +9 -4
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -731,6 +731,60 @@
|
|
|
731
731
|
return res;
|
|
732
732
|
}, {});
|
|
733
733
|
}
|
|
734
|
+
/**
|
|
735
|
+
* Determines if two objects or two values are equivalent.
|
|
736
|
+
*
|
|
737
|
+
* Two objects or values are considered equivalent if at least one of the following is true:
|
|
738
|
+
*
|
|
739
|
+
* * Both objects or values pass `===` comparison.
|
|
740
|
+
* * Both objects or values are of the same type and all of their properties are equal by
|
|
741
|
+
* comparing them with `equals`.
|
|
742
|
+
*
|
|
743
|
+
* @param o1 Object or value to compare.
|
|
744
|
+
* @param o2 Object or value to compare.
|
|
745
|
+
* @returns true if arguments are equal.
|
|
746
|
+
*/
|
|
747
|
+
function equals(o1, o2) {
|
|
748
|
+
if (o1 === o2)
|
|
749
|
+
return true;
|
|
750
|
+
if (o1 === null || o2 === null)
|
|
751
|
+
return false;
|
|
752
|
+
if (o1 !== o1 && o2 !== o2)
|
|
753
|
+
return true; // NaN === NaN
|
|
754
|
+
var t1 = typeof o1, t2 = typeof o2, length, key, keySet;
|
|
755
|
+
if (t1 == t2 && t1 == 'object') {
|
|
756
|
+
if (Array.isArray(o1)) {
|
|
757
|
+
if (!Array.isArray(o2))
|
|
758
|
+
return false;
|
|
759
|
+
if ((length = o1.length) == o2.length) {
|
|
760
|
+
for (key = 0; key < length; key++) {
|
|
761
|
+
if (!equals(o1[key], o2[key]))
|
|
762
|
+
return false;
|
|
763
|
+
}
|
|
764
|
+
return true;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
if (Array.isArray(o2)) {
|
|
769
|
+
return false;
|
|
770
|
+
}
|
|
771
|
+
keySet = Object.create(null);
|
|
772
|
+
for (key in o1) {
|
|
773
|
+
if (!equals(o1[key], o2[key])) {
|
|
774
|
+
return false;
|
|
775
|
+
}
|
|
776
|
+
keySet[key] = true;
|
|
777
|
+
}
|
|
778
|
+
for (key in o2) {
|
|
779
|
+
if (!(key in keySet) && typeof o2[key] !== 'undefined') {
|
|
780
|
+
return false;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
return true;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
return false;
|
|
787
|
+
}
|
|
734
788
|
var Beans = /** @class */ (function () {
|
|
735
789
|
function Beans() {
|
|
736
790
|
}
|
|
@@ -2800,7 +2854,7 @@
|
|
|
2800
2854
|
TranslateContextService.prototype.get = function (key, context, interpolateParams) {
|
|
2801
2855
|
var _this = this;
|
|
2802
2856
|
// No context: do a normal translate
|
|
2803
|
-
if (
|
|
2857
|
+
if (!isNil(context))
|
|
2804
2858
|
return this.translate.get(key, interpolateParams);
|
|
2805
2859
|
// Compute a contextual i18n key, using the context as suffix
|
|
2806
2860
|
var contextKey = this.contextualKey(key, context);
|
|
@@ -2847,15 +2901,43 @@
|
|
|
2847
2901
|
]; };
|
|
2848
2902
|
|
|
2849
2903
|
var TranslateContextPipe = /** @class */ (function () {
|
|
2850
|
-
function TranslateContextPipe(
|
|
2851
|
-
this.
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2904
|
+
function TranslateContextPipe(translate, _ref) {
|
|
2905
|
+
this.translate = translate;
|
|
2906
|
+
this._ref = _ref;
|
|
2907
|
+
this.value = '';
|
|
2908
|
+
this.lastKey = null;
|
|
2909
|
+
this.lastSuffix = null;
|
|
2910
|
+
this.lastParams = [];
|
|
2911
|
+
}
|
|
2912
|
+
TranslateContextPipe.prototype.transform = function (query) {
|
|
2913
|
+
var params = [];
|
|
2914
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2915
|
+
params[_i - 1] = arguments[_i];
|
|
2916
|
+
}
|
|
2917
|
+
if (!query || !query.length) {
|
|
2918
|
+
return query;
|
|
2919
|
+
}
|
|
2920
|
+
var suffix = params && params.length ? params[0] : '';
|
|
2921
|
+
params = suffix && params.slice(1);
|
|
2922
|
+
// if we ask another time for the same key, return the last value
|
|
2923
|
+
if (equalsOrNil(query, this.lastKey)
|
|
2924
|
+
&& equals(suffix, this.lastSuffix)
|
|
2925
|
+
&& equals(params, this.lastParams)) {
|
|
2926
|
+
return this.value;
|
|
2927
|
+
}
|
|
2928
|
+
// store the query, in case it changes
|
|
2929
|
+
this.lastKey = query;
|
|
2930
|
+
// store the params, in case they change
|
|
2931
|
+
this.lastParams = params;
|
|
2932
|
+
// store the params, in case they change
|
|
2933
|
+
this.lastSuffix = suffix;
|
|
2934
|
+
// set the value
|
|
2935
|
+
this.value = this.translate.instant(query, suffix, params);
|
|
2936
|
+
return this.value;
|
|
2855
2937
|
};
|
|
2856
2938
|
return TranslateContextPipe;
|
|
2857
2939
|
}());
|
|
2858
|
-
TranslateContextPipe.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function TranslateContextPipe_Factory() { return new TranslateContextPipe(i0__namespace.ɵɵinject(TranslateContextService)); }, token: TranslateContextPipe, providedIn: "root" });
|
|
2940
|
+
TranslateContextPipe.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function TranslateContextPipe_Factory() { return new TranslateContextPipe(i0__namespace.ɵɵinject(TranslateContextService), i0__namespace.ɵɵinject(i0__namespace.ChangeDetectorRef)); }, token: TranslateContextPipe, providedIn: "root" });
|
|
2859
2941
|
TranslateContextPipe.decorators = [
|
|
2860
2942
|
{ type: i0.Pipe, args: [{
|
|
2861
2943
|
name: 'translateContext'
|
|
@@ -2863,7 +2945,8 @@
|
|
|
2863
2945
|
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
2864
2946
|
];
|
|
2865
2947
|
TranslateContextPipe.ctorParameters = function () { return [
|
|
2866
|
-
{ type: TranslateContextService }
|
|
2948
|
+
{ type: TranslateContextService },
|
|
2949
|
+
{ type: i0.ChangeDetectorRef }
|
|
2867
2950
|
]; };
|
|
2868
2951
|
var TranslatablePipe = /** @class */ (function () {
|
|
2869
2952
|
function TranslatablePipe() {
|
|
@@ -19279,7 +19362,7 @@
|
|
|
19279
19362
|
}
|
|
19280
19363
|
};
|
|
19281
19364
|
AppForm.prototype.markAsReady = function (opts) {
|
|
19282
|
-
if (
|
|
19365
|
+
if (this._$ready.value !== true) {
|
|
19283
19366
|
this._$ready.next(true);
|
|
19284
19367
|
// If subclasses implements OnReady
|
|
19285
19368
|
if (typeof this['ngOnReady'] === 'function') {
|
|
@@ -23875,7 +23958,7 @@
|
|
|
23875
23958
|
};
|
|
23876
23959
|
AppTable.prototype.markAsReady = function (opts) {
|
|
23877
23960
|
if (this.readySubject.value !== true) {
|
|
23878
|
-
this.readySubject.next(
|
|
23961
|
+
this.readySubject.next(true);
|
|
23879
23962
|
// If subclasses implements OnReady
|
|
23880
23963
|
if (typeof this['ngOnReady'] === 'function') {
|
|
23881
23964
|
this.ngOnReady();
|
|
@@ -28259,6 +28342,7 @@
|
|
|
28259
28342
|
exports.disableControls = disableControls;
|
|
28260
28343
|
exports.emitPromiseEvent = emitPromiseEvent;
|
|
28261
28344
|
exports.entityToString = entityToString;
|
|
28345
|
+
exports.equals = equals;
|
|
28262
28346
|
exports.equalsOrNil = equalsOrNil;
|
|
28263
28347
|
exports.fadeInAnimation = fadeInAnimation;
|
|
28264
28348
|
exports.fadeInOutAnimation = fadeInOutAnimation;
|