fix opened folders

fix for #91431
--2. one level too much is opened in mail, see screenshot
This commit is contained in:
Milan 2024-02-12 23:17:27 +01:00
parent 288c0c39e9
commit 2ddfb6a596

View File

@ -100,7 +100,8 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
} }
//Sl-Trees handle their own onClick events //Sl-Trees handle their own onClick events
_handleClick(_ev) { _handleClick(_ev)
{
} }
static get styles() static get styles()
@ -308,6 +309,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
this.onopenstart = _handler this.onopenstart = _handler
this.installHandler("onopenstart", _handler) this.installHandler("onopenstart", _handler)
} }
/** /**
* @deprecated assign to onopenend * @deprecated assign to onopenend
* @param _handler * @param _handler
@ -338,7 +340,6 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
} }
public getSelectedItem(): TreeItemData public getSelectedItem(): TreeItemData
{ {
return this._currentOption return this._currentOption
@ -461,13 +462,17 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
/** /**
* Does nothing * Does nothing
* @deprecated setting styles on individual items is no longer supported
* @param _id * @param _id
* @param _style * @param _style
*/ */
setStyle(_id, _style) setStyle(_id, _style)
{ {
//setting a style on an iduvidual item is not planned to be used with sl_tree var temp = this.getDomNode(_id);
if (!temp) return 0;
if (!temp.style.cssText)
temp.setAttribute("style", _style);
else
temp.style.cssText = temp.style.cssText + ";" + _style;
} }
/** /**
@ -494,10 +499,15 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
// Update action // Update action
// since the action ID has to = this.id, getObjectById() won't work // since the action ID has to = this.id, getObjectById() won't work
let treeObj: EgwActionObject = egw_getAppObjectManager(false).getObjectById(this.id); let treeObj: EgwActionObject = egw_getAppObjectManager(false).getObjectById(this.id);
for (const actionObject of treeObj.children) { for (const actionObject of treeObj.children)
if(actionObject.id == _id){ {
if (actionObject.id == _id)
{
actionObject.id = _newItemId; actionObject.id = _newItemId;
if (actionObject.iface){actionObject.iface.id = _newItemId} if (actionObject.iface)
{
actionObject.iface.id = _newItemId
}
break break
} }
@ -564,7 +574,6 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
} }
return html` return html`
<sl-tree-item <sl-tree-item
id=${selectOption.id} id=${selectOption.id}
@ -721,18 +730,23 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
return action_links; return action_links;
} }
protected updated(_changedProperties: PropertyValues) { protected updated(_changedProperties: PropertyValues)
{
this._link_actions(this.actions) this._link_actions(this.actions)
super.updated(_changedProperties); super.updated(_changedProperties);
} }
private _search(_id: string, data: TreeItemData[]): TreeItemData { private _search(_id: string, data: TreeItemData[]): TreeItemData
{
let res: TreeItemData = null let res: TreeItemData = null
for (const value of data) { for (const value of data)
if (value.id === _id) { {
if (value.id === _id)
{
res = value res = value
return res return res
} else if (_id.startsWith(value.id)) { } else if (_id.startsWith(value.id))
{
res = this._search(_id, value.item) res = this._search(_id, value.item)
} }
} }
@ -740,16 +754,23 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
} }
private calculateExpandState = (selectOption: TreeItemData) => { private calculateExpandState = (selectOption: TreeItemData) => {
if (selectOption.id.includes("INBOX") || selectOption.id == window.egw.preference("ActiveProfileID", "mail")) { if (selectOption.id.endsWith("INBOX") || selectOption.id == window.egw.preference("ActiveProfileID", "mail"))
{
return true return true
} }
if (selectOption.open) { if (selectOption.open)
{
return true return true
} }
if ((this._selectOptions.find((selectOption) => { if (
this._selectOptions[0] == selectOption &&
(this._selectOptions.find((selectOption) => {
return selectOption.open return selectOption.open
}) == undefined) && this._selectOptions[0] == selectOption) { }) == undefined
return true )
)
{
return true //open the first item, if no item is opened
} }
return false return false
@ -816,7 +837,8 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
} }
customElements.define("et2-tree", Et2Tree); customElements.define("et2-tree", Et2Tree);
customElements.define("et2-tree-cat", class extends Et2Tree { customElements.define("et2-tree-cat", class extends Et2Tree
{
}); });