diff --git a/api/js/etemplate/Et2Tree/Et2Tree.ts b/api/js/etemplate/Et2Tree/Et2Tree.ts
index 29b8d977f5..237e00b558 100644
--- a/api/js/etemplate/Et2Tree/Et2Tree.ts
+++ b/api/js/etemplate/Et2Tree/Et2Tree.ts
@@ -33,7 +33,7 @@ export type TreeItemData = SelectOption & {
tooltip: String,
userdata: any[]
//here we can store the number of unread messages, if there are any
- badge?: String;
+ badge?: string;
}
/**
@@ -111,11 +111,26 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
this.selectedNodes = [];
}
+ private _initCurrent()
+ {
+ this._currentSlTreeItem = this.selected;
+ this._currentOption = this._currentSlTreeItem?this.getNode(this._currentSlTreeItem?.id):null
+ }
firstUpdated()
{
// This is somehow required to set the autoload URL properly?
// TODO: Make this not needed, either this.autoload_url should be properly set or go away in favour of using this.autoload
- this.createTree();
+ if (this.autoloading)
+ {
+ // @ts-ignore from static get properties
+ let url = this.autoloading;
+
+ if (url.charAt(0) != '/' && url.substr(0, 4) != 'http')
+ {
+ url = '/json.php?menuaction=' + url;
+ }
+ this.autoloading_url = url;
+ }
// Check if top level should be autoloaded
if(this.autoloading && !this._selectOptions?.length)
@@ -123,9 +138,11 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
this.handleLazyLoading({item: this._selectOptions}).then((results) =>
{
this._selectOptions = results?.item ?? [];
+ this._initCurrent()
this.requestUpdate("_selectOptions");
})
}
+ if (this._selectOptions?.length) this._initCurrent()
// Actions can't be initialized without being connected to InstanceManager
this._initActions();
@@ -697,7 +714,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement)
${selectOption.label ?? selectOption.text}
- ${selectOption.badge ?
+ ${(selectOption.badge) ?
html`
${selectOption.badge}
` : nothing}
diff --git a/mail/js/app.js b/mail/js/app.js
index 34104aaf2a..349dc1dddd 100755
--- a/mail/js/app.js
+++ b/mail/js/app.js
@@ -1949,10 +1949,11 @@ app.classes.mail = AppJS.extend(
// display folder-name bold for unseen mails
if(_status[folderId]["unseenCount"])
{
- ftree.set_badge(folderId,_status[folderId]["unseenCount"]);
ftree.setStyle(folderId, 'font-weight: bold !important');
+ }else {
+ ftree.setStyle(folderId, 'font-weight: normal');
}
-
+ ftree.set_badge(folderId,_status[folderId]["unseenCount"]);
//alert(i +'->'+_status[i]);
}
},
@@ -2169,16 +2170,15 @@ app.classes.mail = AppJS.extend(
mail_reduceCounterWithoutServerRoundtrip: function()
{
var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
- var _foldernode = ftree.getSelectedNode();
- var counter = _foldernode.text.match(this._unseen_regexp);
+ var _foldernode = ftree.getSelectedItem();
+ var counter = _foldernode.badge;
var icounter = 0;
- if ( counter ) icounter = parseInt(counter[0].replace(' (','').replace(')',''));
+ if (counter) icounter = parseInt(counter);
if (icounter>0)
{
- var newcounter = icounter-1;
- if (newcounter > 0) _foldernode.text = _foldernode.text.replace(' (' + String(icounter) + ')', ' (' + String(newcounter) + ')');
- if (newcounter == 0) _foldernode.text = _foldernode.text.replace(' (' + String(icounter) + ')', '');
- ftree.setLabel(_foldernode.id, _foldernode.text);
+ let newcounter = icounter - 1;
+ if (newcounter === 0) newcounter = null;
+ ftree.set_badge(_foldernode.id, newcounter)
}
},