mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-29 10:09:10 +01:00
Tree / Action changes
- Remove dragover action handling, it takes too much time and we do nothing with it (use dragenter) - Fix unregistering actions did not remove eventListeners - Fix multiple binding of actions in Et2Tree
This commit is contained in:
parent
29c0129731
commit
96877abde6
@ -23,6 +23,7 @@ export interface EgwActionObjectInterface {
|
|||||||
//properties
|
//properties
|
||||||
id?:string
|
id?:string
|
||||||
_state: number;
|
_state: number;
|
||||||
|
handlers : { [type : string]? : [{ type : string, listener : Function }] };
|
||||||
stateChangeCallback: Function;
|
stateChangeCallback: Function;
|
||||||
stateChangeContext: any;
|
stateChangeContext: any;
|
||||||
reconnectActionsCallback: Function;
|
reconnectActionsCallback: Function;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {EgwActionImplementation} from "./EgwActionImplementation";
|
import {EgwActionImplementation} from "./EgwActionImplementation";
|
||||||
import {EGW_AI_DRAG_ENTER, EGW_AI_DRAG_OUT, EGW_AI_DRAG_OVER, EGW_AO_EXEC_THIS} from "./egw_action_constants";
|
import {EGW_AI_DRAG_ENTER, EGW_AI_DRAG_OUT, EGW_AO_EXEC_THIS} from "./egw_action_constants";
|
||||||
import {egw_getObjectManager} from "./egw_action";
|
import {egw_getObjectManager} from "./egw_action";
|
||||||
import {getPopupImplementation} from "./EgwPopupActionImplementation";
|
import {getPopupImplementation} from "./EgwPopupActionImplementation";
|
||||||
|
|
||||||
@ -24,21 +24,17 @@ export class EgwDropActionImplementation implements EgwActionImplementation {
|
|||||||
const node = _aoi.getDOMNode() && _aoi.getDOMNode()[0] ? _aoi.getDOMNode()[0] : _aoi.getDOMNode();
|
const node = _aoi.getDOMNode() && _aoi.getDOMNode()[0] ? _aoi.getDOMNode()[0] : _aoi.getDOMNode();
|
||||||
const self:EgwDropActionImplementation = this;
|
const self:EgwDropActionImplementation = this;
|
||||||
if (node) {
|
if (node) {
|
||||||
node.classList.add('et2dropzone');
|
if(typeof _aoi.handlers == "undefined")
|
||||||
|
{
|
||||||
|
_aoi.handlers = {};
|
||||||
|
}
|
||||||
|
_aoi.handlers[this.type] = [];
|
||||||
|
node.classList.add('et2dropzone');
|
||||||
const dragover = (event)=> {
|
const dragover = (event)=> {
|
||||||
if (event.preventDefault) {
|
if (event.preventDefault) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
if (!this.getTheDraggedDOM()) return;
|
|
||||||
|
|
||||||
const data = {
|
|
||||||
event: event,
|
|
||||||
ui: this.getTheDraggedData()
|
|
||||||
};
|
|
||||||
_aoi.triggerEvent(EGW_AI_DRAG_OVER, data);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const dragenter = function (event) {
|
const dragenter = function (event) {
|
||||||
@ -192,12 +188,16 @@ export class EgwDropActionImplementation implements EgwActionImplementation {
|
|||||||
|
|
||||||
// DND Event listeners
|
// DND Event listeners
|
||||||
node.addEventListener('dragover', dragover, false);
|
node.addEventListener('dragover', dragover, false);
|
||||||
|
_aoi.handlers[this.type].push({type: 'dragover', listener: dragover});
|
||||||
|
|
||||||
node.addEventListener('dragenter', dragenter, false);
|
node.addEventListener('dragenter', dragenter, false);
|
||||||
|
_aoi.handlers[this.type].push({type: 'dragenter', listener: dragenter});
|
||||||
|
|
||||||
node.addEventListener('drop', drop, false);
|
node.addEventListener('drop', drop, false);
|
||||||
|
_aoi.handlers[this.type].push({type: 'drop', listener: drop});
|
||||||
|
|
||||||
node.addEventListener('dragleave', dragleave, false);
|
node.addEventListener('dragleave', dragleave, false);
|
||||||
|
_aoi.handlers[this.type].push({type: 'dragleave', listener: dragleave});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -210,6 +210,9 @@ export class EgwDropActionImplementation implements EgwActionImplementation {
|
|||||||
if (node) {
|
if (node) {
|
||||||
node.classList.remove('et2dropzone');
|
node.classList.remove('et2dropzone');
|
||||||
}
|
}
|
||||||
|
// Unregister handlers
|
||||||
|
_aoi.handlers[this.type]?.forEach(h => node.removeEventListener(h.type, h.listener));
|
||||||
|
delete _aoi.handlers[this.type];
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -129,7 +129,12 @@ export class EgwDragActionImplementation implements EgwActionImplementation {
|
|||||||
const node = _aoi.getDOMNode() && _aoi.getDOMNode()[0] ? _aoi.getDOMNode()[0] : _aoi.getDOMNode();
|
const node = _aoi.getDOMNode() && _aoi.getDOMNode()[0] ? _aoi.getDOMNode()[0] : _aoi.getDOMNode();
|
||||||
|
|
||||||
if (node) {
|
if (node) {
|
||||||
// Prevent selection
|
if(typeof _aoi.handlers == "undefined")
|
||||||
|
{
|
||||||
|
_aoi.handlers = {};
|
||||||
|
}
|
||||||
|
_aoi.handlers[this.type] = [];
|
||||||
|
// Prevent selection
|
||||||
node.onselectstart = function () {
|
node.onselectstart = function () {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@ -150,19 +155,26 @@ export class EgwDragActionImplementation implements EgwActionImplementation {
|
|||||||
//jQuery(node).off("mousedown",egwPreventSelect)
|
//jQuery(node).off("mousedown",egwPreventSelect)
|
||||||
//et2_dataview_view_aoi binds mousedown event in et2_dataview_rowAOI to "egwPreventSelect" function from egw_action_common via addEventListener
|
//et2_dataview_view_aoi binds mousedown event in et2_dataview_rowAOI to "egwPreventSelect" function from egw_action_common via addEventListener
|
||||||
//node.removeEventListener("mousedown",egwPreventSelect)
|
//node.removeEventListener("mousedown",egwPreventSelect)
|
||||||
node.addEventListener("mousedown", (event) => {
|
const mousedown = (event) =>
|
||||||
|
{
|
||||||
if (_context.isSelection(event)) {
|
if (_context.isSelection(event)) {
|
||||||
node.setAttribute("draggable", false);
|
node.setAttribute("draggable", false);
|
||||||
} else if (event.which != 3) {
|
} else if (event.which != 3) {
|
||||||
document.getSelection().removeAllRanges();
|
document.getSelection().removeAllRanges();
|
||||||
}
|
}
|
||||||
})
|
};
|
||||||
node.addEventListener("mouseup", (event) => {
|
node.addEventListener("mousedown", mousedown)
|
||||||
|
_aoi.handlers[this.type].push({type: 'mousedown', listener: mousedown});
|
||||||
|
|
||||||
|
const mouseup = (event) =>
|
||||||
|
{
|
||||||
node.setAttribute("draggable", true);
|
node.setAttribute("draggable", true);
|
||||||
|
|
||||||
// Set cursor back to auto. Seems FF can't handle cursor reversion
|
// Set cursor back to auto. Seems FF can't handle cursor reversion
|
||||||
document.body.style.cursor = 'auto'
|
document.body.style.cursor = 'auto'
|
||||||
})
|
};
|
||||||
|
node.addEventListener("mouseup", mouseup)
|
||||||
|
_aoi.handlers[this.type].push({type: 'mousedown', listener: mousedown});
|
||||||
|
|
||||||
|
|
||||||
node.setAttribute('draggable', true);
|
node.setAttribute('draggable', true);
|
||||||
@ -280,7 +292,9 @@ export class EgwDragActionImplementation implements EgwActionImplementation {
|
|||||||
|
|
||||||
// Drag Event listeners
|
// Drag Event listeners
|
||||||
node.addEventListener('dragstart', dragstart, false);
|
node.addEventListener('dragstart', dragstart, false);
|
||||||
|
_aoi.handlers[this.type].push({type: 'dragstart', listener: dragstart});
|
||||||
node.addEventListener('dragend', dragend, false);
|
node.addEventListener('dragend', dragend, false);
|
||||||
|
_aoi.handlers[this.type].push({type: 'dragend', listener: dragend});
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -294,6 +308,9 @@ export class EgwDragActionImplementation implements EgwActionImplementation {
|
|||||||
if (node) {
|
if (node) {
|
||||||
node.setAttribute('draggable', "false");
|
node.setAttribute('draggable', "false");
|
||||||
}
|
}
|
||||||
|
// Unregister handlers
|
||||||
|
_aoi.handlers[this.type]?.forEach(h => node.removeEventListener(h.type, h.listener));
|
||||||
|
delete _aoi.handlers[this.type];
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -351,7 +351,6 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
|
|||||||
if(new_options?.length)
|
if(new_options?.length)
|
||||||
{
|
{
|
||||||
this._selectOptions = new_options;
|
this._selectOptions = new_options;
|
||||||
this.updateComplete.then(()=>this._link_actions(this.actions))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user