(js) Create event by dragging in month's view
parent
90e79e7605
commit
3baef22df4
|
@ -82,7 +82,9 @@
|
||||||
<span class=""><var:string value="currentTableDay.dayOfMonth"/></span> <var:string value="dayHeaderMonth"/>
|
<span class=""><var:string value="currentTableDay.dayOfMonth"/></span> <var:string value="dayHeaderMonth"/>
|
||||||
</var:if>
|
</var:if>
|
||||||
</div>
|
</div>
|
||||||
<md-content sg-draggable-calendar-block="sg-draggable-calendar-block">
|
<md-content
|
||||||
|
sg-draggable-calendar-block="sg-draggable-calendar-block"
|
||||||
|
class="clickableDayCell">
|
||||||
<sg-calendar-month-day
|
<sg-calendar-month-day
|
||||||
sg-blocks="calendar.views[0].blocks"
|
sg-blocks="calendar.views[0].blocks"
|
||||||
sg-click="list.openEvent(event, component)"
|
sg-click="list.openEvent(event, component)"
|
||||||
|
|
|
@ -154,6 +154,8 @@
|
||||||
|
|
||||||
if (component.isNew) {
|
if (component.isNew) {
|
||||||
coordinates = pointerHandler.currentEventCoordinates;
|
coordinates = pointerHandler.currentEventCoordinates;
|
||||||
|
if (component.isAllDay)
|
||||||
|
coordinates.duration -= 96;
|
||||||
component.setDelta(coordinates.duration * 15);
|
component.setDelta(coordinates.duration * 15);
|
||||||
newComponent(null, component).finally(function() {
|
newComponent(null, component).finally(function() {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
},
|
},
|
||||||
template: [
|
template: [
|
||||||
'<sg-calendar-day-block',
|
'<sg-calendar-day-block',
|
||||||
|
' class="sg-draggable-calendar-block"',
|
||||||
' ng-repeat="block in blocks[day]"',
|
' ng-repeat="block in blocks[day]"',
|
||||||
' sg-block="block"',
|
' sg-block="block"',
|
||||||
' sg-click="clickBlock({event: clickEvent, component: clickComponent})"/>'
|
' sg-click="clickBlock({event: clickEvent, component: clickComponent})"/>'
|
||||||
|
|
|
@ -73,6 +73,8 @@
|
||||||
function onDragDetect(ev) {
|
function onDragDetect(ev) {
|
||||||
var block, dragMode, eventType, startDate, newData, newComponent, pointerHandler;
|
var block, dragMode, eventType, startDate, newData, newComponent, pointerHandler;
|
||||||
|
|
||||||
|
ev.stopPropagation();
|
||||||
|
|
||||||
dragMode = 'move-event';
|
dragMode = 'move-event';
|
||||||
|
|
||||||
if (scope.block && scope.block.component) {
|
if (scope.block && scope.block.component) {
|
||||||
|
@ -104,9 +106,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function dragStart(ev) {
|
function dragStart(ev) {
|
||||||
var block, dragMode, eventType, startDate, newData, newComponent, pointerHandler;
|
var block, dragMode, eventType, isHourCell, isMonthly, startDate, newData, newComponent, pointerHandler;
|
||||||
|
|
||||||
eventType = 'multiday';
|
isHourCell = element.hasClass('clickableHourCell');
|
||||||
|
isMonthly = (element[0].parentNode.tagName == 'SG-CALENDAR-MONTH-DAY') ||
|
||||||
|
element.hasClass('clickableDayCell');
|
||||||
|
|
||||||
if (scope.block && scope.block.component) {
|
if (scope.block && scope.block.component) {
|
||||||
// Move or resize existing component
|
// Move or resize existing component
|
||||||
|
@ -121,26 +125,30 @@
|
||||||
type: 'appointment',
|
type: 'appointment',
|
||||||
pid: 'personal', // TODO respect SOGoDefaultCalendar
|
pid: 'personal', // TODO respect SOGoDefaultCalendar
|
||||||
summary: l('New Event'),
|
summary: l('New Event'),
|
||||||
startDate: startDate
|
startDate: startDate,
|
||||||
|
isAllDay: isHourCell? 0 : 1
|
||||||
};
|
};
|
||||||
newComponent = new Component(newData);
|
newComponent = new Component(newData);
|
||||||
block = {
|
block = {
|
||||||
component: newComponent,
|
component: newComponent,
|
||||||
|
dayNumber: calendarDayCtrl.dayNumber,
|
||||||
length: 0
|
length: 0
|
||||||
};
|
};
|
||||||
block.component.blocks = [block];
|
block.component.blocks = [block];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine event type
|
||||||
|
eventType = 'multiday';
|
||||||
|
if (isMonthly)
|
||||||
|
eventType = 'monthly';
|
||||||
|
else if (block.component.c_isallday)
|
||||||
|
eventType = 'multiday-allday';
|
||||||
|
|
||||||
// Mark all blocks as being dragged
|
// Mark all blocks as being dragged
|
||||||
_.forEach(block.component.blocks, function(b) {
|
_.forEach(block.component.blocks, function(b) {
|
||||||
b.dragging = true;
|
b.dragging = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (element[0].parentNode.tagName === 'SG-CALENDAR-MONTH-DAY')
|
|
||||||
eventType = 'monthly';
|
|
||||||
else if (block.component.c_isallday)
|
|
||||||
eventType = 'multiday-allday';
|
|
||||||
|
|
||||||
// Update pointer handler
|
// Update pointer handler
|
||||||
pointerHandler = Component.$ghost.pointerHandler;
|
pointerHandler = Component.$ghost.pointerHandler;
|
||||||
pointerHandler.prepareWithEventType(eventType);
|
pointerHandler.prepareWithEventType(eventType);
|
||||||
|
@ -239,19 +247,18 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
initFromBlock: function(block) {
|
initFromBlock: function(block) {
|
||||||
if (this.eventType === 'monthly')
|
if (this.eventType === 'monthly') {
|
||||||
this.start = 0;
|
this.start = 0;
|
||||||
else
|
|
||||||
// Get the start (first quarter) from the event's first block
|
|
||||||
this.start = block.component.blocks[0].start;
|
|
||||||
|
|
||||||
// Compute overall length
|
|
||||||
if (this.eventType === 'monthly')
|
|
||||||
this.duration = block.component.blocks.length * 96;
|
this.duration = block.component.blocks.length * 96;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
|
// Get the start (first quarter) from the event's first block
|
||||||
|
// Compute overall length
|
||||||
|
this.start = block.component.blocks[0].start;
|
||||||
this.duration = _.sum(block.component.blocks, function(b) {
|
this.duration = _.sum(block.component.blocks, function(b) {
|
||||||
return b.length;
|
return b.length;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Get the dayNumber from the event's first block
|
// Get the dayNumber from the event's first block
|
||||||
this.dayNumber = block.component.blocks[0].dayNumber;
|
this.dayNumber = block.component.blocks[0].dayNumber;
|
||||||
|
|
|
@ -424,7 +424,7 @@ $block_radius: 3px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
.sg-event {
|
.sg-event {
|
||||||
position: static;
|
position: relative;
|
||||||
padding: 3px 1%;
|
padding: 3px 1%;
|
||||||
margin: $block_margin;
|
margin: $block_margin;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
Loading…
Reference in New Issue