Skip to content
Snippets Groups Projects
Commit df210177 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #15301 TIME 0:10 fix get custom fields

parent 3dde1238
No related branches found
No related tags found
No related merge requests found
...@@ -416,38 +416,34 @@ export class IndexingFieldsService { ...@@ -416,38 +416,34 @@ export class IndexingFieldsService {
getCustomFields() { getCustomFields() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.customFields.length > 0) { this.http.get('../rest/customFields').pipe(
resolve(this.customFields); tap((data: any) => {
} else { this.customFields = data.customFields.map((info: any) => {
this.http.get('../rest/customFields').pipe( info.identifier = 'indexingCustomField_' + info.id;
tap((data: any) => { info.icon = 'fa-hashtag';
this.customFields = data.customFields.map((info: any) => { info.system = false;
info.identifier = 'indexingCustomField_' + info.id; info.enabled = true;
info.icon = 'fa-hashtag'; info.SQLMode = info.SQLMode;
info.system = false; if (['integer', 'string', 'date'].indexOf(info.type) > -1 && !this.functions.empty(info.values)) {
info.enabled = true; info.default_value = info.values[0].key;
info.SQLMode = info.SQLMode; } else {
if (['integer', 'string', 'date'].indexOf(info.type) > -1 && !this.functions.empty(info.values)) { info.default_value = info.type === 'banAutocomplete' ? [] : null;
info.default_value = info.values[0].key; }
} else { info.values = info.values.length > 0 ? info.values.map((custVal: any) => {
info.default_value = info.type === 'banAutocomplete' ? [] : null; return {
} id: custVal.key,
info.values = info.values.length > 0 ? info.values.map((custVal: any) => { label: custVal.label
return { };
id: custVal.key, }) : info.values;
label: custVal.label return info;
}; });
}) : info.values; }),
return info; finalize(() => resolve(this.customFields)),
}); catchError((err: any) => {
}), this.notify.handleSoftErrors(err);
finalize(() => resolve(this.customFields)), return of(false);
catchError((err: any) => { })
this.notify.handleSoftErrors(err); ).subscribe();
return of(false);
})
).subscribe();
}
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment