| Issue 2004: | duration property for externally-dragged event | |
| 4 people starred this issue and may be notified of changes. | Back to list |
I need to set the defaultEventMinutes for the event directly, is it possible? I have 3 external draggable events and all events should have other duration (first should take 10 minutes. second 20 minutes and third 40 minutes), so when I set the full calendar property defaultEventMinutes to 20 minutes, it is not good because when I am dragging the event to the calendar it shows me only these 20 minutes in different color to drop. I cannot set the end date of the event because even the start date of the event is not known.
Oct 8, 2013
Project Member
#1
adamrs...@gmail.com
Status:
Done
Oct 9, 2013
Thank you for advice but this is clear. I need something else. When u are dragging the external event to the fullcalendar and you still hold the mouse button, u see the light blue efect (where the event will be after releasing the mouse) and this rectangle has height according to defaultEventMinutes, so in my case, when I am above the 7:20, it will show me th elight blue rectangle from 7:20 to 7:40, but when my event has duration 40 minutes, after release the mouse button, it will be added to calendar from 7:20 to 8:00. So I ask if it is possible to set defaultEventMinutes or the style that shows me that blue rectangle when mouse button is not released and the event is dragging through the calendar at a runtime ?
Oct 9, 2013
ah i see. i have to think about this a little more to come up with a more elegant solution api-wise
Summary:
Dyamic defaultEventMinutes
(was: Full calendar - defaultEventMinutes)
Status: Discussing Labels: Type-Feature
Oct 9, 2013
when improvements are made with issue 550 , this will probably go with it. It's be nice to associate real event data with the event being dragged. A `duration` property would be the best route
Oct 9, 2013
(No comment was entered for this change.)
Summary:
duration property for externally-dragged event
(was: Dyamic defaultEventMinutes)
Status: Accepted
Oct 9, 2013
Yeah it would be sooo good. Thank you very much.
May 28, 2014
Hi, was the Dyamic defaultEventMinutes released ? I cant find it in documentation
Jun 5, 2014
I believe this can be achieved with the following: version 2.x: http://arshaw.com/fullcalendar/docs/event_data/defaultAllDayEventDuration/ http://arshaw.com/fullcalendar/docs/event_data/defaultTimedEventDuration/ http://arshaw.com/fullcalendar/docs/event_data/forceEventDuration/ version 1.x: http://arshaw.com/fullcalendar/docs1/agenda/defaultEventMinutes/ ...but have not tested. On a separate note, here is a pull request with an implementation that lets you specify this via an html5 data- attribute on the element being dragged, via @iamWh1sp3r: https://github.com/arshaw/fullcalendar/pull/144
Jun 19, 2014
I implemented a way to do this locally.
Here's how I did it:
In "function Calendar" > "function option", I added the following
function option(name, value) {
if (value === undefined) {
return options[name];
}
if (name == 'height' || name == 'contentHeight' || name == 'aspectRatio') {
options[name] = value;
updateSize();
}
// BEGIN CHANGE
if (name == 'defaultTimedEventDuration') {
options[name] = value;
t.defaultTimedEventDuration = moment.duration(options.defaultTimedEventDuration);
}
// END CHANGE
}
This allows to set the 'defaultTimedEventDuration' property on the fly, which lets me set the duration of the block I'm dragging in when starting the drag.
Also, I added the following in sliceSegs:
function sliceSegs(events, rangeStart, rangeEnd) {
// normalize, because all dates will be compared w/o zones
rangeStart = rangeStart.clone().stripZone();
rangeEnd = rangeEnd.clone().stripZone();
var segs = [],
i, len=events.length, event,
eventStart, eventEnd,
segStart, segEnd,
isStart, isEnd;
for (i=0; i<len; i++) {
event = events[i];
// BEGIN CHANGE
trigger('updateDefaultTimedEventDuration', event, event);
// END CHANGE
// get dates, make copies, then strip zone to normalize
eventStart = event.start.clone().stripZone();
eventEnd = getEventEnd(event).stripZone();
if (eventEnd > rangeStart && eventStart < rangeEnd) {
if (eventStart < rangeStart) {
segStart = rangeStart.clone();
isStart = false;
}
else {
segStart = eventStart;
isStart = true;
}
if (eventEnd > rangeEnd) {
segEnd = rangeEnd.clone();
isEnd = false;
}
else {
segEnd = eventEnd;
isEnd = true;
}
segs.push({
event: event,
start: segStart,
end: segEnd,
isStart: isStart,
isEnd: isEnd
});
}
}
return segs.sort(compareSlotSegs);
}
Here, this was to allow for the defaultTimedEventDuration setting to stick for each event that is rendered if the view is reloaded. Here's a use case of this callback:
updateDefaultTimedEventDuration: function(event) {
if(event.hasEnd && event.hasEnd == 0) {
$("#calendar").fullCalendar("option", "defaultTimedEventDuration", '0' + event.time.length + ':00:00');
}
},
And here's my drag start event when dragging in external blocks:
start: function( event, ui ) {
$("#calendar").fullCalendar("option", "defaultTimedEventDuration", '0' + $(this).data('duration') + ':00:00');
},
Hopefully this can be implementation can be mirrored so I don't need to re-add this every time I update FC. I'm too lazy to fork and re-compile it using your build tools which are honestly way too complex and not worth the effort.
Sep 2, 2014
(No comment was entered for this change.)
Labels:
milestone-annotation
Oct 19, 2014
this has been implemented in thiagotalma's fork: https://github.com/arshaw/fullcalendar/pull/192 for the official release of this, i might make an alternate implementation that dovetails with my recent changes related to background-events/annotations. it is turning out to be a bit related.
Nov 14, 2014
this is officially implemented and released. possible through the 'duration' data property: http://fullcalendar.io/docs/dropping/droppable/ (see bottom of that article) or if you want to streamline the adding of the event too: http://fullcalendar.io/docs/dropping/eventReceive/
Status:
Released
|
|
| ► Sign in to add a comment |