mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 07:09:20 +01:00
Fixed bugs with Drag&Drop and IE, improved speed of grid view component by adding an timestamp to the data cells and only updating them if the timestamp has changed
This commit is contained in:
parent
6fb34fa100
commit
01a50945f5
@ -83,6 +83,11 @@ function egwDragActionImplementation()
|
||||
|
||||
if (node)
|
||||
{
|
||||
// Prevent selection
|
||||
node.onselectstart = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
$(node).draggable(
|
||||
{
|
||||
"distance": 20,
|
||||
@ -101,8 +106,18 @@ function egwDragActionImplementation()
|
||||
$(node).data("ddTypes", ai.ddTypes);
|
||||
$(node).data("selected", ai.selected);
|
||||
|
||||
if (ai.helper)
|
||||
{
|
||||
// Append the helper object to the body element - this
|
||||
// fixes a bug in IE: If the element isn't inserted into
|
||||
// the DOM-tree jquery appends it to the parent node.
|
||||
// In case this is a table it doesn't work correctly
|
||||
$("body").append(ai.helper);
|
||||
return ai.helper;
|
||||
}
|
||||
|
||||
// Return an empty div if the helper dom node is not set
|
||||
return ai.helper ? ai.helper: $(document.createElement("div"));
|
||||
return $(document.createElement("div"));
|
||||
},
|
||||
"start": function(e) {
|
||||
return ai.helper != null;
|
||||
@ -110,7 +125,8 @@ function egwDragActionImplementation()
|
||||
// Solves problem with scroll position changing in the grid
|
||||
// component
|
||||
"refreshPositions": true,
|
||||
"scroll": false
|
||||
"scroll": false,
|
||||
"containment": "document"
|
||||
}
|
||||
);
|
||||
|
||||
@ -326,8 +342,10 @@ function egwDropActionImplementation()
|
||||
// set of properties.
|
||||
var popup = getPopupImplementation();
|
||||
var pos = popup._getPageXY(event);
|
||||
window.setTimeout(function() {
|
||||
popup.doExecuteImplementation(pos, selected, links,
|
||||
_context);
|
||||
}, 0); // Timeout is needed to have it working in IE
|
||||
}
|
||||
|
||||
_aoi.triggerEvent(EGW_AI_DRAG_OUT);
|
||||
|
@ -248,9 +248,9 @@ function egwPopupActionImplementation()
|
||||
|
||||
// Append the groups to the groups2 array
|
||||
var groups2 = [];
|
||||
for (k in groups)
|
||||
for (var i = 0; i < groups.length; i++)
|
||||
{
|
||||
groups2.push(groups[k].links);
|
||||
groups2.push(groups[i].links);
|
||||
}
|
||||
|
||||
_parentGroup.groups = groups2;
|
||||
|
@ -68,10 +68,13 @@ function egwGridDataElement(_id, _parent, _columns, _readQueue, _objectManager)
|
||||
this.updatedGrid = null;
|
||||
this.actionLinkGroups = {};
|
||||
this.group = false;
|
||||
this.capColTime = 0;
|
||||
|
||||
this.gridViewObj = null;
|
||||
}
|
||||
|
||||
var EGW_GRID_DATA_UPDATE_TIME = 0;
|
||||
|
||||
egwGridDataElement.prototype.free = function()
|
||||
{
|
||||
//TODO
|
||||
@ -79,17 +82,29 @@ egwGridDataElement.prototype.free = function()
|
||||
|
||||
egwGridDataElement.prototype.set_caption = function(_value)
|
||||
{
|
||||
if (_value != this.caption)
|
||||
{
|
||||
this.capColTime = EGW_GRID_DATA_UPDATE_TIME;
|
||||
this.caption = _value;
|
||||
}
|
||||
}
|
||||
|
||||
egwGridDataElement.prototype.set_iconUrl = function(_value)
|
||||
{
|
||||
if (_value != this.iconUrl)
|
||||
{
|
||||
this.capColTime = EGW_GRID_DATA_UPDATE_TIME;
|
||||
this.iconUrl = _value;
|
||||
}
|
||||
}
|
||||
|
||||
egwGridDataElement.prototype.set_iconSize = function(_value)
|
||||
{
|
||||
if (_value != this.iconSize)
|
||||
{
|
||||
this.capColTime = EGW_GRID_DATA_UPDATE_TIME;
|
||||
this.iconSize = _value;
|
||||
}
|
||||
}
|
||||
|
||||
egwGridDataElement.prototype.set_opened = function(_value)
|
||||
@ -99,7 +114,14 @@ egwGridDataElement.prototype.set_opened = function(_value)
|
||||
|
||||
egwGridDataElement.prototype.set_canHaveChildren = function(_value)
|
||||
{
|
||||
this.canHaveChildren = _value && (this.children.length == 0);
|
||||
// Calculate the canHaveChildren value which would really be set
|
||||
var rv = _value && (this.children.length == 0);
|
||||
|
||||
if (rv != this.canHaveChildren)
|
||||
{
|
||||
this.canHaveChildren = _value;
|
||||
this.capColTime = EGW_GRID_DATA_UPDATE_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
egwGridDataElement.prototype.set_group = function(_value)
|
||||
@ -150,10 +172,27 @@ egwGridDataElement.prototype.set_data = function(_value)
|
||||
data = val;
|
||||
}
|
||||
|
||||
// Set the data column timestamp - this is used inside the grid_view
|
||||
// row unit in order to only update data which has really changed
|
||||
var ts = 0;
|
||||
var newData = true;
|
||||
|
||||
if (typeof this.data[col_id] != "undefined" && this.data[col_id].data == data)
|
||||
{
|
||||
ts = this.data[col_id].ts;
|
||||
newData = false;
|
||||
}
|
||||
|
||||
if (newData)
|
||||
{
|
||||
ts = EGW_GRID_DATA_UPDATE_TIME;
|
||||
}
|
||||
|
||||
this.data[col_id] = {
|
||||
"data": data,
|
||||
"sortData": sortData,
|
||||
"queued": false
|
||||
"queued": false,
|
||||
"time": ts
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -191,6 +230,9 @@ egwGridDataElement.prototype.set_data = function(_value)
|
||||
*/
|
||||
egwGridDataElement.prototype.loadData = function(_data, _doCallUpdate)
|
||||
{
|
||||
// Store the current timestamp
|
||||
EGW_GRID_DATA_UPDATE_TIME = (new Date).getTime();
|
||||
|
||||
if (typeof _doCallUpdate == "undefined")
|
||||
{
|
||||
_doCallUpdate = false;
|
||||
@ -287,6 +329,7 @@ egwGridDataElement.prototype.clearData = function()
|
||||
this.caption = false;
|
||||
this.iconUrl = false;
|
||||
this.iconSize = false;
|
||||
this.capColTime = 0;
|
||||
|
||||
this.callGridViewObjectUpdate();
|
||||
}
|
||||
@ -426,7 +469,8 @@ egwGridDataElement.prototype.hasColumn = function(_columnId, _returnData)
|
||||
{
|
||||
res = {
|
||||
"caption": this.caption,
|
||||
"iconUrl": this.iconUrl
|
||||
"iconUrl": this.iconUrl,
|
||||
"time": this.capColTime
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -448,7 +492,7 @@ egwGridDataElement.prototype.hasColumn = function(_columnId, _returnData)
|
||||
{
|
||||
if (_returnData && typeof this.data[_columnId].data != "undefined")
|
||||
{
|
||||
res = this.data[_columnId].data;
|
||||
res = this.data[_columnId];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1396,9 +1396,9 @@ function egwGridViewRow_doInsertIntoDOM()
|
||||
this.parentNode.append(td);
|
||||
|
||||
// Assign the click event to the column
|
||||
td.mousedown(egwPreventSelect);
|
||||
// td.mousedown(egwPreventSelect);
|
||||
td.click({"item": this, "col": col.id}, function(e) {
|
||||
this.onselectstart = null;
|
||||
// this.onselectstart = null;
|
||||
e.data.item._columnClick(egwGetShiftState(e), e.data.col);
|
||||
});
|
||||
|
||||
@ -1407,7 +1407,8 @@ function egwGridViewRow_doInsertIntoDOM()
|
||||
// Store the column in the td object array
|
||||
this.tdObjects.push({
|
||||
"td": td,
|
||||
"cont": cont
|
||||
"cont": cont,
|
||||
"ts": 0
|
||||
});
|
||||
}
|
||||
|
||||
@ -1443,6 +1444,16 @@ function egwGridViewRow_doUpdateData(_immediate)
|
||||
var cont = this.tdObjects[i].cont;
|
||||
if (typeof data[col.id] != "undefined")
|
||||
{
|
||||
// If the timestamp of the tdObject and the data is still the
|
||||
// same we don't have to update
|
||||
if (this.tdObjects[i].ts == data[col.id].time)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Update the timestamp
|
||||
this.tdObjects[i].ts = data[col.id].time;
|
||||
|
||||
cont.empty();
|
||||
|
||||
if (col.type == EGW_COL_TYPE_NAME_ICON_FIXED)
|
||||
@ -1531,7 +1542,7 @@ function egwGridViewRow_doUpdateData(_immediate)
|
||||
}
|
||||
else
|
||||
{
|
||||
cont.html(data[col.id]);
|
||||
cont.html(data[col.id].data);
|
||||
}
|
||||
cont.toggleClass("queued", false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user