diff --git a/api/js/etemplate/Et2Button/Et2ButtonTimestamper.ts b/api/js/etemplate/Et2Button/Et2ButtonTimestamper.ts index d07b2ecc7a..3aa642f868 100644 --- a/api/js/etemplate/Et2Button/Et2ButtonTimestamper.ts +++ b/api/js/etemplate/Et2Button/Et2ButtonTimestamper.ts @@ -81,79 +81,87 @@ export class Et2ButtonTimestamper extends Et2Button // Get properly formatted user name const user = parseInt(egw.user('account_id')); - const account = egw.accounts('accounts').filter(option => option.value == user)[0]; - text += account.label + ': '; - - const widget = this._get_input(this.target); - let input = widget.input ? widget.input : widget.getDOMNode(); - if(input.context) + egw.accounts('accounts', true).then((accounts) => { - input = input.get(0); - } + const account = accounts.filter(option => option.value == user)[0]; + text += account.label + ': '; - let scrollPos = input.scrollTop; - let browser = ((input.selectionStart || input.selectionStart == "0") ? - "standards" : (document["selection"] ? "ie" : false ) ); - - let pos = 0; - let tinymce = tinyMCE && tinyMCE.EditorManager.get(input.id) || false; - - // Find cursor or selection - if (browser == "ie") - { - input.focus(); - let range = document["selection"].createRange(); - range.moveStart ("character", -input.value.length); - pos = range.text.length; - } - else if (browser == "standards") - { - pos = input.selectionStart; - } - - // If on a tab, switch to that tab so user can see it - let tabbox = widget; - while(tabbox._parent && tabbox.nodeName !== 'ET2-TABBOX') - { - tabbox = tabbox._parent; - } - if (tabbox.nodeName === 'ET2-TABBOX') (tabbox).activateTab(widget); - - // If tinymce, update it - if(tinymce) - { - tinymce.insertContent(text); - } - else - { - // Insert the text - let front = (input.value).substring(0, pos); - let back = (input.value).substring(pos, input.value.length); - // for webComponent, we need to set the component value too, otherwise the change is lost! - if (typeof widget.tagName !== 'undefined') + const widget = this._get_input(this.target); + let input = widget.input ? widget.input : widget.getDOMNode(); + if(input.context) { - widget.value = front+text+back; + input = input.get(0); } - input.value = front+text+back; - // Clean up a little - pos = pos + text.length; - if (browser == "ie") { + let scrollPos = input.scrollTop; + let browser = ((input.selectionStart || input.selectionStart == "0") ? + "standards" : (document["selection"] ? "ie" : false)); + + let pos = 0; + let tinymce = tinyMCE && tinyMCE.EditorManager.get(input.id) || false; + + // Find cursor or selection + if(browser == "ie") + { input.focus(); let range = document["selection"].createRange(); - range.moveStart ("character", -input.value.length); - range.moveStart ("character", pos); - range.moveEnd ("character", 0); - range.select(); + range.moveStart("character", -input.value.length); + pos = range.text.length; } - else if (browser == "standards") { - input.selectionStart = pos; - input.selectionEnd = pos; + else if(browser == "standards") + { + pos = input.selectionStart; + } + + // If on a tab, switch to that tab so user can see it + let tabbox = widget; + while(tabbox._parent && tabbox.nodeName !== 'ET2-TABBOX') + { + tabbox = tabbox._parent; + } + if(tabbox.nodeName === 'ET2-TABBOX') + { + (tabbox).activateTab(widget); + } + + // If tinymce, update it + if(tinymce) + { + tinymce.insertContent(text); + } + else + { + // Insert the text + let front = (input.value).substring(0, pos); + let back = (input.value).substring(pos, input.value.length); + // for webComponent, we need to set the component value too, otherwise the change is lost! + if(typeof widget.tagName !== 'undefined') + { + widget.value = front + text + back; + } + input.value = front + text + back; + + // Clean up a little + pos = pos + text.length; + if(browser == "ie") + { + input.focus(); + let range = document["selection"].createRange(); + range.moveStart("character", -input.value.length); + range.moveStart("character", pos); + range.moveEnd("character", 0); + range.select(); + } + else if(browser == "standards") + { + input.selectionStart = pos; + input.selectionEnd = pos; + input.focus(); + } + input.scrollTop = scrollPos; input.focus(); } - input.scrollTop = scrollPos; - input.focus(); - } + }); } private _get_input(target) diff --git a/api/js/jsapi/egw_user.js b/api/js/jsapi/egw_user.js index bc95117dcc..685ca4bf55 100644 --- a/api/js/jsapi/egw_user.js +++ b/api/js/jsapi/egw_user.js @@ -122,11 +122,16 @@ egw.extend('user', egw.MODULE_GLOBAL, function() // Synchronous egw.json("EGroupware\\Api\\Framework::ajax_user_list",[], cache_it, this, false).sendRequest(false); } + let result = []; if (type === 'both') { - return [].concat(accountStore.accounts, accountStore.groups); + result = [].concat(accountStore.accounts, accountStore.groups); } - return [].concat(accountStore[type]); + else + { + result = [].concat(accountStore[type]); + } + return async ? Promise.resolve(result) : result; }, /**