@jsb188/calendar 1.1.11 → 1.1.12
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 +14 -15
- package/src/constants/calendar.ts +9 -2
- package/src/libs/calendar-geometry.ts +2 -4
- package/src/libs/calendar-range.ts +2 -0
- package/src/libs/calendar-state.ts +21 -163
- package/src/libs/calendar-url.ts +24 -0
- package/src/libs/roster-layout.ts +388 -0
- package/src/modules/Calendar.tsx +26 -32
- package/src/modules/MiniCalendar.tsx +9 -3
- package/src/types/calendar.d.ts +7 -1
- package/src/types/shift-form.d.ts +19 -0
- package/src/ui/CalendarAgendaUI.tsx +26 -17
- package/src/ui/CalendarMonthUI.tsx +17 -9
- package/src/ui/CalendarToolbarUI.tsx +34 -20
- package/src/ui/CalendarUI.tsx +37 -9
- package/src/ui/RosterUI.tsx +273 -0
- package/src/ui/ShiftFormUI.tsx +333 -0
- package/tests/calendar-geometry.test.ts +4 -6
- package/tests/calendar-url.test.ts +22 -0
- package/tests/roster-layout.test.ts +210 -0
- package/src/ui/CalendarCoverageUI.tsx +0 -242
- package/src/ui/CalendarEventDetailUI.tsx +0 -265
- package/src/ui/CalendarEventFormUI.tsx +0 -266
- package/src/ui/CalendarRailUI.tsx +0 -342
- package/src/ui/CalendarRequestUI.tsx +0 -576
- package/src/ui/CalendarViolationUI.tsx +0 -230
|
@@ -3,6 +3,14 @@ import { memo } from 'react';
|
|
|
3
3
|
import { CALENDAR_DRAFT_PATTERN_CLASS_NAME } from '../constants/calendar.ts';
|
|
4
4
|
import type { CalendarMonthCellObj } from '../libs/calendar-geometry.ts';
|
|
5
5
|
|
|
6
|
+
const FILE_CONSTANTS = {
|
|
7
|
+
weekdayStyle: { paddingTop: 4, paddingBottom: 4 },
|
|
8
|
+
dayButtonStyle: { paddingLeft: 4, paddingRight: 4, paddingTop: 2 },
|
|
9
|
+
eventsStyle: { paddingLeft: 2, paddingRight: 2 },
|
|
10
|
+
eventStyle: { paddingLeft: 3, paddingRight: 3, marginBottom: 1 },
|
|
11
|
+
overflowStyle: { paddingLeft: 3, paddingRight: 3 },
|
|
12
|
+
};
|
|
13
|
+
|
|
6
14
|
/**
|
|
7
15
|
* The month grid.
|
|
8
16
|
*
|
|
@@ -47,8 +55,8 @@ export const CalendarMonthUI = memo((p: CalendarMonthUIProps) => {
|
|
|
47
55
|
{weekdayLabels.map((label) => (
|
|
48
56
|
<div
|
|
49
57
|
key={label}
|
|
50
|
-
className="f a_c
|
|
51
|
-
style={
|
|
58
|
+
className="f a_c ft_xxs cl_lt"
|
|
59
|
+
style={FILE_CONSTANTS.weekdayStyle}
|
|
52
60
|
>
|
|
53
61
|
{label}
|
|
54
62
|
</div>
|
|
@@ -77,12 +85,12 @@ export const CalendarMonthUI = memo((p: CalendarMonthUIProps) => {
|
|
|
77
85
|
<button
|
|
78
86
|
type="button"
|
|
79
87
|
className="w_f a_l"
|
|
80
|
-
style={
|
|
88
|
+
style={FILE_CONSTANTS.dayButtonStyle}
|
|
81
89
|
onClick={() => onSelectDay(cell.day.dateKey)}
|
|
82
90
|
>
|
|
83
91
|
<span
|
|
84
92
|
className={cn(
|
|
85
|
-
'
|
|
93
|
+
'ft_xxs',
|
|
86
94
|
cell.day.isToday ? 'ft_bold' : '',
|
|
87
95
|
// A leading or trailing day belongs to the
|
|
88
96
|
// neighbouring month; dimmed, not hidden
|
|
@@ -93,13 +101,13 @@ export const CalendarMonthUI = memo((p: CalendarMonthUIProps) => {
|
|
|
93
101
|
</span>
|
|
94
102
|
</button>
|
|
95
103
|
|
|
96
|
-
<div style={
|
|
104
|
+
<div style={FILE_CONSTANTS.eventsStyle}>
|
|
97
105
|
{cell.events.map((event) => (
|
|
98
106
|
<button
|
|
99
107
|
key={event.id}
|
|
100
108
|
type="button"
|
|
101
109
|
className={cn(
|
|
102
|
-
'w_f a_l ellip
|
|
110
|
+
'w_f a_l ellip ft_xxs r_xs rel of',
|
|
103
111
|
event.status === 'DRAFT'
|
|
104
112
|
? CALENDAR_DRAFT_PATTERN_CLASS_NAME
|
|
105
113
|
: '',
|
|
@@ -107,7 +115,7 @@ export const CalendarMonthUI = memo((p: CalendarMonthUIProps) => {
|
|
|
107
115
|
event.isMine ? 'bg_active' : 'bg_alt',
|
|
108
116
|
selectedEventId === event.id ? 'bd_1 bd_bd' : '',
|
|
109
117
|
)}
|
|
110
|
-
style={
|
|
118
|
+
style={FILE_CONSTANTS.eventStyle}
|
|
111
119
|
onClick={() => onSelectEvent(event.id)}
|
|
112
120
|
>
|
|
113
121
|
{event.title}
|
|
@@ -117,8 +125,8 @@ export const CalendarMonthUI = memo((p: CalendarMonthUIProps) => {
|
|
|
117
125
|
{cell.overflowCount > 0 ? (
|
|
118
126
|
<button
|
|
119
127
|
type="button"
|
|
120
|
-
className="w_f a_l ellip
|
|
121
|
-
style={
|
|
128
|
+
className="w_f a_l ellip ft_xxs cl_lt"
|
|
129
|
+
style={FILE_CONSTANTS.overflowStyle}
|
|
122
130
|
onClick={() => onSelectOverflow(cell.day.dateKey)}
|
|
123
131
|
>
|
|
124
132
|
{moreLabel(cell.overflowCount)}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { cn } from '@jsb188/app/utils/string.ts';
|
|
2
|
-
import {
|
|
3
|
-
Button,
|
|
4
|
-
SegmentedControl,
|
|
5
|
-
type SegmentedControlOption,
|
|
6
|
-
} from '@jsb188/react-web/ui/Button';
|
|
7
|
-
import { ToggleSwitch } from '@jsb188/react-web/ui/Form';
|
|
8
1
|
import { Icon } from '@jsb188/react-web/svgs/Icon';
|
|
2
|
+
import { Button, SegmentedControl, type SegmentedControlOption } from '@jsb188/react-web/ui/Button';
|
|
3
|
+
import { ToggleSwitch } from '@jsb188/form/ui/Form';
|
|
9
4
|
import { memo } from 'react';
|
|
10
5
|
|
|
11
6
|
/**
|
|
@@ -18,6 +13,7 @@ import { memo } from 'react';
|
|
|
18
13
|
*/
|
|
19
14
|
|
|
20
15
|
export interface CalendarToolbarUIProps {
|
|
16
|
+
compact?: boolean;
|
|
21
17
|
// The range heading, e.g. "Jul 19 – 25, 2026"
|
|
22
18
|
title: string;
|
|
23
19
|
viewOptions: SegmentedControlOption[];
|
|
@@ -54,7 +50,7 @@ export const CalendarToolbarUI = memo((p: CalendarToolbarUIProps) => {
|
|
|
54
50
|
|
|
55
51
|
return (
|
|
56
52
|
<div
|
|
57
|
-
className="no_shrink h_item gap_sm bd_b_1 bd_b_bd"
|
|
53
|
+
className="no_shrink h_item f_wrap gap_sm bd_b_1 bd_b_bd"
|
|
58
54
|
style={{
|
|
59
55
|
paddingLeft: 12,
|
|
60
56
|
paddingRight: 12,
|
|
@@ -91,7 +87,7 @@ export const CalendarToolbarUI = memo((p: CalendarToolbarUIProps) => {
|
|
|
91
87
|
<Icon name="arrow-right" />
|
|
92
88
|
</button>
|
|
93
89
|
|
|
94
|
-
<span className=
|
|
90
|
+
<span className="f ellip ft_md ft_bold">{title}</span>
|
|
95
91
|
|
|
96
92
|
<label className="h_item gap_sm pointer unsel no_shrink">
|
|
97
93
|
<ToggleSwitch
|
|
@@ -99,19 +95,37 @@ export const CalendarToolbarUI = memo((p: CalendarToolbarUIProps) => {
|
|
|
99
95
|
checked={mineOnly}
|
|
100
96
|
onChange={(event) => onToggleMineOnly(event.currentTarget.checked)}
|
|
101
97
|
/>
|
|
102
|
-
<span className="
|
|
98
|
+
<span className="ft_xxs cl_md">{mineOnlyText}</span>
|
|
103
99
|
</label>
|
|
104
100
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
101
|
+
{p.compact ? (
|
|
102
|
+
<select
|
|
103
|
+
className="p_8 bd_1 bd_bd r_sm"
|
|
104
|
+
aria-label={p.title}
|
|
105
|
+
value={selectedView}
|
|
106
|
+
onChange={(event) => onSelectView(event.target.value)}
|
|
107
|
+
>
|
|
108
|
+
{viewOptions.map((option) => (
|
|
109
|
+
<option
|
|
110
|
+
key={option.value}
|
|
111
|
+
value={option.value}
|
|
112
|
+
>
|
|
113
|
+
{option.text}
|
|
114
|
+
</option>
|
|
115
|
+
))}
|
|
116
|
+
</select>
|
|
117
|
+
) : (
|
|
118
|
+
<SegmentedControl
|
|
119
|
+
className="no_shrink ft_sm"
|
|
120
|
+
heightClassName="h_30"
|
|
121
|
+
borderRadiusClassName="r_df"
|
|
122
|
+
selectedBorderRadiusClassName="r_smw"
|
|
123
|
+
gapSize={3}
|
|
124
|
+
options={viewOptions}
|
|
125
|
+
selectedValue={selectedView}
|
|
126
|
+
onClickItem={(_event, value) => onSelectView(value)}
|
|
127
|
+
/>
|
|
128
|
+
)}
|
|
115
129
|
|
|
116
130
|
{RightComponent}
|
|
117
131
|
</div>
|
package/src/ui/CalendarUI.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import i18n from '@jsb188/app/i18n/index.ts';
|
|
1
2
|
import { cn } from '@jsb188/app/utils/string.ts';
|
|
2
3
|
import { memo } from 'react';
|
|
3
4
|
import {
|
|
@@ -39,11 +40,14 @@ export const CalendarTimeGutterUI = memo(
|
|
|
39
40
|
const { hourHeight, hourLabels } = p;
|
|
40
41
|
|
|
41
42
|
return (
|
|
42
|
-
<div
|
|
43
|
+
<div
|
|
44
|
+
className="no_shrink rel"
|
|
45
|
+
style={{ width: CALENDAR_GUTTER_WIDTH }}
|
|
46
|
+
>
|
|
43
47
|
{hourLabels.map((label, hour) => (
|
|
44
48
|
<div
|
|
45
49
|
key={hour}
|
|
46
|
-
className="abs w_f a_r
|
|
50
|
+
className="abs w_f a_r ft_xxs cl_lt"
|
|
47
51
|
// Pulled up by half a line so the label sits ON its gridline
|
|
48
52
|
// rather than hanging below it. Midnight is unlabelled: it is
|
|
49
53
|
// the day boundary the header already names.
|
|
@@ -85,8 +89,14 @@ export const CalendarHourLinesUI = memo(
|
|
|
85
89
|
|
|
86
90
|
export const CalendarNowLineUI = memo((p: { topOffset: number }) => {
|
|
87
91
|
return (
|
|
88
|
-
<div
|
|
89
|
-
|
|
92
|
+
<div
|
|
93
|
+
className="abs w_f z3"
|
|
94
|
+
style={{ top: p.topOffset }}
|
|
95
|
+
>
|
|
96
|
+
<div
|
|
97
|
+
className="bg_red"
|
|
98
|
+
style={{ height: 2 }}
|
|
99
|
+
/>
|
|
90
100
|
</div>
|
|
91
101
|
);
|
|
92
102
|
});
|
|
@@ -149,6 +159,8 @@ export const CalendarEventUI = memo(
|
|
|
149
159
|
selected ? 'z3' : 'z2',
|
|
150
160
|
getCalendarEventStatusClassName(event.status),
|
|
151
161
|
event.isMine ? 'bg_active' : 'bg_alt',
|
|
162
|
+
event.pending ? 'op_60' : '',
|
|
163
|
+
event.kind === 'BLOCK' ? 'pattern_texture cl_lt' : '',
|
|
152
164
|
)}
|
|
153
165
|
style={{
|
|
154
166
|
top,
|
|
@@ -170,11 +182,25 @@ export const CalendarEventUI = memo(
|
|
|
170
182
|
aria-current={selected ? 'true' : undefined}
|
|
171
183
|
data-calendar-event-id={event.id}
|
|
172
184
|
>
|
|
173
|
-
<span className="ellip
|
|
185
|
+
<span className="ellip ft_xxs ft_bold">{event.title}</span>
|
|
186
|
+
{event.breach ? (
|
|
187
|
+
<span
|
|
188
|
+
className={cn(
|
|
189
|
+
'abs r_5',
|
|
190
|
+
event.breach === 'BLOCK' ? 'bg_err' : 'bg_warn',
|
|
191
|
+
)}
|
|
192
|
+
style={{ width: 6, height: 6, right: 3, top: 3 }}
|
|
193
|
+
/>
|
|
194
|
+
) : null}
|
|
195
|
+
{(event.openCount || 0) > 0 ? (
|
|
196
|
+
<span className="pill bg_amber_alt_lt ft_xxs">
|
|
197
|
+
{i18n.t('calendar.open_count', { count: event.openCount })}
|
|
198
|
+
</span>
|
|
199
|
+
) : null}
|
|
174
200
|
|
|
175
201
|
{/* Below roughly 40 minutes there is only room for one line */}
|
|
176
202
|
{height >= 32 ? (
|
|
177
|
-
<span className="ellip
|
|
203
|
+
<span className="ellip ft_xxs cl_lt">{timeLabel}</span>
|
|
178
204
|
) : null}
|
|
179
205
|
|
|
180
206
|
{/* Resize grips. Only offered when the block is tall enough to leave
|
|
@@ -259,9 +285,11 @@ export const CalendarAllDayBandUI = memo(
|
|
|
259
285
|
key={bar.event.id}
|
|
260
286
|
type="button"
|
|
261
287
|
className={cn(
|
|
262
|
-
'abs of a_l r_xs ellip
|
|
288
|
+
'abs of a_l r_xs ellip ft_xxs',
|
|
263
289
|
getCalendarEventStatusClassName(bar.event.status),
|
|
264
290
|
bar.event.isMine ? 'bg_active' : 'bg_alt',
|
|
291
|
+
bar.event.pending ? 'op_60' : '',
|
|
292
|
+
bar.event.kind === 'BLOCK' ? 'pattern_texture cl_lt' : '',
|
|
265
293
|
selectedEventId === bar.event.id ? 'z3' : 'z2',
|
|
266
294
|
)}
|
|
267
295
|
style={{
|
|
@@ -316,7 +344,7 @@ export const CalendarDayHeaderUI = memo(
|
|
|
316
344
|
disabled={!onSelectDay}
|
|
317
345
|
onClick={onSelectDay ? () => onSelectDay(day.dateKey) : undefined}
|
|
318
346
|
>
|
|
319
|
-
<span className="ellip
|
|
347
|
+
<span className="ellip ft_xxs cl_lt">
|
|
320
348
|
{dayLabels[index]?.weekday}
|
|
321
349
|
</span>
|
|
322
350
|
<span
|
|
@@ -366,7 +394,7 @@ export const CalendarDraftBlockUI = memo(
|
|
|
366
394
|
pointerEvents: 'none',
|
|
367
395
|
}}
|
|
368
396
|
>
|
|
369
|
-
<span className="ellip
|
|
397
|
+
<span className="ellip ft_xxs ft_bold">{label}</span>
|
|
370
398
|
</div>
|
|
371
399
|
);
|
|
372
400
|
},
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import i18n from '@jsb188/app/i18n/index.ts';
|
|
2
|
+
import { cn } from '@jsb188/app/utils/string.ts';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import type { RosterLayoutObj } from '../libs/roster-layout.ts';
|
|
5
|
+
|
|
6
|
+
/* Render an accessible people-by-day grid with one row per worker and visible open staffing seats. */
|
|
7
|
+
export const RosterUI = memo(
|
|
8
|
+
(p: {
|
|
9
|
+
layout: RosterLayoutObj;
|
|
10
|
+
editable: boolean;
|
|
11
|
+
narrow?: boolean;
|
|
12
|
+
selectedDay?: string;
|
|
13
|
+
onSelectDay: (dateKey: string) => void;
|
|
14
|
+
onSelectOccurrence: (id: string) => void;
|
|
15
|
+
onCreate: (
|
|
16
|
+
dateKey: string,
|
|
17
|
+
resourceId: string | null,
|
|
18
|
+
roomId: string | null,
|
|
19
|
+
) => void;
|
|
20
|
+
onReassign?: (
|
|
21
|
+
occurrenceId: string,
|
|
22
|
+
assignmentId: string,
|
|
23
|
+
resourceId: string,
|
|
24
|
+
) => void;
|
|
25
|
+
onOpenShifts: (roomId: string | null, dateKey: string) => void;
|
|
26
|
+
}) => {
|
|
27
|
+
const indexes = p.narrow
|
|
28
|
+
? [
|
|
29
|
+
Math.max(
|
|
30
|
+
0,
|
|
31
|
+
p.layout.days.findIndex((day) => day.dateKey === p.selectedDay),
|
|
32
|
+
),
|
|
33
|
+
]
|
|
34
|
+
: p.layout.days.map((_, index) => index);
|
|
35
|
+
return (
|
|
36
|
+
<div className="f h_0 auto_x auto_y app_scr">
|
|
37
|
+
{p.narrow ? (
|
|
38
|
+
<div className="h_item gap_xs p_8">
|
|
39
|
+
{p.layout.days.map((day) => (
|
|
40
|
+
<button
|
|
41
|
+
key={day.dateKey}
|
|
42
|
+
type="button"
|
|
43
|
+
className={cn(
|
|
44
|
+
'f p_8 r_sm',
|
|
45
|
+
day.dateKey === p.selectedDay ? 'bg_active' : 'bg_alt',
|
|
46
|
+
)}
|
|
47
|
+
onClick={() => p.onSelectDay(day.dateKey)}
|
|
48
|
+
>
|
|
49
|
+
{day.label}
|
|
50
|
+
</button>
|
|
51
|
+
))}
|
|
52
|
+
</div>
|
|
53
|
+
) : null}
|
|
54
|
+
<div
|
|
55
|
+
role="grid"
|
|
56
|
+
aria-label={i18n.t('calendar.roster')}
|
|
57
|
+
style={{
|
|
58
|
+
display: 'grid',
|
|
59
|
+
gridTemplateColumns: p.narrow
|
|
60
|
+
? '114px minmax(160px,1fr) 56px'
|
|
61
|
+
: `200px repeat(${indexes.length},minmax(130px,1fr)) 64px`,
|
|
62
|
+
minWidth: p.narrow ? 0 : 1000,
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
<div className="sticky_top sticky_left bg z3 p_8 ft_bold">
|
|
66
|
+
{i18n.t('schedule.resources')}
|
|
67
|
+
</div>
|
|
68
|
+
{indexes.map((index) => (
|
|
69
|
+
<button
|
|
70
|
+
key={index}
|
|
71
|
+
className="sticky_top bg z2 p_8 bd_b_1 bd_b_bd"
|
|
72
|
+
type="button"
|
|
73
|
+
onClick={() => p.onSelectDay(p.layout.days[index].dateKey)}
|
|
74
|
+
>
|
|
75
|
+
<span className="ft_bold">{p.layout.days[index].label}</span>
|
|
76
|
+
<span
|
|
77
|
+
className={cn(
|
|
78
|
+
'bl ft_xxs',
|
|
79
|
+
p.layout.days[index].breach === 'BLOCK' ? 'cl_err' : 'cl_md',
|
|
80
|
+
)}
|
|
81
|
+
>
|
|
82
|
+
{i18n.t('calendar.staff_count', {
|
|
83
|
+
count: p.layout.days[index].staffCount,
|
|
84
|
+
})}{' '}
|
|
85
|
+
·{' '}
|
|
86
|
+
{i18n.t('calendar.open_count', {
|
|
87
|
+
count: p.layout.days[index].openCount,
|
|
88
|
+
})}
|
|
89
|
+
</span>
|
|
90
|
+
</button>
|
|
91
|
+
))}
|
|
92
|
+
<div
|
|
93
|
+
className="sticky_top bg z2 p_4 ft_xxs"
|
|
94
|
+
style={{ whiteSpace: 'nowrap' }}
|
|
95
|
+
>
|
|
96
|
+
{i18n.t('calendar.hours_week')}
|
|
97
|
+
</div>
|
|
98
|
+
{p.layout.rows.map((row) => (
|
|
99
|
+
<div
|
|
100
|
+
key={row.key}
|
|
101
|
+
role="row"
|
|
102
|
+
style={{ display: 'contents' }}
|
|
103
|
+
>
|
|
104
|
+
<div
|
|
105
|
+
role="rowheader"
|
|
106
|
+
style={{ top: 'auto', bottom: 'auto' }}
|
|
107
|
+
className={cn(
|
|
108
|
+
'sticky_left bg z1 p_8 bd_b_1 bd_b_bd ellip',
|
|
109
|
+
row.kind === 'GROUP' ? 'ft_bold bg_alt' : 'ft_sm',
|
|
110
|
+
row.breach === 'BLOCK'
|
|
111
|
+
? 'cl_err'
|
|
112
|
+
: row.breach === 'WARN'
|
|
113
|
+
? 'cl_warn'
|
|
114
|
+
: '',
|
|
115
|
+
)}
|
|
116
|
+
>
|
|
117
|
+
{row.kind === 'OPEN'
|
|
118
|
+
? i18n.t('calendar.roster_open_row')
|
|
119
|
+
: row.name || i18n.t('calendar.no_room')}
|
|
120
|
+
</div>
|
|
121
|
+
{indexes.map((index) => {
|
|
122
|
+
const cell = row.cells[index];
|
|
123
|
+
return (
|
|
124
|
+
<div
|
|
125
|
+
key={cell.dateKey}
|
|
126
|
+
role="gridcell"
|
|
127
|
+
onDragOver={(event) => {
|
|
128
|
+
if (p.editable && row.kind === 'PERSON')
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
}}
|
|
131
|
+
onDrop={(event) => {
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
if (!p.editable || !row.resourceId) return;
|
|
134
|
+
try {
|
|
135
|
+
const drag = JSON.parse(
|
|
136
|
+
event.dataTransfer.getData(
|
|
137
|
+
'application/x-schedule-assignment',
|
|
138
|
+
),
|
|
139
|
+
);
|
|
140
|
+
if (
|
|
141
|
+
drag.dateKey === cell.dateKey &&
|
|
142
|
+
drag.resourceId !== row.resourceId &&
|
|
143
|
+
typeof drag.occurrenceId === 'string' &&
|
|
144
|
+
typeof drag.assignmentId === 'string'
|
|
145
|
+
)
|
|
146
|
+
p.onReassign?.(
|
|
147
|
+
drag.occurrenceId,
|
|
148
|
+
drag.assignmentId,
|
|
149
|
+
row.resourceId,
|
|
150
|
+
);
|
|
151
|
+
} catch {}
|
|
152
|
+
}}
|
|
153
|
+
className={cn(
|
|
154
|
+
'p_4 bd_b_1 bd_b_bd bd_l_1 bd_l_bd',
|
|
155
|
+
row.kind === 'GROUP' ? 'bg_alt' : '',
|
|
156
|
+
cell.timeOff?.status === 'APPROVED'
|
|
157
|
+
? 'bg_alt'
|
|
158
|
+
: cell.timeOff
|
|
159
|
+
? 'pattern_stripes medium_bf rel'
|
|
160
|
+
: '',
|
|
161
|
+
)}
|
|
162
|
+
style={{ minHeight: 48 }}
|
|
163
|
+
>
|
|
164
|
+
{cell.timeOff ? (
|
|
165
|
+
<span className="bl ft_xxs cl_md">
|
|
166
|
+
{i18n.t('schedule.time_off')}
|
|
167
|
+
</span>
|
|
168
|
+
) : null}
|
|
169
|
+
{row.kind === 'OPEN' ? (
|
|
170
|
+
cell.openCount > 0 ? (
|
|
171
|
+
<button
|
|
172
|
+
type="button"
|
|
173
|
+
className={cn(
|
|
174
|
+
'pill p_8',
|
|
175
|
+
cell.breach === 'BLOCK'
|
|
176
|
+
? 'bg_red_alt_lt'
|
|
177
|
+
: 'bg_amber_alt_lt',
|
|
178
|
+
)}
|
|
179
|
+
onClick={() =>
|
|
180
|
+
p.onOpenShifts(row.roomId, cell.dateKey)
|
|
181
|
+
}
|
|
182
|
+
>
|
|
183
|
+
{i18n.t('calendar.open_count', {
|
|
184
|
+
count: cell.openCount,
|
|
185
|
+
})}
|
|
186
|
+
</button>
|
|
187
|
+
) : null
|
|
188
|
+
) : (
|
|
189
|
+
cell.chips.map((chip) => (
|
|
190
|
+
<button
|
|
191
|
+
type="button"
|
|
192
|
+
key={chip.assignmentId || chip.occurrenceId}
|
|
193
|
+
draggable={
|
|
194
|
+
p.editable &&
|
|
195
|
+
!!chip.assignmentId &&
|
|
196
|
+
chip.status !== 'CANCELED'
|
|
197
|
+
}
|
|
198
|
+
onDragStart={(event) => {
|
|
199
|
+
event.dataTransfer.setData(
|
|
200
|
+
'application/x-schedule-assignment',
|
|
201
|
+
JSON.stringify({
|
|
202
|
+
occurrenceId: chip.occurrenceId,
|
|
203
|
+
assignmentId: chip.assignmentId,
|
|
204
|
+
resourceId: row.resourceId,
|
|
205
|
+
dateKey: cell.dateKey,
|
|
206
|
+
}),
|
|
207
|
+
);
|
|
208
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
209
|
+
}}
|
|
210
|
+
className={cn(
|
|
211
|
+
'bl w_f a_l r_sm px_4 py_2 ft_xxs bd_1 bd_bd',
|
|
212
|
+
chip.status === 'DRAFT'
|
|
213
|
+
? 'pattern_stripes medium_bf rel'
|
|
214
|
+
: '',
|
|
215
|
+
chip.status === 'CANCELED'
|
|
216
|
+
? 'strikethrough op_50'
|
|
217
|
+
: '',
|
|
218
|
+
chip.isMine ? 'bg_active' : 'bg_alt',
|
|
219
|
+
chip.breach === 'BLOCK'
|
|
220
|
+
? 'bd_red_md'
|
|
221
|
+
: chip.breach === 'WARN'
|
|
222
|
+
? 'bd_amber_md'
|
|
223
|
+
: '',
|
|
224
|
+
)}
|
|
225
|
+
onClick={() =>
|
|
226
|
+
p.onSelectOccurrence(chip.occurrenceId)
|
|
227
|
+
}
|
|
228
|
+
>
|
|
229
|
+
<span className="bl ellip ft_bold">{chip.title}</span>
|
|
230
|
+
<span>
|
|
231
|
+
{chip.startLabel}–{chip.endLabel}
|
|
232
|
+
{chip.overnight ? ' →' : ''}
|
|
233
|
+
</span>
|
|
234
|
+
{chip.roomName ? (
|
|
235
|
+
<span className="bl ellip cl_md">
|
|
236
|
+
{chip.roomName}
|
|
237
|
+
</span>
|
|
238
|
+
) : null}
|
|
239
|
+
</button>
|
|
240
|
+
))
|
|
241
|
+
)}
|
|
242
|
+
{row.kind === 'PERSON' &&
|
|
243
|
+
p.editable &&
|
|
244
|
+
!cell.chips.length ? (
|
|
245
|
+
<button
|
|
246
|
+
type="button"
|
|
247
|
+
className="w_f p_8 cl_lt"
|
|
248
|
+
aria-label={i18n.t('calendar.new_shift')}
|
|
249
|
+
onClick={() =>
|
|
250
|
+
p.onCreate(cell.dateKey, row.resourceId, row.roomId)
|
|
251
|
+
}
|
|
252
|
+
>
|
|
253
|
+
+
|
|
254
|
+
</button>
|
|
255
|
+
) : null}
|
|
256
|
+
</div>
|
|
257
|
+
);
|
|
258
|
+
})}
|
|
259
|
+
<div
|
|
260
|
+
className={cn(
|
|
261
|
+
'p_8 bd_b_1 bd_b_bd ft_xxs',
|
|
262
|
+
row.kind === 'GROUP' ? 'bg_alt' : '',
|
|
263
|
+
)}
|
|
264
|
+
>
|
|
265
|
+
{row.kind === 'PERSON' ? (row.weekMinutes / 60).toFixed(1) : ''}
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
))}
|
|
269
|
+
</div>
|
|
270
|
+
</div>
|
|
271
|
+
);
|
|
272
|
+
},
|
|
273
|
+
);
|