@decaf-ts/for-angular 0.0.73 → 0.0.74
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.
|
@@ -6105,7 +6105,6 @@ let CrudFieldComponent = class CrudFieldComponent extends NgxFormFieldDirective
|
|
|
6105
6105
|
* @memberOf CrudFieldComponent
|
|
6106
6106
|
*/
|
|
6107
6107
|
async ngOnInit() {
|
|
6108
|
-
this.options = await this.getOptions();
|
|
6109
6108
|
if (Array.isArray(this.hidden) && !this.hidden.includes(this.operation))
|
|
6110
6109
|
this.hidden = false;
|
|
6111
6110
|
if (this.readonly && typeof this.readonly === Function.name.toLocaleLowerCase())
|
|
@@ -6117,6 +6116,7 @@ let CrudFieldComponent = class CrudFieldComponent extends NgxFormFieldDirective
|
|
|
6117
6116
|
this.formGroup = undefined;
|
|
6118
6117
|
}
|
|
6119
6118
|
else {
|
|
6119
|
+
this.options = await this.getOptions();
|
|
6120
6120
|
if (!this.parentForm && this.formGroup instanceof FormGroup || this.formGroup instanceof FormArray)
|
|
6121
6121
|
this.parentForm = (this.formGroup.root || this.formControl.root);
|
|
6122
6122
|
if (this.multiple) {
|
|
@@ -6147,11 +6147,11 @@ let CrudFieldComponent = class CrudFieldComponent extends NgxFormFieldDirective
|
|
|
6147
6147
|
return [];
|
|
6148
6148
|
if (this.options instanceof Function) {
|
|
6149
6149
|
if (this.options.name === 'options')
|
|
6150
|
-
this.options = this.options();
|
|
6150
|
+
this.options = await this.options();
|
|
6151
6151
|
const fnName = this.options?.name;
|
|
6152
6152
|
if (fnName) {
|
|
6153
6153
|
if (fnName === 'function') {
|
|
6154
|
-
this.options = this.options();
|
|
6154
|
+
this.options = await this.options();
|
|
6155
6155
|
}
|
|
6156
6156
|
else {
|
|
6157
6157
|
const repo = getModelAndRepository(this.options?.['name'], this);
|
|
@@ -10143,14 +10143,23 @@ let ListComponent = class ListComponent extends NgxComponentDirective {
|
|
|
10143
10143
|
* @returns {KeyValue} A mapper object that contains string values mapped to the
|
|
10144
10144
|
* component's public keys.
|
|
10145
10145
|
*/
|
|
10146
|
-
|
|
10146
|
+
async getMapper() {
|
|
10147
10147
|
this.mapper = { ...this.mapper, ...{ uid: this.pk } };
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
if (typeof
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
|
|
10148
|
+
const mapper = {};
|
|
10149
|
+
for (const [key, value] of Object.entries(this.mapper)) {
|
|
10150
|
+
if (typeof value === Primitives.STRING) {
|
|
10151
|
+
mapper[key] = value;
|
|
10152
|
+
continue;
|
|
10153
|
+
}
|
|
10154
|
+
const mapperFn = value?.['valueParserFn'] || undefined;
|
|
10155
|
+
if (typeof mapperFn === 'function') {
|
|
10156
|
+
const value = await mapperFn(key, this);
|
|
10157
|
+
if (typeof value === Primitives.STRING) {
|
|
10158
|
+
mapper[value] = key;
|
|
10159
|
+
}
|
|
10160
|
+
}
|
|
10161
|
+
}
|
|
10162
|
+
return mapper;
|
|
10154
10163
|
}
|
|
10155
10164
|
/**
|
|
10156
10165
|
* @description Refreshes the list data from the configured source.
|
|
@@ -10296,7 +10305,7 @@ let ListComponent = class ListComponent extends NgxComponentDirective {
|
|
|
10296
10305
|
*/
|
|
10297
10306
|
async handleCreate(uid) {
|
|
10298
10307
|
const result = await this._repository?.read(uid);
|
|
10299
|
-
const item = this.mapResults([result])[0];
|
|
10308
|
+
const item = (await this.mapResults([result]))[0];
|
|
10300
10309
|
this.items = this.data = [item, ...(this.items || [])];
|
|
10301
10310
|
}
|
|
10302
10311
|
/**
|
|
@@ -10512,8 +10521,7 @@ let ListComponent = class ListComponent extends NgxComponentDirective {
|
|
|
10512
10521
|
*/
|
|
10513
10522
|
parseSearchResults(results, search) {
|
|
10514
10523
|
const filtered = results.filter((item) => Object.values(item).some((v) => {
|
|
10515
|
-
if (v
|
|
10516
|
-
.toString()
|
|
10524
|
+
if (`${v}`
|
|
10517
10525
|
.toLowerCase()
|
|
10518
10526
|
.includes(search?.toLowerCase()))
|
|
10519
10527
|
return v;
|
|
@@ -10596,7 +10604,11 @@ let ListComponent = class ListComponent extends NgxComponentDirective {
|
|
|
10596
10604
|
async getFromModel(force = false) {
|
|
10597
10605
|
let data = [...(this.data || [])];
|
|
10598
10606
|
let request = [];
|
|
10599
|
-
|
|
10607
|
+
if (!this.repositoryObserver) {
|
|
10608
|
+
this.repositoryObserver = {
|
|
10609
|
+
refresh: async (...args) => this.handleRepositoryRefresh(...args),
|
|
10610
|
+
};
|
|
10611
|
+
}
|
|
10600
10612
|
if (!this._repository) {
|
|
10601
10613
|
this._repository = this.repository;
|
|
10602
10614
|
try {
|
|
@@ -10783,7 +10795,7 @@ let ListComponent = class ListComponent extends NgxComponentDirective {
|
|
|
10783
10795
|
this.getMoreData(result?.length || 0);
|
|
10784
10796
|
}
|
|
10785
10797
|
return Object.keys(this.mapper || {}).length
|
|
10786
|
-
? this.mapResults(result)
|
|
10798
|
+
? await this.mapResults(result)
|
|
10787
10799
|
: result;
|
|
10788
10800
|
}
|
|
10789
10801
|
/**
|
|
@@ -10871,11 +10883,11 @@ let ListComponent = class ListComponent extends NgxComponentDirective {
|
|
|
10871
10883
|
*
|
|
10872
10884
|
* @memberOf ListComponent
|
|
10873
10885
|
*/
|
|
10874
|
-
mapResults(data) {
|
|
10886
|
+
async mapResults(data) {
|
|
10875
10887
|
if (!data || !data.length)
|
|
10876
10888
|
return [];
|
|
10877
10889
|
// passing uid as prop to mapper
|
|
10878
|
-
this.mapper = this.
|
|
10890
|
+
this.mapper = await this.getMapper();
|
|
10879
10891
|
const props = Object.assign({
|
|
10880
10892
|
operations: this.operations,
|
|
10881
10893
|
route: this.route,
|
|
@@ -12649,6 +12661,9 @@ let TableComponent = class TableComponent extends ListComponent {
|
|
|
12649
12661
|
}
|
|
12650
12662
|
async ngOnInit() {
|
|
12651
12663
|
this.initialized = false;
|
|
12664
|
+
this.repositoryObserver = {
|
|
12665
|
+
refresh: async (...args) => this.handleRepositoryRefresh(...args),
|
|
12666
|
+
};
|
|
12652
12667
|
this.type = ListComponentsTypes.PAGINATED;
|
|
12653
12668
|
this.empty = Object.assign({}, DefaultListEmptyOptions, this.empty);
|
|
12654
12669
|
if (!this.initialized)
|
|
@@ -12724,7 +12739,7 @@ let TableComponent = class TableComponent extends ListComponent {
|
|
|
12724
12739
|
return { ...accum, [curr]: parserFn ? parserFn(mapped[curr], this) : mapped[curr] };
|
|
12725
12740
|
}, { ...props });
|
|
12726
12741
|
}
|
|
12727
|
-
mapResults(data) {
|
|
12742
|
+
async mapResults(data) {
|
|
12728
12743
|
if (!data || !data.length)
|
|
12729
12744
|
return [];
|
|
12730
12745
|
return data.reduce((accum, curr) => [
|