mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
reduceCounter fix for badges in Mail tree
This commit is contained in:
parent
556757ae5d
commit
9b5412a494
@ -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)
|
||||
<span class="tree-item__label">
|
||||
${selectOption.label ?? selectOption.text}
|
||||
</span>
|
||||
${selectOption.badge ?
|
||||
${(selectOption.badge) ?
|
||||
html`
|
||||
<sl-badge pill variant="danger">${selectOption.badge}</sl-badge>
|
||||
` : nothing}
|
||||
|
@ -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)
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user