@sumaris-net/ngx-components 1.20.4 → 1.20.7
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 +86 -51
- 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/doc/changelog.md +6 -0
- package/esm2015/src/app/shared/file/csv.utils.js +5 -25
- package/esm2015/src/app/shared/file/file.utils.js +30 -1
- package/esm2015/src/app/shared/pipes/form.pipes.js +21 -24
- package/esm2015/src/app/shared/pipes/property.pipes.js +29 -5
- package/fesm2015/sumaris-net.ngx-components.js +78 -51
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/shared/file/csv.utils.d.ts +1 -0
- package/src/app/shared/file/file.utils.d.ts +5 -0
- package/src/app/shared/pipes/form.pipes.d.ts +1 -1
- package/src/app/shared/pipes/property.pipes.d.ts +11 -3
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -4719,10 +4719,9 @@
|
|
|
4719
4719
|
* Clean any existing subscription to change events
|
|
4720
4720
|
*/
|
|
4721
4721
|
FormErrorTranslatePipe.prototype._dispose = function () {
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
}
|
|
4722
|
+
var _a;
|
|
4723
|
+
(_a = this._onFormStatusChanges) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
4724
|
+
this._onFormStatusChanges = undefined;
|
|
4726
4725
|
};
|
|
4727
4726
|
return FormErrorTranslatePipe;
|
|
4728
4727
|
}());
|
|
@@ -4815,23 +4814,24 @@
|
|
|
4815
4814
|
this.value = control === null || control === void 0 ? void 0 : control.value;
|
|
4816
4815
|
// if there is a subscription to onLangChange, clean it
|
|
4817
4816
|
this._dispose();
|
|
4818
|
-
|
|
4819
|
-
|
|
4817
|
+
if (control) {
|
|
4818
|
+
// subscribe to valueChanges event
|
|
4820
4819
|
this._onControlValueChanges = control.valueChanges.subscribe(function (value) {
|
|
4821
4820
|
if (value !== _this.value) {
|
|
4822
4821
|
_this.value = value;
|
|
4823
4822
|
_this._ref.markForCheck();
|
|
4824
4823
|
}
|
|
4825
4824
|
});
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4825
|
+
// subscribe to statusChanges event
|
|
4826
|
+
if (listenStatusChanges) {
|
|
4827
|
+
this._onControlStatusChanges = control.statusChanges.subscribe(function (status) {
|
|
4828
|
+
var value = control.value;
|
|
4829
|
+
if (value !== _this.value) {
|
|
4830
|
+
_this.value = value;
|
|
4831
|
+
_this._ref.markForCheck();
|
|
4832
|
+
}
|
|
4833
|
+
});
|
|
4834
|
+
}
|
|
4835
4835
|
}
|
|
4836
4836
|
return this.value;
|
|
4837
4837
|
};
|
|
@@ -4842,14 +4842,11 @@
|
|
|
4842
4842
|
* Clean any existing subscription to change events
|
|
4843
4843
|
*/
|
|
4844
4844
|
FormGetValuePipe.prototype._dispose = function () {
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
this._onControlStatusChanges.unsubscribe();
|
|
4851
|
-
this._onControlStatusChanges = undefined;
|
|
4852
|
-
}
|
|
4845
|
+
var _a, _b;
|
|
4846
|
+
(_a = this._onControlValueChanges) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
4847
|
+
this._onControlValueChanges = undefined;
|
|
4848
|
+
(_b = this._onControlStatusChanges) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
4849
|
+
this._onControlStatusChanges = undefined;
|
|
4853
4850
|
};
|
|
4854
4851
|
return FormGetValuePipe;
|
|
4855
4852
|
}());
|
|
@@ -4882,9 +4879,14 @@
|
|
|
4882
4879
|
},] }
|
|
4883
4880
|
];
|
|
4884
4881
|
var PropertyFormatPipe = /** @class */ (function () {
|
|
4885
|
-
function PropertyFormatPipe(dateFormat) {
|
|
4882
|
+
function PropertyFormatPipe(dateFormat, translate) {
|
|
4886
4883
|
this.dateFormat = dateFormat;
|
|
4884
|
+
this.translate = translate;
|
|
4887
4885
|
}
|
|
4886
|
+
PropertyFormatPipe.prototype.ngOnDestroy = function () {
|
|
4887
|
+
var _a;
|
|
4888
|
+
(_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
4889
|
+
};
|
|
4888
4890
|
PropertyFormatPipe.prototype.transform = function (obj, keyOrDefinition) {
|
|
4889
4891
|
var _a, _b;
|
|
4890
4892
|
if (!obj)
|
|
@@ -4917,16 +4919,40 @@
|
|
|
4917
4919
|
if ((_a = definition.autocomplete) === null || _a === void 0 ? void 0 : _a.displayWith) {
|
|
4918
4920
|
return definition.autocomplete.displayWith(value);
|
|
4919
4921
|
}
|
|
4920
|
-
return joinPropertiesPath(
|
|
4922
|
+
return joinPropertiesPath(value, ((_b = definition.autocomplete) === null || _b === void 0 ? void 0 : _b.attributes) || ['label', 'name']) || undefined;
|
|
4921
4923
|
}
|
|
4924
|
+
case 'boolean':
|
|
4925
|
+
return (obj === 1 || obj === true || obj === 'true') ? this.i18nYes : this.i18nNo;
|
|
4926
|
+
case 'integer':
|
|
4927
|
+
case 'double':
|
|
4922
4928
|
case 'string':
|
|
4923
4929
|
default:
|
|
4924
4930
|
return value;
|
|
4925
4931
|
}
|
|
4926
4932
|
};
|
|
4933
|
+
Object.defineProperty(PropertyFormatPipe.prototype, "i18nYes", {
|
|
4934
|
+
get: function () {
|
|
4935
|
+
if (!this._i18nYes) {
|
|
4936
|
+
this._i18nYes = this.translate.instant('COMMON.YES');
|
|
4937
|
+
}
|
|
4938
|
+
return this._i18nYes;
|
|
4939
|
+
},
|
|
4940
|
+
enumerable: false,
|
|
4941
|
+
configurable: true
|
|
4942
|
+
});
|
|
4943
|
+
Object.defineProperty(PropertyFormatPipe.prototype, "i18nNo", {
|
|
4944
|
+
get: function () {
|
|
4945
|
+
if (!this._i18nNo) {
|
|
4946
|
+
this._i18nNo = this.translate.instant('COMMON.NO');
|
|
4947
|
+
}
|
|
4948
|
+
return this._i18nNo;
|
|
4949
|
+
},
|
|
4950
|
+
enumerable: false,
|
|
4951
|
+
configurable: true
|
|
4952
|
+
});
|
|
4927
4953
|
return PropertyFormatPipe;
|
|
4928
4954
|
}());
|
|
4929
|
-
PropertyFormatPipe.ɵprov = i0.ɵɵdefineInjectable({ factory: function PropertyFormatPipe_Factory() { return new PropertyFormatPipe(i0.ɵɵinject(DateFormatPipe)); }, token: PropertyFormatPipe, providedIn: "root" });
|
|
4955
|
+
PropertyFormatPipe.ɵprov = i0.ɵɵdefineInjectable({ factory: function PropertyFormatPipe_Factory() { return new PropertyFormatPipe(i0.ɵɵinject(DateFormatPipe), i0.ɵɵinject(i1$2.TranslateService)); }, token: PropertyFormatPipe, providedIn: "root" });
|
|
4930
4956
|
PropertyFormatPipe.decorators = [
|
|
4931
4957
|
{ type: i0.Pipe, args: [{
|
|
4932
4958
|
name: 'propertyFormat'
|
|
@@ -4934,7 +4960,8 @@
|
|
|
4934
4960
|
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
4935
4961
|
];
|
|
4936
4962
|
PropertyFormatPipe.ctorParameters = function () { return [
|
|
4937
|
-
{ type: DateFormatPipe }
|
|
4963
|
+
{ type: DateFormatPipe },
|
|
4964
|
+
{ type: i1$2.TranslateService }
|
|
4938
4965
|
]; };
|
|
4939
4966
|
|
|
4940
4967
|
var SharedPipesModule = /** @class */ (function () {
|
|
@@ -18326,6 +18353,34 @@
|
|
|
18326
18353
|
reader.readAsText(file, encoding);
|
|
18327
18354
|
return $progress.asObservable();
|
|
18328
18355
|
};
|
|
18356
|
+
FilesUtils.writeTextToFile = function (content, opts) {
|
|
18357
|
+
if (isNilOrBlank(content))
|
|
18358
|
+
return; // Skip if empty
|
|
18359
|
+
var filename = (opts === null || opts === void 0 ? void 0 : opts.filename) || 'export.txt';
|
|
18360
|
+
var charset = ((opts === null || opts === void 0 ? void 0 : opts.encoding) || 'utf-8').toLowerCase();
|
|
18361
|
+
var type = (opts === null || opts === void 0 ? void 0 : opts.type) || 'text/plain';
|
|
18362
|
+
var blob = new Blob((charset === 'utf-8')
|
|
18363
|
+
// Add UTF-8 BOM character
|
|
18364
|
+
? [FilesUtils.UTF8_BOM_CHAR, content]
|
|
18365
|
+
// Non UTF-8 charset
|
|
18366
|
+
: [content], { type: type + ";charset=" + charset + ";" });
|
|
18367
|
+
if (navigator.msSaveBlob) { // IE 10+
|
|
18368
|
+
navigator.msSaveBlob(blob, filename);
|
|
18369
|
+
}
|
|
18370
|
+
else {
|
|
18371
|
+
var link = document.createElement('a');
|
|
18372
|
+
if (link.download !== undefined) {
|
|
18373
|
+
// Browsers that support HTML5 download attribute
|
|
18374
|
+
var url = URL.createObjectURL(blob);
|
|
18375
|
+
link.setAttribute('href', url);
|
|
18376
|
+
link.setAttribute('download', filename);
|
|
18377
|
+
link.style.visibility = 'hidden';
|
|
18378
|
+
document.body.appendChild(link);
|
|
18379
|
+
link.click();
|
|
18380
|
+
document.body.removeChild(link);
|
|
18381
|
+
}
|
|
18382
|
+
}
|
|
18383
|
+
};
|
|
18329
18384
|
return FilesUtils;
|
|
18330
18385
|
}());
|
|
18331
18386
|
FilesUtils.UTF8_BOM_CHAR = new Uint8Array([0xEF, 0xBB, 0xBF]); // UTF-8 BOM
|
|
@@ -20851,13 +20906,12 @@
|
|
|
20851
20906
|
CsvUtils.exportToFile = function (rows, opts) {
|
|
20852
20907
|
if (!rows || !rows.length)
|
|
20853
20908
|
return; // Skip if empty
|
|
20854
|
-
|
|
20855
|
-
var charset = ((opts === null || opts === void 0 ? void 0 : opts.encoding) || 'utf-8').toLowerCase();
|
|
20909
|
+
// Create text content
|
|
20856
20910
|
var separator = (opts === null || opts === void 0 ? void 0 : opts.separator) || ',';
|
|
20857
20911
|
var protectCellRegexp = new RegExp("/(\"|" + separator + "|\n)/g");
|
|
20858
20912
|
var keys = Object.keys(rows[0]);
|
|
20859
20913
|
var headers = (opts === null || opts === void 0 ? void 0 : opts.headers) || keys;
|
|
20860
|
-
var
|
|
20914
|
+
var textContent =
|
|
20861
20915
|
// Header row
|
|
20862
20916
|
headers.join(separator) + '\n' +
|
|
20863
20917
|
// Data rows
|
|
@@ -20873,27 +20927,8 @@
|
|
|
20873
20927
|
return cellStr;
|
|
20874
20928
|
}).join(separator);
|
|
20875
20929
|
}).join('\n');
|
|
20876
|
-
|
|
20877
|
-
|
|
20878
|
-
? [FilesUtils.UTF8_BOM_CHAR, csvContent]
|
|
20879
|
-
// Non UTF-8 charset
|
|
20880
|
-
: [csvContent], { type: "text/csv;charset=" + charset + ";" });
|
|
20881
|
-
if (navigator.msSaveBlob) { // IE 10+
|
|
20882
|
-
navigator.msSaveBlob(blob, filename);
|
|
20883
|
-
}
|
|
20884
|
-
else {
|
|
20885
|
-
var link = document.createElement('a');
|
|
20886
|
-
if (link.download !== undefined) {
|
|
20887
|
-
// Browsers that support HTML5 download attribute
|
|
20888
|
-
var url = URL.createObjectURL(blob);
|
|
20889
|
-
link.setAttribute('href', url);
|
|
20890
|
-
link.setAttribute('download', filename);
|
|
20891
|
-
link.style.visibility = 'hidden';
|
|
20892
|
-
document.body.appendChild(link);
|
|
20893
|
-
link.click();
|
|
20894
|
-
document.body.removeChild(link);
|
|
20895
|
-
}
|
|
20896
|
-
}
|
|
20930
|
+
// Write to file
|
|
20931
|
+
FilesUtils.writeTextToFile(textContent, Object.assign({ type: 'text/csv', filename: 'export.csv' }, opts));
|
|
20897
20932
|
};
|
|
20898
20933
|
CsvUtils.parseFile = function (file, opts) {
|
|
20899
20934
|
return FilesUtils.readAsText(file, opts === null || opts === void 0 ? void 0 : opts.encoding)
|