mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-08 23:19:04 +01:00
Switch egw.user(..., async=true) to always return a Promise for consistency
Switch Et2ButtonTimestamper to use egw.user(...,async=true)
This commit is contained in:
parent
82504ed158
commit
79b6cef5fd
@ -81,7 +81,9 @@ export class Et2ButtonTimestamper extends Et2Button
|
|||||||
|
|
||||||
// Get properly formatted user name
|
// Get properly formatted user name
|
||||||
const user = parseInt(egw.user('account_id'));
|
const user = parseInt(egw.user('account_id'));
|
||||||
const account = egw.accounts('accounts').filter(option => option.value == user)[0];
|
egw.accounts('accounts', true).then((accounts) =>
|
||||||
|
{
|
||||||
|
const account = accounts.filter(option => option.value == user)[0];
|
||||||
text += account.label + ': ';
|
text += account.label + ': ';
|
||||||
|
|
||||||
const widget = this._get_input(this.target);
|
const widget = this._get_input(this.target);
|
||||||
@ -93,20 +95,20 @@ export class Et2ButtonTimestamper extends Et2Button
|
|||||||
|
|
||||||
let scrollPos = input.scrollTop;
|
let scrollPos = input.scrollTop;
|
||||||
let browser = ((input.selectionStart || input.selectionStart == "0") ?
|
let browser = ((input.selectionStart || input.selectionStart == "0") ?
|
||||||
"standards" : (document["selection"] ? "ie" : false ) );
|
"standards" : (document["selection"] ? "ie" : false));
|
||||||
|
|
||||||
let pos = 0;
|
let pos = 0;
|
||||||
let tinymce = tinyMCE && tinyMCE.EditorManager.get(input.id) || false;
|
let tinymce = tinyMCE && tinyMCE.EditorManager.get(input.id) || false;
|
||||||
|
|
||||||
// Find cursor or selection
|
// Find cursor or selection
|
||||||
if (browser == "ie")
|
if(browser == "ie")
|
||||||
{
|
{
|
||||||
input.focus();
|
input.focus();
|
||||||
let range = document["selection"].createRange();
|
let range = document["selection"].createRange();
|
||||||
range.moveStart ("character", -input.value.length);
|
range.moveStart("character", -input.value.length);
|
||||||
pos = range.text.length;
|
pos = range.text.length;
|
||||||
}
|
}
|
||||||
else if (browser == "standards")
|
else if(browser == "standards")
|
||||||
{
|
{
|
||||||
pos = input.selectionStart;
|
pos = input.selectionStart;
|
||||||
}
|
}
|
||||||
@ -117,7 +119,10 @@ export class Et2ButtonTimestamper extends Et2Button
|
|||||||
{
|
{
|
||||||
tabbox = tabbox._parent;
|
tabbox = tabbox._parent;
|
||||||
}
|
}
|
||||||
if (tabbox.nodeName === 'ET2-TABBOX') (<Et2Tabs>tabbox).activateTab(widget);
|
if(tabbox.nodeName === 'ET2-TABBOX')
|
||||||
|
{
|
||||||
|
(<Et2Tabs>tabbox).activateTab(widget);
|
||||||
|
}
|
||||||
|
|
||||||
// If tinymce, update it
|
// If tinymce, update it
|
||||||
if(tinymce)
|
if(tinymce)
|
||||||
@ -130,23 +135,25 @@ export class Et2ButtonTimestamper extends Et2Button
|
|||||||
let front = (input.value).substring(0, pos);
|
let front = (input.value).substring(0, pos);
|
||||||
let back = (input.value).substring(pos, input.value.length);
|
let back = (input.value).substring(pos, input.value.length);
|
||||||
// for webComponent, we need to set the component value too, otherwise the change is lost!
|
// for webComponent, we need to set the component value too, otherwise the change is lost!
|
||||||
if (typeof widget.tagName !== 'undefined')
|
if(typeof widget.tagName !== 'undefined')
|
||||||
{
|
{
|
||||||
widget.value = front+text+back;
|
widget.value = front + text + back;
|
||||||
}
|
}
|
||||||
input.value = front+text+back;
|
input.value = front + text + back;
|
||||||
|
|
||||||
// Clean up a little
|
// Clean up a little
|
||||||
pos = pos + text.length;
|
pos = pos + text.length;
|
||||||
if (browser == "ie") {
|
if(browser == "ie")
|
||||||
|
{
|
||||||
input.focus();
|
input.focus();
|
||||||
let range = document["selection"].createRange();
|
let range = document["selection"].createRange();
|
||||||
range.moveStart ("character", -input.value.length);
|
range.moveStart("character", -input.value.length);
|
||||||
range.moveStart ("character", pos);
|
range.moveStart("character", pos);
|
||||||
range.moveEnd ("character", 0);
|
range.moveEnd("character", 0);
|
||||||
range.select();
|
range.select();
|
||||||
}
|
}
|
||||||
else if (browser == "standards") {
|
else if(browser == "standards")
|
||||||
|
{
|
||||||
input.selectionStart = pos;
|
input.selectionStart = pos;
|
||||||
input.selectionEnd = pos;
|
input.selectionEnd = pos;
|
||||||
input.focus();
|
input.focus();
|
||||||
@ -154,6 +161,7 @@ export class Et2ButtonTimestamper extends Et2Button
|
|||||||
input.scrollTop = scrollPos;
|
input.scrollTop = scrollPos;
|
||||||
input.focus();
|
input.focus();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _get_input(target)
|
private _get_input(target)
|
||||||
|
@ -122,11 +122,16 @@ egw.extend('user', egw.MODULE_GLOBAL, function()
|
|||||||
// Synchronous
|
// Synchronous
|
||||||
egw.json("EGroupware\\Api\\Framework::ajax_user_list",[], cache_it, this, false).sendRequest(false);
|
egw.json("EGroupware\\Api\\Framework::ajax_user_list",[], cache_it, this, false).sendRequest(false);
|
||||||
}
|
}
|
||||||
|
let result = [];
|
||||||
if (type === 'both')
|
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;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user