@dev-crew-berlin/enter-js-utils 0.45.0 → 0.46.1
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,10 +1,16 @@
|
|
|
1
1
|
import { components } from '../generated/api-schema';
|
|
2
|
+
import { Field } from './field';
|
|
2
3
|
export declare type Dictionary<T> = Record<string, T>;
|
|
3
4
|
export declare type FieldGroup = components['schemas']['FieldGroup'];
|
|
4
5
|
export declare type FieldLabels = Record<string, FieldTitle | undefined>;
|
|
6
|
+
export declare type FieldMap = Map<string, Field & {
|
|
7
|
+
group: string;
|
|
8
|
+
}>;
|
|
5
9
|
declare type FieldTitle = string | Dictionary<string>;
|
|
6
10
|
export declare class FieldGroups {
|
|
7
11
|
groups: FieldGroup[];
|
|
12
|
+
get groupNames(): string[];
|
|
13
|
+
get fields(): FieldMap;
|
|
8
14
|
constructor(json: FieldGroup[]);
|
|
9
15
|
toJSON(): FieldGroup[];
|
|
10
16
|
getFieldLabels(): FieldLabels;
|
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
export class FieldGroups {
|
|
2
|
+
get groupNames() {
|
|
3
|
+
return this.groups.map((_, index) => index.toString());
|
|
4
|
+
}
|
|
5
|
+
get fields() {
|
|
6
|
+
const fields = new Map();
|
|
7
|
+
for (const [groupIndex, group] of this.groups.entries()) {
|
|
8
|
+
for (const field of group.questions) {
|
|
9
|
+
fields.set(field.name, {
|
|
10
|
+
...field,
|
|
11
|
+
group: groupIndex.toString()
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return fields;
|
|
16
|
+
}
|
|
2
17
|
constructor(json) {
|
|
3
18
|
this.groups = json;
|
|
4
19
|
}
|
|
@@ -6,12 +21,11 @@ export class FieldGroups {
|
|
|
6
21
|
return this.groups;
|
|
7
22
|
}
|
|
8
23
|
getFieldLabels() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}, {});
|
|
24
|
+
const labels = {};
|
|
25
|
+
for (const [fieldKey, field] of this.fields.entries()) {
|
|
26
|
+
labels[fieldKey] = field.title ?? field.name;
|
|
27
|
+
}
|
|
28
|
+
return labels;
|
|
15
29
|
}
|
|
16
30
|
getLabelForField(fieldKey, language) {
|
|
17
31
|
const fieldLabel = this.getFieldLabels()[fieldKey];
|
package/dist/models/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type { CheckinJSON } from './checkin';
|
|
|
6
6
|
export { Checkins } from './checkins';
|
|
7
7
|
export type { CheckinsJSON } from './checkins';
|
|
8
8
|
export type { Event, AttendeeUpdatedEvent, AttendeeCreatedEvent, AttendeeRespondedEvent, AttendeeDeletedEvent, CheckinCreatedEvent, CheckinDeletedEvent, PaymentPaidEvent, } from './event';
|
|
9
|
-
export type { FieldGroup, FieldLabels } from './field-group';
|
|
9
|
+
export type { FieldGroup, FieldLabels, FieldMap } from './field-group';
|
|
10
10
|
export { FieldGroups } from './field-group';
|
|
11
11
|
export type { FieldValue } from './field-value';
|
|
12
12
|
export type { StaticField, TextField, EmailField, NumberField, CheckboxField, SingleCheckboxField, RadioField, SingleRadioField, SelectField, Field, } from './field';
|