@jsb188/schedule 1.1.11
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 +61 -0
- package/src/constants/schedule.ts +549 -0
- package/src/css.d.ts +7 -0
- package/src/libs/gantt-geometry.ts +771 -0
- package/src/libs/gantt-histogram.ts +124 -0
- package/src/libs/gantt-keyboard.ts +113 -0
- package/src/libs/gantt-state.ts +57 -0
- package/src/libs/gantt-url.ts +63 -0
- package/src/modules/Gantt.helpers.ts +138 -0
- package/src/modules/Gantt.tsx +719 -0
- package/src/types/schedule.d.ts +1149 -0
- package/src/ui/ActivityFormUI.tsx +133 -0
- package/src/ui/GanttEditorsUI.tsx +102 -0
- package/src/ui/GanttHistogramUI.tsx +236 -0
- package/src/ui/GanttUI.tsx +792 -0
- package/src/ui/ProjectFormUI.tsx +273 -0
- package/src/ui/ProjectMobileListUI.tsx +80 -0
- package/src/ui/ProjectToolbarUI.tsx +54 -0
- package/src/ui/RelationshipListUI.tsx +176 -0
- package/src/ui/ScheduleRunUI.tsx +173 -0
- package/src/ui/ScheduleSettingsUI.tsx +420 -0
- package/src/utils/coverage.helpers.ts +679 -0
- package/src/utils/coverage.ts +630 -0
- package/src/utils/cpm.helpers.ts +674 -0
- package/src/utils/cpm.ts +907 -0
- package/src/utils/cpmLeveling.helpers.ts +564 -0
- package/src/utils/cpmLeveling.ts +367 -0
- package/src/utils/defaults.ts +8 -0
- package/src/utils/eligibility.ts +457 -0
- package/src/utils/planCsv.ts +344 -0
- package/src/utils/predecessorText.ts +96 -0
- package/src/utils/recurrence.ts +616 -0
- package/src/utils/request.ts +153 -0
- package/src/utils/resource.ts +182 -0
- package/src/utils/rule.ts +216 -0
- package/src/utils/run.ts +43 -0
- package/src/utils/series.ts +161 -0
- package/src/utils/slot.ts +208 -0
- package/src/utils/workTime.ts +1382 -0
- package/tests/coverage.fixtures.ts +111 -0
- package/tests/coverage.test.ts +503 -0
- package/tests/cpm.bench.test.ts +154 -0
- package/tests/cpm.test.ts +354 -0
- package/tests/cpmCorrectness.test.ts +327 -0
- package/tests/cpmLeveling.test.ts +471 -0
- package/tests/eligibility.test.ts +320 -0
- package/tests/gantt-geometry.test.ts +367 -0
- package/tests/gantt-histogram.test.ts +78 -0
- package/tests/gantt-keyboard.test.ts +69 -0
- package/tests/helpers/cpmFixtures.ts +101 -0
- package/tests/projectInputs.test.ts +165 -0
- package/tests/recurrence.test.ts +68 -0
- package/tests/request.test.ts +99 -0
- package/tests/resource.test.ts +95 -0
- package/tests/rule.test.ts +98 -0
- package/tests/series.test.ts +120 -0
- package/tests/workTime.test.ts +1007 -0
- package/tests/workTimeContracts.test.ts +111 -0
- package/tsconfig.json +13 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { cn } from '@jsb188/app/utils/string.ts';
|
|
2
|
+
import {
|
|
3
|
+
Input,
|
|
4
|
+
Select,
|
|
5
|
+
type SelectOptionType,
|
|
6
|
+
Textarea,
|
|
7
|
+
} from '@jsb188/react-web/modules/Form';
|
|
8
|
+
import { Button } from '@jsb188/react-web/ui/Button';
|
|
9
|
+
import { memo } from 'react';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The create / edit form for one project. Controlled, like the activity
|
|
13
|
+
* form; dates are "yyyy-MM-dd" and the zone is the caller's problem.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export interface ProjectFormValuesObj {
|
|
17
|
+
code: string;
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
status: string;
|
|
21
|
+
timeZone: string;
|
|
22
|
+
workCalendarId: string;
|
|
23
|
+
plannedStartDate: string;
|
|
24
|
+
mustFinishByDate: string;
|
|
25
|
+
dataDate: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type ProjectFormFieldEnum = keyof ProjectFormValuesObj;
|
|
29
|
+
|
|
30
|
+
export interface ProjectFormUIProps {
|
|
31
|
+
className?: string;
|
|
32
|
+
values: ProjectFormValuesObj;
|
|
33
|
+
isNew: boolean;
|
|
34
|
+
headingText: string;
|
|
35
|
+
codeLabel: string;
|
|
36
|
+
nameLabel: string;
|
|
37
|
+
namePlaceholder: string;
|
|
38
|
+
descriptionLabel: string;
|
|
39
|
+
statusLabel: string;
|
|
40
|
+
statusOptions: SelectOptionType[];
|
|
41
|
+
timeZoneLabel: string;
|
|
42
|
+
timeZoneOptions?: SelectOptionType[];
|
|
43
|
+
workCalendarLabel?: string;
|
|
44
|
+
workCalendarOptions?: SelectOptionType[];
|
|
45
|
+
plannedStartLabel: string;
|
|
46
|
+
mustFinishByLabel: string;
|
|
47
|
+
dataDateLabel: string;
|
|
48
|
+
saveText: string;
|
|
49
|
+
savingText?: string;
|
|
50
|
+
cancelText: string;
|
|
51
|
+
deleteText?: string;
|
|
52
|
+
errorText?: string | null;
|
|
53
|
+
saving?: boolean;
|
|
54
|
+
onChangeValue: (field: ProjectFormFieldEnum, value: string) => void;
|
|
55
|
+
onSave: () => void;
|
|
56
|
+
onCancel: () => void;
|
|
57
|
+
onDelete?: () => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const ProjectFormUI = memo((p: ProjectFormUIProps) => {
|
|
61
|
+
const {
|
|
62
|
+
className,
|
|
63
|
+
values,
|
|
64
|
+
isNew,
|
|
65
|
+
headingText,
|
|
66
|
+
codeLabel,
|
|
67
|
+
nameLabel,
|
|
68
|
+
namePlaceholder,
|
|
69
|
+
descriptionLabel,
|
|
70
|
+
statusLabel,
|
|
71
|
+
statusOptions,
|
|
72
|
+
timeZoneLabel,
|
|
73
|
+
plannedStartLabel,
|
|
74
|
+
mustFinishByLabel,
|
|
75
|
+
dataDateLabel,
|
|
76
|
+
saveText,
|
|
77
|
+
savingText,
|
|
78
|
+
cancelText,
|
|
79
|
+
deleteText,
|
|
80
|
+
errorText,
|
|
81
|
+
saving,
|
|
82
|
+
onChangeValue,
|
|
83
|
+
onSave,
|
|
84
|
+
onCancel,
|
|
85
|
+
onDelete,
|
|
86
|
+
} = p;
|
|
87
|
+
|
|
88
|
+
const saveDisabled =
|
|
89
|
+
!!saving ||
|
|
90
|
+
!values.name.trim() ||
|
|
91
|
+
!values.plannedStartDate ||
|
|
92
|
+
!values.timeZone;
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div className={cn('v_stretch h_f of', className)}>
|
|
96
|
+
<div
|
|
97
|
+
className="f h_0 of auto_y app_scr"
|
|
98
|
+
style={{ paddingLeft: 12, paddingRight: 12, paddingBottom: 12 }}
|
|
99
|
+
>
|
|
100
|
+
<div
|
|
101
|
+
className="ft_sm ft_semibold"
|
|
102
|
+
style={{ paddingTop: 12, paddingBottom: 8 }}
|
|
103
|
+
>
|
|
104
|
+
{headingText}
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<div className="h_item gap_sm">
|
|
108
|
+
<Input
|
|
109
|
+
className="no_shrink"
|
|
110
|
+
preset="fill"
|
|
111
|
+
name="code"
|
|
112
|
+
label={codeLabel}
|
|
113
|
+
disabled={saving}
|
|
114
|
+
value={values.code}
|
|
115
|
+
onChange={(e) => onChangeValue('code', e.currentTarget.value)}
|
|
116
|
+
/>
|
|
117
|
+
<Input
|
|
118
|
+
fullWidth
|
|
119
|
+
autoFocus={isNew}
|
|
120
|
+
className="f"
|
|
121
|
+
preset="fill"
|
|
122
|
+
name="name"
|
|
123
|
+
label={nameLabel}
|
|
124
|
+
placeholder={namePlaceholder}
|
|
125
|
+
disabled={saving}
|
|
126
|
+
value={values.name}
|
|
127
|
+
onChange={(e) => onChangeValue('name', e.currentTarget.value)}
|
|
128
|
+
/>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
{!isNew ? (
|
|
132
|
+
<Select
|
|
133
|
+
fullWidth
|
|
134
|
+
className="mt_xs"
|
|
135
|
+
preset="fill"
|
|
136
|
+
name="status"
|
|
137
|
+
label={statusLabel}
|
|
138
|
+
disabled={saving}
|
|
139
|
+
options={statusOptions}
|
|
140
|
+
value={values.status}
|
|
141
|
+
onChange={(value) => onChangeValue('status', String(value ?? ''))}
|
|
142
|
+
/>
|
|
143
|
+
) : null}
|
|
144
|
+
|
|
145
|
+
<Select
|
|
146
|
+
fullWidth
|
|
147
|
+
preset="fill"
|
|
148
|
+
name="timeZone"
|
|
149
|
+
label={timeZoneLabel}
|
|
150
|
+
disabled={saving}
|
|
151
|
+
options={
|
|
152
|
+
p.timeZoneOptions || [
|
|
153
|
+
{ value: values.timeZone, text: values.timeZone },
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
value={values.timeZone}
|
|
157
|
+
onChange={(value) =>
|
|
158
|
+
onChangeValue('timeZone', String(value || 'UTC'))
|
|
159
|
+
}
|
|
160
|
+
/>
|
|
161
|
+
{p.workCalendarOptions ? (
|
|
162
|
+
<Select
|
|
163
|
+
fullWidth
|
|
164
|
+
preset="fill"
|
|
165
|
+
name="workCalendarId"
|
|
166
|
+
label={p.workCalendarLabel}
|
|
167
|
+
disabled={saving}
|
|
168
|
+
options={p.workCalendarOptions}
|
|
169
|
+
value={values.workCalendarId}
|
|
170
|
+
onChange={(value) =>
|
|
171
|
+
onChangeValue('workCalendarId', String(value || ''))
|
|
172
|
+
}
|
|
173
|
+
/>
|
|
174
|
+
) : null}
|
|
175
|
+
|
|
176
|
+
<div className="h_item gap_sm mt_xs">
|
|
177
|
+
<Input
|
|
178
|
+
fullWidth
|
|
179
|
+
className="f"
|
|
180
|
+
preset="fill"
|
|
181
|
+
type="date"
|
|
182
|
+
name="plannedStartDate"
|
|
183
|
+
label={plannedStartLabel}
|
|
184
|
+
disabled={saving}
|
|
185
|
+
value={values.plannedStartDate}
|
|
186
|
+
onChange={(e) =>
|
|
187
|
+
onChangeValue('plannedStartDate', e.currentTarget.value)
|
|
188
|
+
}
|
|
189
|
+
/>
|
|
190
|
+
<Input
|
|
191
|
+
fullWidth
|
|
192
|
+
className="f"
|
|
193
|
+
preset="fill"
|
|
194
|
+
type="date"
|
|
195
|
+
name="mustFinishByDate"
|
|
196
|
+
label={mustFinishByLabel}
|
|
197
|
+
disabled={saving}
|
|
198
|
+
value={values.mustFinishByDate}
|
|
199
|
+
onChange={(e) =>
|
|
200
|
+
onChangeValue('mustFinishByDate', e.currentTarget.value)
|
|
201
|
+
}
|
|
202
|
+
/>
|
|
203
|
+
</div>
|
|
204
|
+
|
|
205
|
+
<Input
|
|
206
|
+
fullWidth
|
|
207
|
+
className="mt_xs"
|
|
208
|
+
preset="fill"
|
|
209
|
+
type="date"
|
|
210
|
+
name="dataDate"
|
|
211
|
+
label={dataDateLabel}
|
|
212
|
+
disabled={saving}
|
|
213
|
+
value={values.dataDate}
|
|
214
|
+
onChange={(e) => onChangeValue('dataDate', e.currentTarget.value)}
|
|
215
|
+
/>
|
|
216
|
+
|
|
217
|
+
<Textarea
|
|
218
|
+
fullWidth
|
|
219
|
+
className="mt_xs"
|
|
220
|
+
preset="fill"
|
|
221
|
+
name="description"
|
|
222
|
+
label={descriptionLabel}
|
|
223
|
+
minHeight={60}
|
|
224
|
+
disabled={saving}
|
|
225
|
+
value={values.description}
|
|
226
|
+
onChange={(e) => onChangeValue('description', e.currentTarget.value)}
|
|
227
|
+
/>
|
|
228
|
+
|
|
229
|
+
{errorText ? (
|
|
230
|
+
<div className="ft_xs cl_err mt_xs">{errorText}</div>
|
|
231
|
+
) : null}
|
|
232
|
+
</div>
|
|
233
|
+
|
|
234
|
+
<div
|
|
235
|
+
className="no_shrink h_item gap_sm bd_t_1 bd_t_bd"
|
|
236
|
+
style={{
|
|
237
|
+
paddingLeft: 12,
|
|
238
|
+
paddingRight: 12,
|
|
239
|
+
paddingTop: 8,
|
|
240
|
+
paddingBottom: 8,
|
|
241
|
+
}}
|
|
242
|
+
>
|
|
243
|
+
{!isNew && onDelete && deleteText ? (
|
|
244
|
+
<Button
|
|
245
|
+
preset="cl_err"
|
|
246
|
+
size="sm"
|
|
247
|
+
disabled={saving}
|
|
248
|
+
text={deleteText}
|
|
249
|
+
onClick={onDelete}
|
|
250
|
+
/>
|
|
251
|
+
) : null}
|
|
252
|
+
<div className="f" />
|
|
253
|
+
<Button
|
|
254
|
+
preset="bg"
|
|
255
|
+
size="sm"
|
|
256
|
+
disabled={saving}
|
|
257
|
+
text={cancelText}
|
|
258
|
+
onClick={onCancel}
|
|
259
|
+
/>
|
|
260
|
+
<Button
|
|
261
|
+
preset="bg_secondary"
|
|
262
|
+
size="sm"
|
|
263
|
+
disabled={saveDisabled}
|
|
264
|
+
loading={saving}
|
|
265
|
+
text={saving && savingText ? savingText : saveText}
|
|
266
|
+
onClick={onSave}
|
|
267
|
+
/>
|
|
268
|
+
</div>
|
|
269
|
+
</div>
|
|
270
|
+
);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
ProjectFormUI.displayName = 'ProjectFormUI';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { memo, useState } from 'react';
|
|
2
|
+
/* Show a deliberate read-only mobile schedule grouped under collapsible work packages. */
|
|
3
|
+
export const ProjectMobileListUI = memo(
|
|
4
|
+
(p: {
|
|
5
|
+
groups: Array<{
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
rows: Array<{
|
|
9
|
+
id: string;
|
|
10
|
+
code: string;
|
|
11
|
+
name: string;
|
|
12
|
+
dates: string;
|
|
13
|
+
status: string;
|
|
14
|
+
critical: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
}>;
|
|
17
|
+
emptyText: string;
|
|
18
|
+
criticalText: string;
|
|
19
|
+
onSelect: (id: string) => void;
|
|
20
|
+
}) => {
|
|
21
|
+
const [collapsed, setCollapsed] = useState(new Set<string>());
|
|
22
|
+
return (
|
|
23
|
+
<div className="hidden phone:bl f auto_y app_scr">
|
|
24
|
+
{!p.groups.some((group) => group.rows.length) ? (
|
|
25
|
+
<p
|
|
26
|
+
className="ft_sm cl_lt"
|
|
27
|
+
style={{ padding: 16 }}
|
|
28
|
+
>
|
|
29
|
+
{p.emptyText}
|
|
30
|
+
</p>
|
|
31
|
+
) : (
|
|
32
|
+
p.groups.map((group) => (
|
|
33
|
+
<section key={group.id}>
|
|
34
|
+
<button
|
|
35
|
+
className="w_f a_l ft_sm ft_semibold bg_alt"
|
|
36
|
+
style={{ padding: 12 }}
|
|
37
|
+
aria-expanded={!collapsed.has(group.id)}
|
|
38
|
+
onClick={() =>
|
|
39
|
+
setCollapsed((current) => {
|
|
40
|
+
const next = new Set(current);
|
|
41
|
+
if (next.has(group.id)) next.delete(group.id);
|
|
42
|
+
else next.add(group.id);
|
|
43
|
+
return next;
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
>
|
|
47
|
+
{group.name}
|
|
48
|
+
</button>
|
|
49
|
+
{collapsed.has(group.id)
|
|
50
|
+
? null
|
|
51
|
+
: group.rows.map((row) => (
|
|
52
|
+
<button
|
|
53
|
+
type="button"
|
|
54
|
+
key={row.id}
|
|
55
|
+
className="w_f v_stretch a_l gap_xs bd_b_1 bd_b_bd"
|
|
56
|
+
style={{ padding: 12 }}
|
|
57
|
+
onClick={() => p.onSelect(row.id)}
|
|
58
|
+
>
|
|
59
|
+
<span className="ft_sm">
|
|
60
|
+
{row.code} · {row.name}
|
|
61
|
+
</span>
|
|
62
|
+
<span className="ft_xs cl_lt">{row.dates}</span>
|
|
63
|
+
<span className="h_item gap_xs">
|
|
64
|
+
<span className="pill bg_alt ft_xxs">{row.status}</span>
|
|
65
|
+
{row.critical ? (
|
|
66
|
+
<span className="cl_err ft_xxs">
|
|
67
|
+
{p.criticalText}
|
|
68
|
+
</span>
|
|
69
|
+
) : null}
|
|
70
|
+
</span>
|
|
71
|
+
</button>
|
|
72
|
+
))}
|
|
73
|
+
</section>
|
|
74
|
+
))
|
|
75
|
+
)}
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
ProjectMobileListUI.displayName = 'ProjectMobileListUI';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
SegmentedControl,
|
|
4
|
+
type SegmentedControlOption,
|
|
5
|
+
} from '@jsb188/react-web/ui/Button';
|
|
6
|
+
import { memo, type ReactNode } from 'react';
|
|
7
|
+
/* Present compact planner controls with translated labels and caller-owned actions. */
|
|
8
|
+
export const ProjectToolbarUI = memo(
|
|
9
|
+
(p: {
|
|
10
|
+
title: string;
|
|
11
|
+
subText?: string | null;
|
|
12
|
+
zoom: string;
|
|
13
|
+
zoomOptions: SegmentedControlOption[];
|
|
14
|
+
actions: Array<{
|
|
15
|
+
key: string;
|
|
16
|
+
text: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
onClick: () => void;
|
|
19
|
+
}>;
|
|
20
|
+
onSelectZoom: (zoom: string) => void;
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
}) => (
|
|
23
|
+
<div
|
|
24
|
+
className="no_shrink v_stretch gap_xs bd_b_1 bd_b_bd phone:hidden"
|
|
25
|
+
style={{ padding: '6px 12px' }}
|
|
26
|
+
>
|
|
27
|
+
<div className="h_item gap_sm">
|
|
28
|
+
<span className="f ellip ft_sm ft_semibold">{p.title}</span>
|
|
29
|
+
<SegmentedControl
|
|
30
|
+
options={p.zoomOptions}
|
|
31
|
+
selectedValue={p.zoom}
|
|
32
|
+
onClickItem={(_event, value) => p.onSelectZoom(value)}
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
{p.subText ? <span className="ft_xxs cl_lt">{p.subText}</span> : null}
|
|
36
|
+
<div className="h_item f_wrap gap_xs">
|
|
37
|
+
{p.actions.map((action) => (
|
|
38
|
+
<Button
|
|
39
|
+
key={action.key}
|
|
40
|
+
size="sm"
|
|
41
|
+
preset="bg_secondary"
|
|
42
|
+
text={action.text}
|
|
43
|
+
disabled={action.disabled}
|
|
44
|
+
onClick={action.onClick}
|
|
45
|
+
/>
|
|
46
|
+
))}
|
|
47
|
+
</div>
|
|
48
|
+
{p.children ? (
|
|
49
|
+
<div className="h_item f_wrap gap_sm">{p.children}</div>
|
|
50
|
+
) : null}
|
|
51
|
+
</div>
|
|
52
|
+
),
|
|
53
|
+
);
|
|
54
|
+
ProjectToolbarUI.displayName = 'ProjectToolbarUI';
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { memo, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
/* Show one editable relationship while keeping unsaved type and lag local. */
|
|
4
|
+
const RelationshipRowUI = memo(
|
|
5
|
+
(p: {
|
|
6
|
+
row: {
|
|
7
|
+
id: string;
|
|
8
|
+
activityId: string;
|
|
9
|
+
text: string;
|
|
10
|
+
isDriving: boolean;
|
|
11
|
+
type?: string;
|
|
12
|
+
lag?: string;
|
|
13
|
+
};
|
|
14
|
+
editable?: boolean;
|
|
15
|
+
labels: {
|
|
16
|
+
remove: string;
|
|
17
|
+
edit: string;
|
|
18
|
+
type: string;
|
|
19
|
+
lag: string;
|
|
20
|
+
save: string;
|
|
21
|
+
cancel: string;
|
|
22
|
+
};
|
|
23
|
+
onSelectActivity: (id: string) => void;
|
|
24
|
+
onDelete: (id: string) => void;
|
|
25
|
+
onEdit?: (id: string, type: string, lag: string) => Promise<boolean>;
|
|
26
|
+
}) => {
|
|
27
|
+
const [editing, setEditing] = useState(false);
|
|
28
|
+
const [type, setType] = useState(p.row.type || 'FS');
|
|
29
|
+
const [lag, setLag] = useState(p.row.lag || '0');
|
|
30
|
+
const [saving, setSaving] = useState(false);
|
|
31
|
+
/* Close the draft only after the server accepts the relationship change. */
|
|
32
|
+
const save = async () => {
|
|
33
|
+
setSaving(true);
|
|
34
|
+
try {
|
|
35
|
+
if (await p.onEdit?.(p.row.id, type, lag)) setEditing(false);
|
|
36
|
+
} finally {
|
|
37
|
+
setSaving(false);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return (
|
|
41
|
+
<div className="v_stretch bd_b_1 bd_b_bd">
|
|
42
|
+
<div className="h_item gap_xs">
|
|
43
|
+
<button
|
|
44
|
+
type="button"
|
|
45
|
+
className={`f ft_xs a_l bg_hv${p.row.isDriving ? ' ft_semibold' : ''}`}
|
|
46
|
+
onClick={() => p.onSelectActivity(p.row.activityId)}
|
|
47
|
+
>
|
|
48
|
+
{p.row.text}
|
|
49
|
+
</button>
|
|
50
|
+
{p.editable ? (
|
|
51
|
+
<>
|
|
52
|
+
<button
|
|
53
|
+
type="button"
|
|
54
|
+
className="ft_xxs cl_primary"
|
|
55
|
+
onClick={() => {
|
|
56
|
+
setType(p.row.type || 'FS');
|
|
57
|
+
setLag(p.row.lag || '0');
|
|
58
|
+
setEditing(true);
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
{p.labels.edit}
|
|
62
|
+
</button>
|
|
63
|
+
<button
|
|
64
|
+
type="button"
|
|
65
|
+
className="ft_xxs cl_err"
|
|
66
|
+
onClick={() => p.onDelete(p.row.id)}
|
|
67
|
+
>
|
|
68
|
+
{p.labels.remove}
|
|
69
|
+
</button>
|
|
70
|
+
</>
|
|
71
|
+
) : null}
|
|
72
|
+
</div>
|
|
73
|
+
{editing && p.editable ? (
|
|
74
|
+
<div className="h_item f_wrap gap_xs mt_xs mb_xs">
|
|
75
|
+
<label className="v_stretch ft_xxs">
|
|
76
|
+
{p.labels.type}
|
|
77
|
+
<select
|
|
78
|
+
className="bg_alt bd_1 bd_bd ft_xs"
|
|
79
|
+
value={type}
|
|
80
|
+
onChange={(event) => setType(event.target.value)}
|
|
81
|
+
>
|
|
82
|
+
{['FS', 'SS', 'FF', 'SF'].map((value) => (
|
|
83
|
+
<option
|
|
84
|
+
key={value}
|
|
85
|
+
value={value}
|
|
86
|
+
>
|
|
87
|
+
{value}
|
|
88
|
+
</option>
|
|
89
|
+
))}
|
|
90
|
+
</select>
|
|
91
|
+
</label>
|
|
92
|
+
<label className="v_stretch ft_xxs">
|
|
93
|
+
{p.labels.lag}
|
|
94
|
+
<input
|
|
95
|
+
className="bg_alt bd_1 bd_bd ft_xs"
|
|
96
|
+
style={{ width: 70 }}
|
|
97
|
+
type="number"
|
|
98
|
+
step="any"
|
|
99
|
+
value={lag}
|
|
100
|
+
onChange={(event) => setLag(event.target.value)}
|
|
101
|
+
/>
|
|
102
|
+
</label>
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
className="ft_xxs cl_primary"
|
|
106
|
+
disabled={saving}
|
|
107
|
+
onClick={() => void save()}
|
|
108
|
+
>
|
|
109
|
+
{p.labels.save}
|
|
110
|
+
</button>
|
|
111
|
+
<button
|
|
112
|
+
type="button"
|
|
113
|
+
className="ft_xxs cl_lt"
|
|
114
|
+
disabled={saving}
|
|
115
|
+
onClick={() => setEditing(false)}
|
|
116
|
+
>
|
|
117
|
+
{p.labels.cancel}
|
|
118
|
+
</button>
|
|
119
|
+
</div>
|
|
120
|
+
) : null}
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
},
|
|
124
|
+
);
|
|
125
|
+
/* Render incoming or outgoing links with caller-formatted labels and optional editing. */
|
|
126
|
+
export const RelationshipListUI = memo(
|
|
127
|
+
(p: {
|
|
128
|
+
headingText: string;
|
|
129
|
+
emptyText: string;
|
|
130
|
+
removeText: string;
|
|
131
|
+
editText: string;
|
|
132
|
+
typeLabel: string;
|
|
133
|
+
lagLabel: string;
|
|
134
|
+
saveText: string;
|
|
135
|
+
cancelText: string;
|
|
136
|
+
rows: Array<{
|
|
137
|
+
id: string;
|
|
138
|
+
activityId: string;
|
|
139
|
+
text: string;
|
|
140
|
+
isDriving: boolean;
|
|
141
|
+
type?: string;
|
|
142
|
+
lag?: string;
|
|
143
|
+
}>;
|
|
144
|
+
editable?: boolean;
|
|
145
|
+
onSelectActivity: (id: string) => void;
|
|
146
|
+
onDelete: (id: string) => void;
|
|
147
|
+
onEdit?: (id: string, type: string, lag: string) => Promise<boolean>;
|
|
148
|
+
}) => (
|
|
149
|
+
<div className="v_stretch mt_md">
|
|
150
|
+
<span className="ft_xs ft_semibold">{p.headingText}</span>
|
|
151
|
+
{!p.rows.length ? (
|
|
152
|
+
<span className="ft_xxs cl_lt">{p.emptyText}</span>
|
|
153
|
+
) : (
|
|
154
|
+
p.rows.map((row) => (
|
|
155
|
+
<RelationshipRowUI
|
|
156
|
+
key={row.id}
|
|
157
|
+
row={row}
|
|
158
|
+
editable={p.editable}
|
|
159
|
+
labels={{
|
|
160
|
+
remove: p.removeText,
|
|
161
|
+
edit: p.editText,
|
|
162
|
+
type: p.typeLabel,
|
|
163
|
+
lag: p.lagLabel,
|
|
164
|
+
save: p.saveText,
|
|
165
|
+
cancel: p.cancelText,
|
|
166
|
+
}}
|
|
167
|
+
onSelectActivity={p.onSelectActivity}
|
|
168
|
+
onDelete={p.onDelete}
|
|
169
|
+
onEdit={p.onEdit}
|
|
170
|
+
/>
|
|
171
|
+
))
|
|
172
|
+
)}
|
|
173
|
+
</div>
|
|
174
|
+
),
|
|
175
|
+
);
|
|
176
|
+
RelationshipListUI.displayName = 'RelationshipListUI';
|