mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 07:09:20 +01:00
Get Calendar d-n-d working again
This commit is contained in:
parent
374312be3c
commit
f1da90887a
@ -102,12 +102,6 @@ class calendar_uiviews extends calendar_ui
|
||||
*/
|
||||
var $use_time_grid=true;
|
||||
|
||||
/**
|
||||
* Dragdrop Object
|
||||
*
|
||||
* @var dragdrop;
|
||||
*/
|
||||
var $dragdrop;
|
||||
|
||||
/**
|
||||
* Can we display the whole day in a timeGrid of the size of the workday and just scroll to workday start
|
||||
@ -179,13 +173,7 @@ class calendar_uiviews extends calendar_ui
|
||||
|
||||
$this->check_owners_access();
|
||||
|
||||
if($GLOBALS['egw_info']['user']['preferences']['common']['enable_dragdrop'])
|
||||
{
|
||||
$this->dragdrop = new dragdrop();
|
||||
// if the object would auto-disable itself unset object
|
||||
// to avoid unneccesary dragdrop calls later
|
||||
if(!$this->dragdrop->validateBrowser()) $this->dragdrop = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -701,8 +689,6 @@ class calendar_uiviews extends calendar_ui
|
||||
echo $content;
|
||||
}
|
||||
|
||||
// make wz_dragdrop elements work
|
||||
if(is_object($this->dragdrop)) { $this->dragdrop->setJSCode(); }
|
||||
|
||||
return $content;
|
||||
}
|
||||
@ -890,8 +876,6 @@ class calendar_uiviews extends calendar_ui
|
||||
echo $content;
|
||||
}
|
||||
|
||||
// make wz_dragdrop elements work
|
||||
if(is_object($this->dragdrop)) { $this->dragdrop->setJSCode(); }
|
||||
|
||||
return $content;
|
||||
}
|
||||
@ -993,15 +977,12 @@ class calendar_uiviews extends calendar_ui
|
||||
{
|
||||
echo $cols[0];
|
||||
}
|
||||
// make wz_dragdrop elements work
|
||||
if(is_object($this->dragdrop)) { $this->dragdrop->setJSCode(); }
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$content = $this->timeGridWidget($this->bo->search($this->search_params),$this->cal_prefs['interval'],300);
|
||||
|
||||
// make wz_dragdrop elements work
|
||||
if(is_object($this->dragdrop)) { $this->dragdrop->setJSCode(); }
|
||||
|
||||
return $content;
|
||||
}
|
||||
@ -1412,7 +1393,7 @@ class calendar_uiviews extends calendar_ui
|
||||
if ($this->use_time_grid)
|
||||
{
|
||||
// drag and drop: check if the current user has EDIT permissions on the grid
|
||||
if(is_object($this->dragdrop))
|
||||
if($GLOBALS['egw_info']['user']['preferences']['common']['enable_dragdrop'])
|
||||
{
|
||||
if($owner)
|
||||
{
|
||||
@ -1443,19 +1424,15 @@ class calendar_uiviews extends calendar_ui
|
||||
'%;" class="calendar_calAddEvent"';
|
||||
if ($this->allowEdit)
|
||||
{
|
||||
$html .= ' onclick="'.$this->popup($GLOBALS['egw']->link('/index.php',$linkData)).';return false;"';
|
||||
$html .= ' data-date=' .$linkData['date'].'|'.$linkData['hour'].'|'.$linkData['minute'];
|
||||
}
|
||||
if($dropPermission && $owner)
|
||||
{
|
||||
$html .= ' data-owner ='.$owner;
|
||||
|
||||
}
|
||||
$html .= '></div>'."\n";
|
||||
if(is_object($this->dragdrop) && $dropPermission)
|
||||
{
|
||||
$this->dragdrop->addDroppable(
|
||||
$droppableID,
|
||||
array(
|
||||
'datetime'=>$droppableDateTime,
|
||||
'owner'=>$owner ? $owner : $this->user,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1822,7 +1799,7 @@ class calendar_uiviews extends calendar_ui
|
||||
);
|
||||
}
|
||||
|
||||
$draggableID = 'drag_'.$event['id'].'_O'.$event['owner'].'_C'.($owner<0?str_replace('-','group',$owner):$owner);
|
||||
$draggableID = $event['id'].'_O'.$event['owner'].'_C'.($owner<0?str_replace('-','group',$owner):$owner);
|
||||
|
||||
$ttip_options = array(
|
||||
'BorderWidth' => 0, // as we use our round borders
|
||||
@ -1866,7 +1843,7 @@ class calendar_uiviews extends calendar_ui
|
||||
|
||||
// ATM we do not support whole day events or recurring events for dragdrop
|
||||
$dd_emulation = "";
|
||||
if (is_object($this->dragdrop) &&
|
||||
if ($GLOBALS['egw_info']['user']['preferences']['common']['enable_dragdrop'] &&
|
||||
$this->use_time_grid &&
|
||||
(int)$event['id'] && $this->bo->check_perms(EGW_ACL_EDIT,$event))
|
||||
{
|
||||
@ -1874,23 +1851,12 @@ class calendar_uiviews extends calendar_ui
|
||||
!$event['whole_day'] &&
|
||||
!$event['recur_type'])
|
||||
{
|
||||
// register event as draggable
|
||||
$this->dragdrop->addDraggable(
|
||||
$draggableID,
|
||||
array(
|
||||
'eventId'=>$event['id'],
|
||||
'eventOwner'=>$event['owner'],
|
||||
'calendarOwner'=>$owner,
|
||||
'errorImage'=>addslashes(html::image('phpgwapi','dialog_error',false,'style="width: 16px;"')),
|
||||
'loaderImage'=>addslashes(html::image('phpgwapi','ajax-loader')),
|
||||
),
|
||||
'calendar.dragDropFunctions.dragEvent',
|
||||
'calendar.dragDropFunctions.dropEvent',
|
||||
'top center 2'
|
||||
);
|
||||
$draggableID = 'drag_'.$event['id'].'_O'.$event['owner'].'_C'.($owner<0?str_replace('-','group',$owner):$owner);
|
||||
}
|
||||
else
|
||||
{
|
||||
$draggableID = $event['id'].'_O'.$event['owner'].'_C'.($owner<0?str_replace('-','group',$owner):$owner);
|
||||
|
||||
// If a event isn't drag-dropable, the drag drop event handling has to be fully disabled
|
||||
// for that object. Clicking on it - however - should still bring it to the foreground.
|
||||
$dd_emulation = ' onmousedown="dd.z++; this.style.zIndex = dd.z; event.cancelBubble=true;"'
|
||||
|
@ -40,6 +40,8 @@ app.classes.calendar = AppJS.extend(
|
||||
{
|
||||
window.top.app.calendar = this;
|
||||
}
|
||||
//Drag_n_Drop
|
||||
this.drag_n_drop();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -101,7 +103,141 @@ app.classes.calendar = AppJS.extend(
|
||||
this.set_enddate_visibility();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Drag and Drop
|
||||
*
|
||||
*
|
||||
*/
|
||||
drag_n_drop: function()
|
||||
{
|
||||
var that = this;
|
||||
|
||||
//Draggable
|
||||
jQuery("div[id^='drag_']").draggable(
|
||||
{
|
||||
stack: jQuery("div[id^='drag_']"),
|
||||
revert: "invalid",
|
||||
delay: 50,
|
||||
|
||||
cursorAt:{top:0,left:0},
|
||||
containment: ".egw_fw_content_browser_iframe",
|
||||
scroll: true,
|
||||
opacity: .6,
|
||||
|
||||
stop: function(ui,event){
|
||||
event.helper.width(oldWidth);
|
||||
event.helper[0].innerHTML = oldInnerHTML;
|
||||
},
|
||||
drag:function(ui, event){
|
||||
//that.dragEvent();
|
||||
},
|
||||
start: function(ui, event){
|
||||
oldInnerHTML = event.helper[0].innerHTML;
|
||||
oldWidth = event.helper.width();
|
||||
event.helper.width(jQuery("#calColumn").width());
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
//Droppable
|
||||
jQuery("div[id^='drop_']").droppable(
|
||||
{
|
||||
accept:function(dg){
|
||||
|
||||
var id = dg[0].getAttribute('id');
|
||||
var calOwner = id.substring(id.lastIndexOf("_O")+2,id.lastIndexOf("_C"));
|
||||
var dpOwner = this.getAttribute('data-owner');
|
||||
if (dpOwner == null) dpOwner = calOwner;
|
||||
if (dg[0].getAttribute('id').match(/drag/g) && calOwner == dpOwner)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false
|
||||
}
|
||||
|
||||
},
|
||||
tolerance:'pointer',
|
||||
|
||||
drop:function(id, event){
|
||||
var dgId = event.draggable[0].getAttribute('id');
|
||||
var dgOwner = dgId.substring(dgId.lastIndexOf("_C")+2,dgId.lastIndexOf(""));
|
||||
var dpOwner = id.target.getAttribute('data-owner');
|
||||
if (dpOwner == null) dpOwner = dgOwner;
|
||||
if (dpOwner == dgOwner )
|
||||
{
|
||||
that.dropEvent(event.draggable[0].id, id.target.getAttribute('id').substring(id.target.getAttribute('id').lastIndexOf("drop_")+5, id.target.getAttribute('id').lastIndexOf("_O")));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
over:function(ui, event){
|
||||
var timeDemo = ui.target.id.substring(ui.target.id.lastIndexOf("T")+1,ui.target.id.lastIndexOf("_O"));
|
||||
var dgId = event.draggable[0].getAttribute('id');
|
||||
var dgOwner = dgId.substring(dgId.lastIndexOf("_C")+2,dgId.lastIndexOf(""));
|
||||
var dpOwner = ui.target.getAttribute('data-owner');
|
||||
if (dpOwner == null) dpOwner = dgOwner;
|
||||
if (dpOwner == dgOwner )
|
||||
{
|
||||
event.helper[0].innerHTML = '<div style="font-size: 1.1em; font-weight: bold; text-align: center;">'+timeDemo+'</div>'
|
||||
}
|
||||
else
|
||||
{
|
||||
event.helper[0].innerHTML = '<div style="background-color: red; height: 100%; width: 100%; text-align: center;">' + 'Forbidden' + '</div>';
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
//onClick Handler for calendar cells
|
||||
jQuery("div.calendar_calAddEvent").click(function(ev)
|
||||
{
|
||||
var timestamp = ev.target.getAttribute('data-date').split("|");
|
||||
var owner = ev.target.getAttribute('id').split("_");
|
||||
|
||||
var ownerNum = owner[2].match( /Ogroup/g)?owner[2].replace( /Ogroup/g, '-'):owner[2].replace( /^\D+/g, '');
|
||||
var date = timestamp[0];
|
||||
var hour = timestamp[1];
|
||||
var minute = timestamp[2];
|
||||
if (ownerNum == 0)
|
||||
{
|
||||
egw.open_link('calendar.calendar_uiforms.edit&date='+date+'&hour='+hour+'&minute='+minute,'_blank','700x700');
|
||||
}
|
||||
else
|
||||
{
|
||||
egw.open_link('calendar.calendar_uiforms.edit&date='+date+'&hour='+hour+'&minute='+minute+'&owner='+ownerNum,'_blank','700x700');
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* DropEvent
|
||||
*
|
||||
* @param {string} _id dragged event id
|
||||
* @param {array} _date array of date,hour, and minute of dropped cell
|
||||
*
|
||||
*/
|
||||
dropEvent : function(_id, _date)
|
||||
{
|
||||
var eventId = _id.substring(_id.lastIndexOf("drag_")+5,_id.lastIndexOf("_O"));
|
||||
var calOwner = _id.substring(_id.lastIndexOf("_O")+2,_id.lastIndexOf("_C"));
|
||||
var eventOwner = _id.substring(_id.lastIndexOf("_C")+2,_id.lastIndexOf(""));
|
||||
var date = _date;
|
||||
xajax_doXMLHTTP(
|
||||
'calendar.calendar_ajax.moveEvent',
|
||||
eventId,
|
||||
calOwner,
|
||||
date,
|
||||
eventOwner
|
||||
);
|
||||
},
|
||||
/**
|
||||
* open the freetime search popup
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user