authscape 1.0.572 → 1.0.574
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/index.js +1035 -3165
- package/package.json +2 -4
- package/src/components/stripe/StripePayment.js +3 -6
- package/src/components/kanban/Action.js +0 -25
- package/src/components/kanban/Container.js +0 -77
- package/src/components/kanban/Handle.js +0 -24
- package/src/components/kanban/Item.js +0 -149
- package/src/components/kanban/Kanban.js +0 -917
- package/src/components/kanban/Remove.js +0 -23
- package/src/components/kanban/createRange.js +0 -5
- package/src/components/kanban/multipleContainersKeyboardCoordinates.js +0 -114
- package/src/components/users/UserEditor.js +0 -590
- package/src/components/users/UserManagement.js +0 -186
|
@@ -1,917 +0,0 @@
|
|
|
1
|
-
import React, {useCallback, useEffect, useRef, useState} from 'react';
|
|
2
|
-
import {createPortal, unstable_batchedUpdates} from 'react-dom';
|
|
3
|
-
import {
|
|
4
|
-
CancelDrop,
|
|
5
|
-
closestCenter,
|
|
6
|
-
pointerWithin,
|
|
7
|
-
rectIntersection,
|
|
8
|
-
CollisionDetection,
|
|
9
|
-
DndContext,
|
|
10
|
-
DragOverlay,
|
|
11
|
-
DropAnimation,
|
|
12
|
-
getFirstCollision,
|
|
13
|
-
KeyboardSensor,
|
|
14
|
-
MouseSensor,
|
|
15
|
-
TouchSensor,
|
|
16
|
-
Modifiers,
|
|
17
|
-
useDroppable,
|
|
18
|
-
UniqueIdentifier,
|
|
19
|
-
useSensors,
|
|
20
|
-
useSensor,
|
|
21
|
-
MeasuringStrategy,
|
|
22
|
-
KeyboardCoordinateGetter,
|
|
23
|
-
defaultDropAnimationSideEffects,
|
|
24
|
-
} from '@dnd-kit/core';
|
|
25
|
-
import {
|
|
26
|
-
AnimateLayoutChanges,
|
|
27
|
-
SortableContext,
|
|
28
|
-
useSortable,
|
|
29
|
-
arrayMove,
|
|
30
|
-
defaultAnimateLayoutChanges,
|
|
31
|
-
verticalListSortingStrategy,
|
|
32
|
-
SortingStrategy,
|
|
33
|
-
horizontalListSortingStrategy,
|
|
34
|
-
} from '@dnd-kit/sortable';
|
|
35
|
-
import {CSS} from '@dnd-kit/utilities';
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/// use in testing
|
|
39
|
-
// import {coordinateGetter as multipleContainersCoordinateGetter} from './multipleContainersKeyboardCoordinates';
|
|
40
|
-
// import { apiService } from 'authscape';
|
|
41
|
-
// import { Item } from './item';
|
|
42
|
-
// import { Container } from './container';
|
|
43
|
-
|
|
44
|
-
import { Box } from '@mui/material';
|
|
45
|
-
|
|
46
|
-
const animateLayoutChanges = (args) =>
|
|
47
|
-
defaultAnimateLayoutChanges({...args, wasDragging: true});
|
|
48
|
-
|
|
49
|
-
function DroppableContainer({
|
|
50
|
-
children,
|
|
51
|
-
columns = 1,
|
|
52
|
-
disabled,
|
|
53
|
-
id,
|
|
54
|
-
containerStyles,
|
|
55
|
-
items,
|
|
56
|
-
disableHandle = false,
|
|
57
|
-
disableDelete = false,
|
|
58
|
-
style,
|
|
59
|
-
...props
|
|
60
|
-
}) {
|
|
61
|
-
const {
|
|
62
|
-
active,
|
|
63
|
-
attributes,
|
|
64
|
-
isDragging,
|
|
65
|
-
listeners,
|
|
66
|
-
over,
|
|
67
|
-
setNodeRef,
|
|
68
|
-
transition,
|
|
69
|
-
transform,
|
|
70
|
-
} = useSortable({
|
|
71
|
-
id,
|
|
72
|
-
data: {
|
|
73
|
-
type: 'container',
|
|
74
|
-
children: items,
|
|
75
|
-
},
|
|
76
|
-
animateLayoutChanges,
|
|
77
|
-
});
|
|
78
|
-
const isOverContainer = over
|
|
79
|
-
? (id === over.id && active?.data.current?.type !== 'container') ||
|
|
80
|
-
items.includes(over.id)
|
|
81
|
-
: false;
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<Container
|
|
85
|
-
ref={disabled ? undefined : setNodeRef}
|
|
86
|
-
disableHandle={disableHandle}
|
|
87
|
-
disableDelete={disableDelete}
|
|
88
|
-
containerStyles={containerStyles}
|
|
89
|
-
style={{
|
|
90
|
-
...style,
|
|
91
|
-
transition,
|
|
92
|
-
transform: CSS.Translate.toString(transform),
|
|
93
|
-
opacity: isDragging ? 0.5 : undefined,
|
|
94
|
-
}}
|
|
95
|
-
hover={isOverContainer}
|
|
96
|
-
handleProps={{
|
|
97
|
-
...attributes,
|
|
98
|
-
...listeners,
|
|
99
|
-
}}
|
|
100
|
-
columns={columns}
|
|
101
|
-
{...props}
|
|
102
|
-
>
|
|
103
|
-
{children}
|
|
104
|
-
</Container>
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const dropAnimation = {
|
|
109
|
-
sideEffects: defaultDropAnimationSideEffects({
|
|
110
|
-
styles: {
|
|
111
|
-
active: {
|
|
112
|
-
opacity: '0.5',
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
}),
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export const TRASH_ID = 'void';
|
|
119
|
-
const PLACEHOLDER_ID = 'placeholder';
|
|
120
|
-
const empty = [];
|
|
121
|
-
|
|
122
|
-
export function Kanban({
|
|
123
|
-
adjustScale = false,
|
|
124
|
-
itemCount = 3,
|
|
125
|
-
cancelDrop,
|
|
126
|
-
Menu = null,
|
|
127
|
-
columns,
|
|
128
|
-
loadedUser = true,
|
|
129
|
-
handle = false,
|
|
130
|
-
CardTemplate = null,
|
|
131
|
-
items: initialItems,
|
|
132
|
-
disableContainerHandle = false,
|
|
133
|
-
disableContainerDelete = false,
|
|
134
|
-
disableAddColumn = false,
|
|
135
|
-
containerStyles,
|
|
136
|
-
itemStyles,
|
|
137
|
-
identifier = null,
|
|
138
|
-
containerStyle,
|
|
139
|
-
coordinateGetter = multipleContainersCoordinateGetter,
|
|
140
|
-
getItemStyles = () => ({}),
|
|
141
|
-
wrapperStyle = () => ({}),
|
|
142
|
-
minimal = false,
|
|
143
|
-
modifiers,
|
|
144
|
-
renderItem,
|
|
145
|
-
strategy = verticalListSortingStrategy,
|
|
146
|
-
trashable = false,
|
|
147
|
-
vertical = false,
|
|
148
|
-
onCardClicked,
|
|
149
|
-
onCardChangedState = null,
|
|
150
|
-
scrollable,
|
|
151
|
-
}) {
|
|
152
|
-
|
|
153
|
-
const [initItems, setInitItems] = useState(null);
|
|
154
|
-
const [cards, setCards] = useState(null);
|
|
155
|
-
const [items, setItems] = useState();
|
|
156
|
-
const [containers, setContainers] = useState();
|
|
157
|
-
|
|
158
|
-
useEffect(() => {
|
|
159
|
-
|
|
160
|
-
if (loadedUser)
|
|
161
|
-
{
|
|
162
|
-
const fetchData = async () => {
|
|
163
|
-
|
|
164
|
-
let response = null;
|
|
165
|
-
if (identifier == null)
|
|
166
|
-
{
|
|
167
|
-
response = await apiService().get("/Kanban/GetKanban");
|
|
168
|
-
}
|
|
169
|
-
else
|
|
170
|
-
{
|
|
171
|
-
response = await apiService().get("/Kanban/GetKanban?identifier=" + identifier);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (response != null && response.status == 200)
|
|
175
|
-
{
|
|
176
|
-
let containers = [];
|
|
177
|
-
let initItems = response.data;
|
|
178
|
-
let cardNames = [];
|
|
179
|
-
let container = {};
|
|
180
|
-
|
|
181
|
-
initItems.forEach(element => {
|
|
182
|
-
|
|
183
|
-
containers.push(element.id);
|
|
184
|
-
|
|
185
|
-
let cards = [];
|
|
186
|
-
element.cards.forEach((card) => {
|
|
187
|
-
cards.push(card.id);
|
|
188
|
-
cardNames.push(card);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
container[element.id] = cards;
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
setInitItems(initItems);
|
|
195
|
-
setCards(cardNames);
|
|
196
|
-
setItems(container);
|
|
197
|
-
setContainers(containers);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
fetchData();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
}, [loadedUser]);
|
|
204
|
-
|
|
205
|
-
const getContainerName = (containerId) => {
|
|
206
|
-
|
|
207
|
-
let name = "";
|
|
208
|
-
initItems.forEach(element => {
|
|
209
|
-
if (containerId == element.id)
|
|
210
|
-
{
|
|
211
|
-
name = element.name;
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
return name;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const getCardName = (cardId) => {
|
|
219
|
-
|
|
220
|
-
let name = "";
|
|
221
|
-
if (cards != null)
|
|
222
|
-
{
|
|
223
|
-
cards.forEach(card => {
|
|
224
|
-
if (cardId == card.id)
|
|
225
|
-
{
|
|
226
|
-
name = card.name;
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
return name;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const getCardDetails = (cardId) => {
|
|
235
|
-
|
|
236
|
-
let cardDetail = {};
|
|
237
|
-
if (cards != null)
|
|
238
|
-
{
|
|
239
|
-
cards.forEach(card => {
|
|
240
|
-
if (cardId == card.id)
|
|
241
|
-
{
|
|
242
|
-
cardDetail = card;
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
return cardDetail;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const [activeId, setActiveId] = useState(null);
|
|
252
|
-
const lastOverId = useRef(null);
|
|
253
|
-
const recentlyMovedToNewContainer = useRef(false);
|
|
254
|
-
const isSortingContainer = activeId ? containers.includes(activeId) : false;
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Custom collision detection strategy optimized for multiple containers
|
|
258
|
-
*
|
|
259
|
-
* - First, find any droppable containers intersecting with the pointer.
|
|
260
|
-
* - If there are none, find intersecting containers with the active draggable.
|
|
261
|
-
* - If there are no intersecting containers, return the last matched intersection
|
|
262
|
-
*
|
|
263
|
-
*/
|
|
264
|
-
const collisionDetectionStrategy = useCallback(
|
|
265
|
-
(args) => {
|
|
266
|
-
if (activeId && activeId in items) {
|
|
267
|
-
return closestCenter({
|
|
268
|
-
...args,
|
|
269
|
-
droppableContainers: args.droppableContainers.filter(
|
|
270
|
-
(container) => container.id in items
|
|
271
|
-
),
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// Start by finding any intersecting droppable
|
|
276
|
-
const pointerIntersections = pointerWithin(args);
|
|
277
|
-
const intersections =
|
|
278
|
-
pointerIntersections.length > 0
|
|
279
|
-
? // If there are droppables intersecting with the pointer, return those
|
|
280
|
-
pointerIntersections
|
|
281
|
-
: rectIntersection(args);
|
|
282
|
-
let overId = getFirstCollision(intersections, 'id');
|
|
283
|
-
|
|
284
|
-
if (overId != null) {
|
|
285
|
-
if (overId === TRASH_ID) {
|
|
286
|
-
// If the intersecting droppable is the trash, return early
|
|
287
|
-
// Remove this if you're not using trashable functionality in your app
|
|
288
|
-
return intersections;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (overId in items) {
|
|
292
|
-
const containerItems = items[overId];
|
|
293
|
-
|
|
294
|
-
// If a container is matched and it contains items (columns 'A', 'B', 'C')
|
|
295
|
-
if (containerItems.length > 0) {
|
|
296
|
-
// Return the closest droppable within that container
|
|
297
|
-
overId = closestCenter({
|
|
298
|
-
...args,
|
|
299
|
-
droppableContainers: args.droppableContainers.filter(
|
|
300
|
-
(container) =>
|
|
301
|
-
container.id !== overId &&
|
|
302
|
-
containerItems.includes(container.id)
|
|
303
|
-
),
|
|
304
|
-
})[0]?.id;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
lastOverId.current = overId;
|
|
309
|
-
|
|
310
|
-
return [{id: overId}];
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// When a draggable item moves to a new container, the layout may shift
|
|
314
|
-
// and the `overId` may become `null`. We manually set the cached `lastOverId`
|
|
315
|
-
// to the id of the draggable item that was moved to the new container, otherwise
|
|
316
|
-
// the previous `overId` will be returned which can cause items to incorrectly shift positions
|
|
317
|
-
if (recentlyMovedToNewContainer.current) {
|
|
318
|
-
lastOverId.current = activeId;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// If no droppable is matched, return the last match
|
|
322
|
-
return lastOverId.current ? [{id: lastOverId.current}] : [];
|
|
323
|
-
},
|
|
324
|
-
[activeId, items]
|
|
325
|
-
);
|
|
326
|
-
const [clonedItems, setClonedItems] = useState(null);
|
|
327
|
-
const sensors = useSensors(
|
|
328
|
-
useSensor(MouseSensor, {
|
|
329
|
-
activationConstraint: { distance: 8 }
|
|
330
|
-
}),
|
|
331
|
-
useSensor(TouchSensor, {
|
|
332
|
-
activationConstraint: { distance: 8 }
|
|
333
|
-
}),
|
|
334
|
-
useSensor(KeyboardSensor, {
|
|
335
|
-
coordinateGetter,
|
|
336
|
-
activationConstraint: { distance: 8 }
|
|
337
|
-
})
|
|
338
|
-
);
|
|
339
|
-
const findContainer = (id) => {
|
|
340
|
-
if (id in items) {
|
|
341
|
-
return id;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
return Object.keys(items).find((key) => items[key].includes(id));
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
const getIndex = (id) => {
|
|
348
|
-
const container = findContainer(id);
|
|
349
|
-
|
|
350
|
-
if (!container) {
|
|
351
|
-
return -1;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
const index = items[container].indexOf(id);
|
|
355
|
-
|
|
356
|
-
return index;
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
const onDragCancel = () => {
|
|
360
|
-
if (clonedItems) {
|
|
361
|
-
// Reset items to their original state in case items have been
|
|
362
|
-
// Dragged across containers
|
|
363
|
-
setItems(clonedItems);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
setActiveId(null);
|
|
367
|
-
setClonedItems(null);
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
useEffect(() => {
|
|
371
|
-
requestAnimationFrame(() => {
|
|
372
|
-
recentlyMovedToNewContainer.current = false;
|
|
373
|
-
});
|
|
374
|
-
}, [items]);
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
|
378
|
-
const [SelectedCardId, setSelectedCardId] = useState(null);
|
|
379
|
-
const open = Boolean(anchorEl);
|
|
380
|
-
const handleMoreClick = (event) => {
|
|
381
|
-
event.stopPropagation();
|
|
382
|
-
setAnchorEl(event.currentTarget);
|
|
383
|
-
};
|
|
384
|
-
const handleMoreClose = () => {
|
|
385
|
-
setAnchorEl(null);
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
return (
|
|
389
|
-
<Box>
|
|
390
|
-
{(loadedUser && containers != null && cards != null && items != null) &&
|
|
391
|
-
<>
|
|
392
|
-
<DndContext
|
|
393
|
-
sensors={sensors}
|
|
394
|
-
collisionDetection={collisionDetectionStrategy}
|
|
395
|
-
measuring={{
|
|
396
|
-
droppable: {
|
|
397
|
-
strategy: MeasuringStrategy.Always,
|
|
398
|
-
},
|
|
399
|
-
}}
|
|
400
|
-
onDragStart={({active}) => {
|
|
401
|
-
setActiveId(active.id);
|
|
402
|
-
setClonedItems(items);
|
|
403
|
-
}}
|
|
404
|
-
onDragOver={({active, over}) => {
|
|
405
|
-
const overId = over?.id;
|
|
406
|
-
|
|
407
|
-
if (overId == null || overId === TRASH_ID || active.id in items) {
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
const overContainer = findContainer(overId);
|
|
412
|
-
const activeContainer = findContainer(active.id);
|
|
413
|
-
|
|
414
|
-
if (!overContainer || !activeContainer) {
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
if (activeContainer !== overContainer) {
|
|
419
|
-
setItems((items) => {
|
|
420
|
-
const activeItems = items[activeContainer];
|
|
421
|
-
const overItems = items[overContainer];
|
|
422
|
-
const overIndex = overItems.indexOf(overId);
|
|
423
|
-
const activeIndex = activeItems.indexOf(active.id);
|
|
424
|
-
|
|
425
|
-
let newIndex;
|
|
426
|
-
|
|
427
|
-
if (overId in items) {
|
|
428
|
-
newIndex = overItems.length + 1;
|
|
429
|
-
} else {
|
|
430
|
-
const isBelowOverItem =
|
|
431
|
-
over &&
|
|
432
|
-
active.rect.current.translated &&
|
|
433
|
-
active.rect.current.translated.top >
|
|
434
|
-
over.rect.top + over.rect.height;
|
|
435
|
-
|
|
436
|
-
const modifier = isBelowOverItem ? 1 : 0;
|
|
437
|
-
|
|
438
|
-
newIndex =
|
|
439
|
-
overIndex >= 0 ? overIndex + modifier : overItems.length + 1;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
recentlyMovedToNewContainer.current = true;
|
|
443
|
-
|
|
444
|
-
return {
|
|
445
|
-
...items,
|
|
446
|
-
[activeContainer]: items[activeContainer].filter(
|
|
447
|
-
(item) => item !== active.id
|
|
448
|
-
),
|
|
449
|
-
[overContainer]: [
|
|
450
|
-
...items[overContainer].slice(0, newIndex),
|
|
451
|
-
items[activeContainer][activeIndex],
|
|
452
|
-
...items[overContainer].slice(
|
|
453
|
-
newIndex,
|
|
454
|
-
items[overContainer].length
|
|
455
|
-
),
|
|
456
|
-
],
|
|
457
|
-
};
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
}}
|
|
461
|
-
onDragEnd={({active, over}) => {
|
|
462
|
-
if (active.id in items && over?.id) {
|
|
463
|
-
setContainers((containers) => {
|
|
464
|
-
const activeIndex = containers.indexOf(active.id);
|
|
465
|
-
const overIndex = containers.indexOf(over.id);
|
|
466
|
-
|
|
467
|
-
let array = arrayMove(containers, activeIndex, overIndex);
|
|
468
|
-
|
|
469
|
-
apiService().put("/Kanban/SetColumnOrder", {
|
|
470
|
-
columnsIds: array
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
// is this correct?
|
|
474
|
-
// onCardChangedState(over.id, active.id);
|
|
475
|
-
|
|
476
|
-
return array;
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
const activeContainer = findContainer(active.id);
|
|
481
|
-
|
|
482
|
-
if (!activeContainer) {
|
|
483
|
-
setActiveId(null);
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
const overId = over?.id;
|
|
488
|
-
|
|
489
|
-
if (overId == null) {
|
|
490
|
-
setActiveId(null);
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
if (overId === TRASH_ID) {
|
|
495
|
-
setItems((items) => ({
|
|
496
|
-
...items,
|
|
497
|
-
[activeContainer]: items[activeContainer].filter(
|
|
498
|
-
(id) => id !== activeId
|
|
499
|
-
),
|
|
500
|
-
}));
|
|
501
|
-
setActiveId(null);
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
if (overId === PLACEHOLDER_ID) {
|
|
506
|
-
const newContainerId = getNextContainerId();
|
|
507
|
-
|
|
508
|
-
unstable_batchedUpdates(() => {
|
|
509
|
-
setContainers((containers) => [...containers, newContainerId]);
|
|
510
|
-
setItems((items) => ({
|
|
511
|
-
...items,
|
|
512
|
-
[activeContainer]: items[activeContainer].filter(
|
|
513
|
-
(id) => id !== activeId
|
|
514
|
-
),
|
|
515
|
-
[newContainerId]: [active.id],
|
|
516
|
-
}));
|
|
517
|
-
setActiveId(null);
|
|
518
|
-
});
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
const overContainer = findContainer(overId);
|
|
523
|
-
|
|
524
|
-
if (overContainer) {
|
|
525
|
-
|
|
526
|
-
// you can't get the item from the key in an array, you need to search for it
|
|
527
|
-
|
|
528
|
-
var name = getContainerName(overContainer);
|
|
529
|
-
|
|
530
|
-
//alert(activeContainer + " \n" + overContainer)
|
|
531
|
-
|
|
532
|
-
const activeIndex = items[activeContainer].indexOf(active.id);
|
|
533
|
-
const overIndex = items[overContainer].indexOf(overId);
|
|
534
|
-
|
|
535
|
-
//alert(activeIndex + " - " + active.id + " !== " + overId + " - " + overIndex)
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
if (activeIndex !== overIndex) {
|
|
540
|
-
|
|
541
|
-
let newArray = arrayMove(
|
|
542
|
-
items[overContainer],
|
|
543
|
-
activeIndex,
|
|
544
|
-
overIndex
|
|
545
|
-
);
|
|
546
|
-
|
|
547
|
-
setItems((items) => ({
|
|
548
|
-
...items,
|
|
549
|
-
[overContainer]: newArray,
|
|
550
|
-
}));
|
|
551
|
-
|
|
552
|
-
// get the items we need to rearrange
|
|
553
|
-
// alert(JSON.stringify(newArray))
|
|
554
|
-
|
|
555
|
-
apiService().put("/Kanban/AssignCardsBasedOnOrder", {
|
|
556
|
-
cardId: active.id,
|
|
557
|
-
columnId: overContainer,
|
|
558
|
-
cards: newArray
|
|
559
|
-
});
|
|
560
|
-
|
|
561
|
-
if (onCardChangedState != null)
|
|
562
|
-
{
|
|
563
|
-
onCardChangedState(overContainer, active.id);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
else
|
|
567
|
-
{
|
|
568
|
-
// assign the order of the cards
|
|
569
|
-
apiService().put("/Kanban/AssignColumnForCard", {
|
|
570
|
-
columnId: overContainer,
|
|
571
|
-
cardId: active.id,
|
|
572
|
-
orderId: 0
|
|
573
|
-
});
|
|
574
|
-
|
|
575
|
-
if (onCardChangedState != null)
|
|
576
|
-
{
|
|
577
|
-
onCardChangedState(overContainer, active.id);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
setActiveId(null);
|
|
583
|
-
}}
|
|
584
|
-
cancelDrop={cancelDrop}
|
|
585
|
-
onDragCancel={onDragCancel}
|
|
586
|
-
modifiers={modifiers}
|
|
587
|
-
>
|
|
588
|
-
<div
|
|
589
|
-
style={{
|
|
590
|
-
display: 'inline-grid',
|
|
591
|
-
boxSizing: 'border-box',
|
|
592
|
-
padding: 20,
|
|
593
|
-
gridAutoFlow: vertical ? 'row' : 'column',
|
|
594
|
-
}}
|
|
595
|
-
>
|
|
596
|
-
<SortableContext
|
|
597
|
-
items={[...containers, PLACEHOLDER_ID]}
|
|
598
|
-
strategy={
|
|
599
|
-
vertical
|
|
600
|
-
? verticalListSortingStrategy
|
|
601
|
-
: horizontalListSortingStrategy
|
|
602
|
-
}
|
|
603
|
-
>
|
|
604
|
-
{containers.map((containerId) => {
|
|
605
|
-
|
|
606
|
-
let containerName = getContainerName(containerId);
|
|
607
|
-
|
|
608
|
-
return (
|
|
609
|
-
<DroppableContainer
|
|
610
|
-
key={containerId}
|
|
611
|
-
containerStyles={containerStyles}
|
|
612
|
-
id={containerId}
|
|
613
|
-
disableHandle={disableContainerHandle}
|
|
614
|
-
disableDelete={disableContainerDelete}
|
|
615
|
-
label={containerName}
|
|
616
|
-
columns={columns}
|
|
617
|
-
items={items[containerId]}
|
|
618
|
-
scrollable={scrollable}
|
|
619
|
-
style={containerStyle}
|
|
620
|
-
unstyled={minimal}
|
|
621
|
-
onRemove={() => handleRemove(containerId)}
|
|
622
|
-
>
|
|
623
|
-
<SortableContext items={items[containerId]} strategy={strategy}>
|
|
624
|
-
{items[containerId].map((value, index) => {
|
|
625
|
-
|
|
626
|
-
return (
|
|
627
|
-
<SortableItem
|
|
628
|
-
disabled={isSortingContainer}
|
|
629
|
-
key={value}
|
|
630
|
-
onCardClicked={onCardClicked}
|
|
631
|
-
itemStyles={itemStyles}
|
|
632
|
-
id={value}
|
|
633
|
-
cardDetail={getCardDetails(value)}
|
|
634
|
-
CardTemplate={CardTemplate}
|
|
635
|
-
handleMoreClick={(event) => {
|
|
636
|
-
handleMoreClick(event);
|
|
637
|
-
setSelectedCardId(value);
|
|
638
|
-
}}
|
|
639
|
-
handleMoreClose={() => {
|
|
640
|
-
handleMoreClose();
|
|
641
|
-
setSelectedCardId(null);
|
|
642
|
-
}}
|
|
643
|
-
name={getCardName(value)}
|
|
644
|
-
index={index}
|
|
645
|
-
handle={handle}
|
|
646
|
-
style={getItemStyles}
|
|
647
|
-
wrapperStyle={wrapperStyle}
|
|
648
|
-
renderItem={renderItem}
|
|
649
|
-
containerId={containerId}
|
|
650
|
-
getIndex={getIndex}
|
|
651
|
-
/>
|
|
652
|
-
);
|
|
653
|
-
})}
|
|
654
|
-
</SortableContext>
|
|
655
|
-
</DroppableContainer>
|
|
656
|
-
)})}
|
|
657
|
-
{minimal ? undefined : (
|
|
658
|
-
<>
|
|
659
|
-
{!disableAddColumn &&
|
|
660
|
-
<DroppableContainer
|
|
661
|
-
id={PLACEHOLDER_ID}
|
|
662
|
-
containerStyles={containerStyles}
|
|
663
|
-
disabled={isSortingContainer}
|
|
664
|
-
items={empty}
|
|
665
|
-
onClick={handleAddColumn}
|
|
666
|
-
placeholder
|
|
667
|
-
>
|
|
668
|
-
+ Add column
|
|
669
|
-
</DroppableContainer>
|
|
670
|
-
}
|
|
671
|
-
</>
|
|
672
|
-
)}
|
|
673
|
-
</SortableContext>
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
</div>
|
|
678
|
-
{createPortal(
|
|
679
|
-
<DragOverlay adjustScale={adjustScale} dropAnimation={dropAnimation}>
|
|
680
|
-
{activeId
|
|
681
|
-
? containers.includes(activeId)
|
|
682
|
-
? renderContainerDragOverlay(CardTemplate, activeId, containerStyles)
|
|
683
|
-
: renderSortableItemDragOverlay(CardTemplate, activeId)
|
|
684
|
-
: null}
|
|
685
|
-
</DragOverlay>,
|
|
686
|
-
document.body
|
|
687
|
-
)}
|
|
688
|
-
{trashable && activeId && !containers.includes(activeId) ? (
|
|
689
|
-
<Trash id={TRASH_ID} />
|
|
690
|
-
) : null}
|
|
691
|
-
</DndContext>
|
|
692
|
-
{Menu != null &&
|
|
693
|
-
<Menu anchorEl={anchorEl} open={open} handleMoreClose={handleMoreClose} cardId={SelectedCardId} />
|
|
694
|
-
}
|
|
695
|
-
</>
|
|
696
|
-
}
|
|
697
|
-
</Box>
|
|
698
|
-
);
|
|
699
|
-
|
|
700
|
-
function renderSortableItemDragOverlay(CardTemplate, id) {
|
|
701
|
-
return (
|
|
702
|
-
<Item
|
|
703
|
-
value={id}
|
|
704
|
-
itemStyles={itemStyles}
|
|
705
|
-
name={getCardName(id)}
|
|
706
|
-
cardDetail={getCardDetails(id)}
|
|
707
|
-
onCardClicked={onCardClicked}
|
|
708
|
-
CardTemplate={CardTemplate}
|
|
709
|
-
handle={handle}
|
|
710
|
-
style={getItemStyles({
|
|
711
|
-
containerId: findContainer(id),
|
|
712
|
-
overIndex: -1,
|
|
713
|
-
index: getIndex(id),
|
|
714
|
-
value: id,
|
|
715
|
-
isSorting: true,
|
|
716
|
-
isDragging: true,
|
|
717
|
-
isDragOverlay: true,
|
|
718
|
-
})}
|
|
719
|
-
color={getColor(id)}
|
|
720
|
-
wrapperStyle={wrapperStyle({index: 0})}
|
|
721
|
-
renderItem={renderItem}
|
|
722
|
-
dragOverlay
|
|
723
|
-
/>
|
|
724
|
-
);
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
function renderContainerDragOverlay(CardTemplate, containerId, containerStyles) {
|
|
728
|
-
return (
|
|
729
|
-
<Container
|
|
730
|
-
label={getContainerName(containerId)}
|
|
731
|
-
containerStyles={containerStyles}
|
|
732
|
-
columns={columns}
|
|
733
|
-
style={{
|
|
734
|
-
height: '100%',
|
|
735
|
-
paddingRight:"10px"
|
|
736
|
-
}}
|
|
737
|
-
shadow
|
|
738
|
-
unstyled={false}
|
|
739
|
-
>
|
|
740
|
-
{items[containerId].map((item, index) => (
|
|
741
|
-
<Item
|
|
742
|
-
key={item}
|
|
743
|
-
onCardClicked={onCardClicked}
|
|
744
|
-
value={item}
|
|
745
|
-
itemStyles={itemStyles}
|
|
746
|
-
CardTemplate={CardTemplate}
|
|
747
|
-
cardDetail={getCardDetails(item)}
|
|
748
|
-
name={getCardName(item)}
|
|
749
|
-
handle={handle}
|
|
750
|
-
style={getItemStyles({
|
|
751
|
-
containerId,
|
|
752
|
-
overIndex: -1,
|
|
753
|
-
index: getIndex(item),
|
|
754
|
-
value: item,
|
|
755
|
-
isDragging: false,
|
|
756
|
-
isSorting: false,
|
|
757
|
-
isDragOverlay: false,
|
|
758
|
-
})}
|
|
759
|
-
color={getColor(item)}
|
|
760
|
-
wrapperStyle={wrapperStyle({index})}
|
|
761
|
-
renderItem={renderItem}
|
|
762
|
-
/>
|
|
763
|
-
))}
|
|
764
|
-
</Container>
|
|
765
|
-
);
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
function handleRemove(containerID) {
|
|
769
|
-
setContainers((containers) =>
|
|
770
|
-
containers.filter((id) => id !== containerID)
|
|
771
|
-
);
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
function handleAddColumn() {
|
|
775
|
-
const newContainerId = getNextContainerId();
|
|
776
|
-
|
|
777
|
-
unstable_batchedUpdates(() => {
|
|
778
|
-
setContainers((containers) => [...containers, newContainerId]);
|
|
779
|
-
setItems((items) => ({
|
|
780
|
-
...items,
|
|
781
|
-
[newContainerId]: [],
|
|
782
|
-
}));
|
|
783
|
-
});
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
function getNextContainerId() {
|
|
787
|
-
const containerIds = Object.keys(items);
|
|
788
|
-
const lastContainerId = containerIds[containerIds.length - 1];
|
|
789
|
-
|
|
790
|
-
return String.fromCharCode(lastContainerId.charCodeAt(0) + 1);
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
function getColor(id) {
|
|
796
|
-
switch (String(id)[0]) {
|
|
797
|
-
case 'A':
|
|
798
|
-
return '#7193f1';
|
|
799
|
-
case 'B':
|
|
800
|
-
return '#ffda6c';
|
|
801
|
-
case 'C':
|
|
802
|
-
return '#00bcd4';
|
|
803
|
-
case 'D':
|
|
804
|
-
return '#ef769f';
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
return undefined;
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
function Trash({id}) {
|
|
811
|
-
const {setNodeRef, isOver} = useDroppable({
|
|
812
|
-
id,
|
|
813
|
-
});
|
|
814
|
-
|
|
815
|
-
return (
|
|
816
|
-
<div
|
|
817
|
-
ref={setNodeRef}
|
|
818
|
-
style={{
|
|
819
|
-
display: 'flex',
|
|
820
|
-
alignItems: 'center',
|
|
821
|
-
justifyContent: 'center',
|
|
822
|
-
position: 'fixed',
|
|
823
|
-
left: '50%',
|
|
824
|
-
marginLeft: -150,
|
|
825
|
-
bottom: 20,
|
|
826
|
-
width: 300,
|
|
827
|
-
height: 60,
|
|
828
|
-
borderRadius: 5,
|
|
829
|
-
border: '1px solid',
|
|
830
|
-
borderColor: isOver ? 'red' : '#DDD',
|
|
831
|
-
}}
|
|
832
|
-
>
|
|
833
|
-
Drop here to delete
|
|
834
|
-
</div>
|
|
835
|
-
);
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
function SortableItem({
|
|
839
|
-
disabled,
|
|
840
|
-
id,
|
|
841
|
-
index,
|
|
842
|
-
handle,
|
|
843
|
-
name,
|
|
844
|
-
renderItem,
|
|
845
|
-
onCardClicked,
|
|
846
|
-
CardTemplate,
|
|
847
|
-
cardDetail,
|
|
848
|
-
handleMoreClick,
|
|
849
|
-
itemStyles,
|
|
850
|
-
handleMoreClose,
|
|
851
|
-
style,
|
|
852
|
-
containerId,
|
|
853
|
-
getIndex,
|
|
854
|
-
wrapperStyle,
|
|
855
|
-
}) {
|
|
856
|
-
const {
|
|
857
|
-
setNodeRef,
|
|
858
|
-
setActivatorNodeRef,
|
|
859
|
-
listeners,
|
|
860
|
-
isDragging,
|
|
861
|
-
isSorting,
|
|
862
|
-
over,
|
|
863
|
-
overIndex,
|
|
864
|
-
transform,
|
|
865
|
-
transition,
|
|
866
|
-
} = useSortable({
|
|
867
|
-
id,
|
|
868
|
-
});
|
|
869
|
-
const mounted = useMountStatus();
|
|
870
|
-
const mountedWhileDragging = isDragging && !mounted;
|
|
871
|
-
|
|
872
|
-
return (
|
|
873
|
-
<Item
|
|
874
|
-
ref={disabled ? undefined : setNodeRef}
|
|
875
|
-
value={id}
|
|
876
|
-
itemStyles={itemStyles}
|
|
877
|
-
onCardClicked={onCardClicked}
|
|
878
|
-
dragging={isDragging}
|
|
879
|
-
sorting={isSorting}
|
|
880
|
-
cardDetail={cardDetail}
|
|
881
|
-
CardTemplate={CardTemplate}
|
|
882
|
-
handleMoreClick={handleMoreClick}
|
|
883
|
-
handleMoreClose={handleMoreClose}
|
|
884
|
-
name={name}
|
|
885
|
-
handle={handle}
|
|
886
|
-
handleProps={handle ? {ref: setActivatorNodeRef} : undefined}
|
|
887
|
-
index={index}
|
|
888
|
-
wrapperStyle={wrapperStyle({index})}
|
|
889
|
-
style={style({
|
|
890
|
-
index,
|
|
891
|
-
value: id,
|
|
892
|
-
isDragging,
|
|
893
|
-
isSorting,
|
|
894
|
-
overIndex: over ? getIndex(over.id) : overIndex,
|
|
895
|
-
containerId,
|
|
896
|
-
})}
|
|
897
|
-
color={getColor(id)}
|
|
898
|
-
transition={transition}
|
|
899
|
-
transform={transform}
|
|
900
|
-
fadeIn={mountedWhileDragging}
|
|
901
|
-
listeners={listeners}
|
|
902
|
-
renderItem={renderItem}
|
|
903
|
-
/>
|
|
904
|
-
);
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
function useMountStatus() {
|
|
908
|
-
const [isMounted, setIsMounted] = useState(false);
|
|
909
|
-
|
|
910
|
-
useEffect(() => {
|
|
911
|
-
const timeout = setTimeout(() => setIsMounted(true), 500);
|
|
912
|
-
|
|
913
|
-
return () => clearTimeout(timeout);
|
|
914
|
-
}, []);
|
|
915
|
-
|
|
916
|
-
return isMounted;
|
|
917
|
-
}
|