getNode and getDomNode refactoring for compatibility

This commit is contained in:
Milan 2024-02-08 22:20:11 +01:00
parent 65eb7e3404
commit 206fb0dd4b
4 changed files with 27 additions and 26 deletions

View File

@ -16,7 +16,7 @@ import {egwBitIsSet} from "./egw_action_common";
function dhtmlxTree_getNode(_tree: Et2Tree, _itemId: string)
{
const node = _tree.getNode(_itemId);
const node = _tree.getDomNode(_itemId);
if (node != null)
{
return node
@ -26,7 +26,7 @@ export class EgwDragDropShoelaceTree {
constructor(_tree:Et2Tree, _itemId) {
const aoi = new egwActionObjectInterface();
aoi.node = _tree.getNode(_itemId);
aoi.node = _tree.getDomNode(_itemId);
aoi.id = _itemId
aoi.doGetDOMNode = function () {
return aoi.node;

View File

@ -84,7 +84,7 @@ export class Et2MultiselectTree extends Et2Tree {
@sl-lazy-load=${(event) => {
this.handleLazyLoading(selectOption).then((result) => {
this.getItem(selectOption.id).item = [...result.item]
this.getNode(selectOption.id).item = [...result.item]
this.requestUpdate("_selectOptions")
})
@ -106,7 +106,7 @@ export class Et2MultiselectTree extends Et2Tree {
//TODO inefficient
this.selectedItems = []
for (const slTreeItem of <SlTreeItem[]>event.detail.selection) {
this.selectedItems.push(this.getItem(slTreeItem.id));
this.selectedItems.push(this.getNode(slTreeItem.id));
}
this.selectedNodes = event.detail.selection;
//TODO look at what signature is expected here

View File

@ -362,17 +362,17 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
return this._currentSlTreeItem
}
getNode(_id): SlTreeItem
getDomNode(_id): SlTreeItem
{
return this.shadowRoot.querySelector("sl-tree-item[id='" + _id + "'");
}
/**
* return the Item with given _id, was called getNode(_id) in dhtmlxTree
* return the Item with given _id, was called getDomNode(_id) in dhtmlxTree
* @param _id
*/
public getItem(_id: string): TreeItemData
public getNode(_id: string): TreeItemData
{
return this._search(_id, this._selectOptions)
@ -386,8 +386,8 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
*/
setLabel(_id, _label, _tooltip?)
{
let tooltip = _tooltip || (this.getItem(_id) && this.getItem(_id).tooltip ? this.getItem(_id).tooltip : "");
let i = this.getItem(_id)
let tooltip = _tooltip || (this.getNode(_id) && this.getNode(_id).tooltip ? this.getNode(_id).tooltip : "");
let i = this.getNode(_id)
i.tooltip = tooltip
i.text = _label
}
@ -399,7 +399,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
*/
getLabel(_id)
{
return this.getItem(_id)?.text;
return this.getNode(_id)?.text;
}
/**
@ -451,7 +451,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
this.refreshItem(_id, null)
} else
{
let item = this.getItem(_id)
let item = this.getNode(_id)
this.handleLazyLoading(item).then((result) => {
item.item = [...result.item]
this.requestUpdate("_selectOptions")
@ -489,7 +489,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
*/
public renameItem(_id, _newItemId, _label)
{
this.getItem(_id).id = _newItemId
this.getNode(_id).id = _newItemId
// Update action
// since the action ID has to = this.id, getObjectById() won't work
@ -509,7 +509,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
public focusItem(_id)
{
let item = this.getItem(_id)
let item = this.getNode(_id)
item.focused = true
}
@ -521,7 +521,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
*/
hasChildren(_id)
{
return this.getItem(_id).item?.length;
return this.getNode(_id).item?.length;
}
/**
@ -531,8 +531,8 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
reSelectItem(_id)
{
this._previousOption = this._currentOption
this._currentOption = this.getItem(_id);
const node: SlTreeItem = this.getNode(_id)
this._currentOption = this.getNode(_id);
const node: SlTreeItem = this.getDomNode(_id)
if (node)
{
this._currentSlTreeItem = node;
@ -542,7 +542,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
getUserData(_nodeId, _name)
{
return this.getItem(_nodeId)?.userdata?.find(elem => {
return this.getNode(_nodeId)?.userdata?.find(elem => {
elem.name === _name
})?.content
}
@ -573,7 +573,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
?focused=${selectOption.focused || nothing}
@sl-lazy-load=${(event) => {
this.handleLazyLoading(selectOption).then((result) => {
this.getItem(selectOption.id).item = [...result.item]
this.getNode(selectOption.id).item = [...result.item]
this.requestUpdate("_selectOptions")
})
@ -594,7 +594,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
@sl-selection-change=${
(event: any) => {
this._previousOption = this._currentOption
this._currentOption = this.getItem(event.detail.selection[0].id);
this._currentOption = this.getNode(event.detail.selection[0].id);
event.detail.previous = this._previousOption.id;
this._currentSlTreeItem = event.detail.selection[0];

View File

@ -694,7 +694,8 @@ app.classes.mail = AppJS.extend(
// ToDo: tree.refreshItem() and openItem() should return a promise
// need to wait tree is refreshed: current and new id are there AND current folder is selected again
const interval = window.setInterval(() => {
if (tree.getItem(_id) && tree.getItem(current_id)) {
if (tree.getNode(_id) && tree.getNode(current_id))
{
if (!tree.getSelectedNode())
{
tree.reSelectItem(current_id);
@ -706,7 +707,7 @@ app.classes.mail = AppJS.extend(
tree.openItem(_id, true);
// need to wait new folders are loaded AND current folder is selected again
const open_interval = window.setInterval(() => {
if (tree.getItem(_id + '::INBOX')) {
if (tree.getNode(_id + '::INBOX')) {
if (!tree.getSelectedNode()) {
tree.reSelectItem(current_id);
} else {
@ -1844,7 +1845,7 @@ app.classes.mail = AppJS.extend(
ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
if (ftree)
{
node = ftree.getItem(_senders[0].id);
node = ftree.getNode(_senders[0].id);
}
if (node && node.im0.indexOf('NoSelect') !== -1)
@ -1869,7 +1870,7 @@ app.classes.mail = AppJS.extend(
{
var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
var acc_id = _senders[0].id.split('::')[0];
var node = ftree ? ftree.getItem(acc_id) : null;
var node = ftree ? ftree.getNode(acc_id) : null;
return node && node.data && node.data.spamfolder;
},
@ -1888,7 +1889,7 @@ app.classes.mail = AppJS.extend(
{
var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
var acc_id = _senders[0].id.split('::')[2]; // this is operating on mails
var node = ftree ? ftree.getItem(acc_id) : null;
var node = ftree ? ftree.getNode(acc_id) : null;
return node && node.data && node.data.archivefolder;
},
@ -1906,7 +1907,7 @@ app.classes.mail = AppJS.extend(
{
var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
var acc_id = _senders[0].id.split('::')[0];
var node = ftree ? ftree.getItem(acc_id) : null;
var node = ftree ? ftree.getNode(acc_id) : null;
return node && node.data && node.data.sieve;
},
@ -1925,7 +1926,7 @@ app.classes.mail = AppJS.extend(
{
var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
var inbox = _senders[0].id.split('::')[0]+'::INBOX';
var node = ftree ? ftree.getItem(inbox) : null;
var node = ftree ? ftree.getNode(inbox) : null;
return node && node.data && node.data.acl && this.mail_CheckFolderNoSelect(_action,_senders,_currentNode);
},