@dev-crew-berlin/enter-js-utils 0.47.2 → 0.47.3
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.
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { components } from '../generated/api-schema';
|
|
2
2
|
import { Field } from './field';
|
|
3
3
|
export declare type Dictionary<T> = Record<string, T>;
|
|
4
|
-
export declare type
|
|
4
|
+
export declare type _FieldGroup = components['schemas']['FieldGroup'];
|
|
5
|
+
export declare type FieldGroup = Omit<_FieldGroup, 'questions'>;
|
|
5
6
|
export declare class FieldGroups {
|
|
6
7
|
private _groups;
|
|
7
8
|
get groups(): Map<string, FieldGroup>;
|
|
8
9
|
get fields(): Map<string, Field>;
|
|
9
|
-
constructor(json:
|
|
10
|
-
toJSON():
|
|
10
|
+
constructor(json: _FieldGroup[]);
|
|
11
|
+
toJSON(): _FieldGroup[];
|
|
12
|
+
withoutMetaFields(): FieldGroups;
|
|
11
13
|
getLabelForField(fieldKey: string, language: string): string;
|
|
12
14
|
}
|
|
@@ -24,6 +24,22 @@ export class FieldGroups {
|
|
|
24
24
|
toJSON() {
|
|
25
25
|
return this._groups;
|
|
26
26
|
}
|
|
27
|
+
withoutMetaFields() {
|
|
28
|
+
const fieldGroupList = [];
|
|
29
|
+
for (const group of this._groups) {
|
|
30
|
+
if (group.isMetaGroup) continue;
|
|
31
|
+
const fields = [];
|
|
32
|
+
for (const field of group.questions) {
|
|
33
|
+
if (field.isMetaField) continue;
|
|
34
|
+
fields.push(field);
|
|
35
|
+
}
|
|
36
|
+
fieldGroupList.push({
|
|
37
|
+
...group,
|
|
38
|
+
questions: fields
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return new FieldGroups(fieldGroupList);
|
|
42
|
+
}
|
|
27
43
|
getLabelForField(fieldKey, language) {
|
|
28
44
|
const field = this.fields.get(fieldKey);
|
|
29
45
|
const fieldLabel = field?.title ?? field?.name ?? fieldKey;
|