@opengis/gis 0.1.59 → 0.1.60

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/gis",
3
- "version": "0.1.59",
3
+ "version": "0.1.60",
4
4
  "type": "module",
5
5
  "author": "Softpro",
6
6
  "main": "dist/import-file.js",
@@ -1,9 +1,19 @@
1
1
  import { getSelectVal } from '@opengis/fastify-table/utils.js';
2
2
 
3
- export async function attachClassifiers(rowOrRows, classifiers) {
3
+ export async function attachClassifiers(rowOrRows, classifiers = []) {
4
4
  const rows = Array.isArray(rowOrRows) ? rowOrRows : [rowOrRows];
5
5
 
6
- for (const row of rows) {
6
+ await Promise.all(rows.map(async row => {
7
+ classifiers.filter(item => item.classifier && item.name && row[item.name]).map(async ({ name, classifier }) => {
8
+ const arr = await getSelectVal({ name: classifier, values: [row[name]], ar: true });
9
+ const val = arr?.find?.(el => el.id === row[name]);
10
+ if (val?.text) { row[`${name}_data`] = val; }
11
+ row[name] = val?.text || val || row[name]; // for frontend
12
+ row[`${name}_text`] = val?.text || val || row[name]; // legacy?
13
+ });
14
+ }));
15
+
16
+ /* for (const row of rows) {
7
17
  for (const { name, classifier } of classifiers) {
8
18
  const value = row[name];
9
19
  if (value != null && classifier) {
@@ -18,9 +28,10 @@ export async function attachClassifiers(rowOrRows, classifiers) {
18
28
  ) {
19
29
  row[`${name}_text`] = matchVal;
20
30
  };
31
+
21
32
  }
22
33
  }
23
- }
34
+ } */
24
35
 
25
36
  return rowOrRows;
26
37
  }