tycho-components 0.25.6 → 0.25.7
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.
|
@@ -34,16 +34,19 @@ const toCoreFormValues = (participant) => ({
|
|
|
34
34
|
separator: participant.separator ?? '',
|
|
35
35
|
color: participant.color ?? '',
|
|
36
36
|
});
|
|
37
|
-
const toChatFormValues = (participant) =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
const toChatFormValues = (participant) => {
|
|
38
|
+
const chat = participant.chat ?? {};
|
|
39
|
+
return {
|
|
40
|
+
language: chat.language ?? '',
|
|
41
|
+
age: chat.age ?? '',
|
|
42
|
+
sex: chat.sex ?? '',
|
|
43
|
+
group: chat.group ?? '',
|
|
44
|
+
ses: chat.ses ?? '',
|
|
45
|
+
role: chat.role ?? '',
|
|
46
|
+
education: chat.education ?? '',
|
|
47
|
+
custom: chat.custom ?? '',
|
|
48
|
+
};
|
|
49
|
+
};
|
|
47
50
|
export default function Participants({ document, participants, onChange, useChat, }) {
|
|
48
51
|
const { t } = useTranslation('participants');
|
|
49
52
|
const { dispatchMessage } = useMessageUtils();
|
|
@@ -51,10 +54,10 @@ export default function Participants({ document, participants, onChange, useChat
|
|
|
51
54
|
const [openRemove, setOpenRemove] = useState(false);
|
|
52
55
|
const [openCreate, setOpenCreate] = useState(false);
|
|
53
56
|
const participantForm = useForm({
|
|
54
|
-
defaultValues: toCoreFormValues({ order: 1, code: '', name: '' }),
|
|
57
|
+
defaultValues: toCoreFormValues({ order: 1, code: '', name: '', chat: {} }),
|
|
55
58
|
});
|
|
56
59
|
const chatForm = useForm({
|
|
57
|
-
defaultValues: toChatFormValues({ order: 1, code: '', name: '' }),
|
|
60
|
+
defaultValues: toChatFormValues({ order: 1, code: '', name: '', chat: {} }),
|
|
58
61
|
});
|
|
59
62
|
const participantFields = useMemo(() => PARTICIPANT_FIELD_DEFS.map((field) => ({
|
|
60
63
|
...field,
|
|
@@ -67,24 +70,27 @@ export default function Participants({ document, participants, onChange, useChat
|
|
|
67
70
|
...field,
|
|
68
71
|
name: t(`participant.field.${field.attr}`),
|
|
69
72
|
})), [t]);
|
|
70
|
-
const buildParticipantPayload = () => {
|
|
73
|
+
const buildParticipantPayload = (current) => {
|
|
71
74
|
const coreValues = participantForm.getValues();
|
|
72
75
|
const chatValues = chatForm.getValues();
|
|
73
76
|
const order = typeof coreValues.order === 'string'
|
|
74
|
-
? Number(coreValues.order) ||
|
|
77
|
+
? Number(coreValues.order) || current.order || 1
|
|
75
78
|
: coreValues.order;
|
|
76
79
|
return {
|
|
77
|
-
...
|
|
78
|
-
...chatValues,
|
|
80
|
+
...current,
|
|
79
81
|
...coreValues,
|
|
80
82
|
order,
|
|
83
|
+
chat: {
|
|
84
|
+
...current.chat,
|
|
85
|
+
...chatValues,
|
|
86
|
+
},
|
|
81
87
|
};
|
|
82
88
|
};
|
|
83
89
|
const handleSave = () => {
|
|
84
90
|
if (!participant)
|
|
85
91
|
return;
|
|
86
92
|
const lookupCode = participant.code;
|
|
87
|
-
const payload = buildParticipantPayload();
|
|
93
|
+
const payload = buildParticipantPayload(participant);
|
|
88
94
|
ParticipantService.update(document, lookupCode, payload)
|
|
89
95
|
.then(() => {
|
|
90
96
|
dispatchMessage({ key: 'update.success', t });
|
|
@@ -3,16 +3,9 @@ type Participant = {
|
|
|
3
3
|
code: string;
|
|
4
4
|
name: string;
|
|
5
5
|
color?: string;
|
|
6
|
-
separator?: string;
|
|
7
6
|
role?: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
sex?: string;
|
|
11
|
-
custom?: string;
|
|
12
|
-
corpus?: string;
|
|
13
|
-
language?: string;
|
|
14
|
-
age?: string;
|
|
15
|
-
group?: string;
|
|
7
|
+
separator?: string;
|
|
8
|
+
chat: Record<string, string>;
|
|
16
9
|
};
|
|
17
10
|
export type ParticipantCreateRequest = {
|
|
18
11
|
code: string;
|
|
@@ -23,9 +16,5 @@ export type ParticipantUpdateRequest = {
|
|
|
23
16
|
code: string;
|
|
24
17
|
participant: Participant;
|
|
25
18
|
};
|
|
26
|
-
export declare const EMPTY_PARTICIPANT:
|
|
27
|
-
order: number;
|
|
28
|
-
code: string;
|
|
29
|
-
name: string;
|
|
30
|
-
};
|
|
19
|
+
export declare const EMPTY_PARTICIPANT: Participant;
|
|
31
20
|
export default Participant;
|