react-big-schedule 5.5.2-beta.5 → 6.1.0
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/README.md +6 -0
- package/dist/components/AddMore.js +29 -35
- package/dist/components/AddMorePopover.js +65 -83
- package/dist/components/AgendaEventItem.js +44 -54
- package/dist/components/AgendaResourceEvents.js +55 -65
- package/dist/components/AgendaView.js +50 -53
- package/dist/components/BodyView.js +30 -35
- package/dist/components/DnDContext.js +144 -159
- package/dist/components/DnDSource.js +107 -116
- package/dist/components/EventItem.js +659 -704
- package/dist/components/EventItemPopover.js +74 -83
- package/dist/components/HeaderView.js +81 -91
- package/dist/components/ResourceEvents.js +613 -675
- package/dist/components/ResourceView.js +71 -81
- package/dist/components/SchedulerData.js +1031 -1258
- package/dist/components/SchedulerHeader.js +83 -116
- package/dist/components/SelectedArea.js +18 -22
- package/dist/components/Summary.js +36 -45
- package/dist/components/WrapperFun.js +9 -19
- package/dist/components/index.js +317 -463
- package/dist/config/default.js +6 -12
- package/dist/config/i18n.js +13 -27
- package/dist/config/scheduler.js +8 -13
- package/dist/helper/behaviors.js +53 -61
- package/dist/helper/utility.js +40 -26
- package/dist/index.js +2 -103
- package/dist/sample-data/sample1.js +44 -8
- package/package.json +18 -18
|
@@ -1,125 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
newStart = localeDayjs(event.start).add(localeDayjs(newStart).diff(localeDayjs(new Date(initialStart))), 'ms').format(_default.DATETIME_FORMAT);
|
|
50
|
-
} else if (viewType !== _default.ViewType.Day) {
|
|
51
|
-
var tmpDayjs = localeDayjs(newStart);
|
|
52
|
-
newStart = localeDayjs(event.start).year(tmpDayjs.year()).month(tmpDayjs.month()).date(tmpDayjs.date()).format(_default.DATETIME_FORMAT);
|
|
53
|
-
}
|
|
54
|
-
newEnd = localeDayjs(newStart).add(localeDayjs(event.end).diff(localeDayjs(event.start)), 'ms').format(_default.DATETIME_FORMAT);
|
|
55
|
-
|
|
56
|
-
// if crossResourceMove disabled, slot returns old value
|
|
57
|
-
if (config.crossResourceMove === false) {
|
|
58
|
-
slotId = schedulerData._getEventSlotId(item);
|
|
59
|
-
slotName = undefined;
|
|
60
|
-
var slot = schedulerData.getSlotById(slotId);
|
|
61
|
-
if (slot) slotName = slot.name;
|
|
62
|
-
}
|
|
63
|
-
action = 'Move';
|
|
1
|
+
import { DATETIME_FORMAT, DnDTypes, ViewType } from '../config/default';
|
|
2
|
+
export default class DnDSource {
|
|
3
|
+
constructor(resolveDragObjFunc, DnDEnabled, dndType = DnDTypes.EVENT) {
|
|
4
|
+
this.resolveDragObjFunc = resolveDragObjFunc;
|
|
5
|
+
this.dndType = dndType;
|
|
6
|
+
this.DnDEnabled = DnDEnabled;
|
|
7
|
+
}
|
|
8
|
+
getDragSpec = () => ({
|
|
9
|
+
// beginDrag: (props, monitor, component) => this.resolveDragObjFunc(props),
|
|
10
|
+
beginDrag: props => this.resolveDragObjFunc(props),
|
|
11
|
+
// endDrag: (props, monitor, component) => {
|
|
12
|
+
endDrag: (props, monitor) => {
|
|
13
|
+
if (!monitor.didDrop()) return;
|
|
14
|
+
const {
|
|
15
|
+
moveEvent,
|
|
16
|
+
newEvent,
|
|
17
|
+
schedulerData
|
|
18
|
+
} = props;
|
|
19
|
+
const {
|
|
20
|
+
events,
|
|
21
|
+
config,
|
|
22
|
+
viewType,
|
|
23
|
+
localeDayjs
|
|
24
|
+
} = schedulerData;
|
|
25
|
+
const item = monitor.getItem();
|
|
26
|
+
const type = monitor.getItemType();
|
|
27
|
+
const dropResult = monitor.getDropResult();
|
|
28
|
+
let {
|
|
29
|
+
slotId
|
|
30
|
+
} = dropResult;
|
|
31
|
+
let {
|
|
32
|
+
slotName
|
|
33
|
+
} = dropResult;
|
|
34
|
+
let newStart = dropResult.start;
|
|
35
|
+
let newEnd = dropResult.end;
|
|
36
|
+
const {
|
|
37
|
+
initialStart
|
|
38
|
+
} = dropResult;
|
|
39
|
+
// const { initialEnd } = dropResult;
|
|
40
|
+
let action = 'New';
|
|
41
|
+
const isEvent = type === DnDTypes.EVENT;
|
|
42
|
+
if (isEvent) {
|
|
43
|
+
const event = item;
|
|
44
|
+
if (config.relativeMove) {
|
|
45
|
+
newStart = localeDayjs(event.start).add(localeDayjs(newStart).diff(localeDayjs(new Date(initialStart))), 'ms').format(DATETIME_FORMAT);
|
|
46
|
+
} else if (viewType !== ViewType.Day) {
|
|
47
|
+
const tmpDayjs = localeDayjs(newStart);
|
|
48
|
+
newStart = localeDayjs(event.start).year(tmpDayjs.year()).month(tmpDayjs.month()).date(tmpDayjs.date()).format(DATETIME_FORMAT);
|
|
64
49
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (start >= eStart && start < eEnd || end > eStart && end <= eEnd || eStart >= start && eStart < end || eEnd > start && eEnd <= end) hasConflict = true;
|
|
74
|
-
}
|
|
75
|
-
});
|
|
50
|
+
newEnd = localeDayjs(newStart).add(localeDayjs(event.end).diff(localeDayjs(event.start)), 'ms').format(DATETIME_FORMAT);
|
|
51
|
+
|
|
52
|
+
// if crossResourceMove disabled, slot returns old value
|
|
53
|
+
if (config.crossResourceMove === false) {
|
|
54
|
+
slotId = schedulerData._getEventSlotId(item);
|
|
55
|
+
slotName = undefined;
|
|
56
|
+
const slot = schedulerData.getSlotById(slotId);
|
|
57
|
+
if (slot) slotName = slot.name;
|
|
76
58
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
59
|
+
action = 'Move';
|
|
60
|
+
}
|
|
61
|
+
let hasConflict = false;
|
|
62
|
+
if (config.checkConflict) {
|
|
63
|
+
const start = localeDayjs(newStart);
|
|
64
|
+
const end = localeDayjs(newEnd);
|
|
65
|
+
events.forEach(e => {
|
|
66
|
+
if (schedulerData._getEventSlotId(e) === slotId && (!isEvent || e.id !== item.id)) {
|
|
67
|
+
const eStart = localeDayjs(e.start);
|
|
68
|
+
const eEnd = localeDayjs(e.end);
|
|
69
|
+
if (start >= eStart && start < eEnd || end > eStart && end <= eEnd || eStart >= start && eStart < end || eEnd > start && eEnd <= end) hasConflict = true;
|
|
87
70
|
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
canDrag: function canDrag(props) {
|
|
91
|
-
var schedulerData = props.schedulerData,
|
|
92
|
-
resourceEvents = props.resourceEvents;
|
|
93
|
-
var item = _this.resolveDragObjFunc(props);
|
|
94
|
-
if (schedulerData._isResizing()) return false;
|
|
95
|
-
var config = schedulerData.config;
|
|
96
|
-
return config.movable && (resourceEvents === undefined || !resourceEvents.groupOnly) && (item.movable === undefined || item.movable !== false);
|
|
71
|
+
});
|
|
97
72
|
}
|
|
98
|
-
|
|
73
|
+
if (hasConflict) {
|
|
74
|
+
const {
|
|
75
|
+
conflictOccurred
|
|
76
|
+
} = props;
|
|
77
|
+
if (conflictOccurred !== undefined) {
|
|
78
|
+
conflictOccurred(schedulerData, action, item, type, slotId, slotName, newStart, newEnd);
|
|
79
|
+
} else {
|
|
80
|
+
console.log('Conflict occurred, set conflictOccurred func in Scheduler to handle it');
|
|
81
|
+
}
|
|
82
|
+
} else if (isEvent) {
|
|
83
|
+
if (moveEvent !== undefined) {
|
|
84
|
+
moveEvent(schedulerData, item, slotId, slotName, newStart, newEnd);
|
|
85
|
+
}
|
|
86
|
+
} else if (newEvent !== undefined) newEvent(schedulerData, slotId, slotName, newStart, newEnd, type, item);
|
|
87
|
+
},
|
|
88
|
+
canDrag: props => {
|
|
89
|
+
const {
|
|
90
|
+
schedulerData,
|
|
91
|
+
resourceEvents
|
|
92
|
+
} = props;
|
|
93
|
+
const item = this.resolveDragObjFunc(props);
|
|
94
|
+
if (schedulerData._isResizing()) return false;
|
|
95
|
+
const {
|
|
96
|
+
config
|
|
97
|
+
} = schedulerData;
|
|
98
|
+
return config.movable && (resourceEvents === undefined || !resourceEvents.groupOnly) && (item.movable === undefined || item.movable !== false);
|
|
99
|
+
}
|
|
99
100
|
});
|
|
101
|
+
|
|
100
102
|
// Returns the drag specification for use with useDrag hook
|
|
101
103
|
// This should be called with props from the component using the hook
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
getDragOptions = props => {
|
|
105
|
+
const spec = this.getDragSpec();
|
|
104
106
|
return {
|
|
105
|
-
type:
|
|
106
|
-
item:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
canDrag: function canDrag() {
|
|
113
|
-
return spec.canDrag(props);
|
|
114
|
-
},
|
|
115
|
-
collect: function collect(monitor) {
|
|
116
|
-
return {
|
|
117
|
-
isDragging: monitor.isDragging()
|
|
118
|
-
};
|
|
119
|
-
}
|
|
107
|
+
type: this.dndType,
|
|
108
|
+
item: () => spec.beginDrag(props),
|
|
109
|
+
end: (_item, monitor) => spec.endDrag(props, monitor),
|
|
110
|
+
canDrag: () => spec.canDrag(props),
|
|
111
|
+
collect: monitor => ({
|
|
112
|
+
isDragging: monitor.isDragging()
|
|
113
|
+
})
|
|
120
114
|
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
this.dndType = dndType;
|
|
124
|
-
this.DnDEnabled = DnDEnabled;
|
|
125
|
-
});
|
|
115
|
+
};
|
|
116
|
+
}
|