Change display name in useradmin menu

pull/1/head
yflory 7 years ago
parent a96d447e8b
commit dd9b38066e

@ -45,6 +45,8 @@ define([
}); });
}; };
funcs.feedback = function () {};
Object.freeze(funcs); Object.freeze(funcs);
return { create: function (cb) { return { create: function (cb) {
nThen(function (waitFor) { nThen(function (waitFor) {

@ -358,7 +358,7 @@ define([
$content.css('margin-top', h+'px'); $content.css('margin-top', h+'px');
}); });
$closeIcon.click(function () { $closeIcon.click(function () {
Cryptpad.setAttribute('userlist-drawer', false); //Cryptpad.setAttribute('userlist-drawer', false); TODO iframe
hide(); hide();
}); });
$button.click(function () { $button.click(function () {
@ -368,9 +368,9 @@ define([
visible = !visible; visible = !visible;
// TODO iframe // TODO iframe
//Cryptpad.setAttribute('userlist-drawer', visible); //Cryptpad.setAttribute('userlist-drawer', visible);
//Cryptpad.feedback(visible?'USERLIST_SHOW': 'USERLIST_HIDE'); Common.feedback(visible?'USERLIST_SHOW': 'USERLIST_HIDE');
}); });
show();
// TODO iframe // TODO iframe
/*Cryptpad.getAttribute('userlist-drawer', function (err, val) { /*Cryptpad.getAttribute('userlist-drawer', function (err, val) {
if (val === false || mobile) { return void hide(); } if (val === false || mobile) { return void hide(); }
@ -773,6 +773,11 @@ define([
}; };
var createUserAdmin = function (toolbar, config) { var createUserAdmin = function (toolbar, config) {
if (!config.metadataMgr) {
throw new Error("You must provide a `metadataMgr` to display the user menu");
}
var metadataMgr = config.metadataMgr;
var myData = metadataMgr.getMetadata().users[metadataMgr.getNetfluxId()];
var $userAdmin = toolbar.$userAdmin.find('.'+USERADMIN_CLS).show(); var $userAdmin = toolbar.$userAdmin.find('.'+USERADMIN_CLS).show();
var userMenuCfg = { var userMenuCfg = {
$initBlock: $userAdmin $initBlock: $userAdmin
@ -795,22 +800,23 @@ define([
$userButton.click(function (e) { $userButton.click(function (e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
Cryptpad.getLastName(function (err, lastName) { var lastName = myData.displayName;
if (err) { return void console.error("Cannot get last name", err); } //Cryptpad.getLastName(function (err, lastName) {
//if (err) { return void console.error("Cannot get last name", err); }
Cryptpad.prompt(Messages.changeNamePrompt, lastName || '', function (newName) { Cryptpad.prompt(Messages.changeNamePrompt, lastName || '', function (newName) {
if (newName === null && typeof(lastName) === "string") { return; } if (newName === null && typeof(lastName) === "string") { return; }
if (newName === null) { newName = ''; } if (newName === null) { newName = ''; }
else { Cryptpad.feedback('NAME_CHANGED'); } else { Common.feedback('NAME_CHANGED'); }
Cryptpad.setAttribute('username', newName, function (err) { Common.setDisplayName(newName, function (err) {
if (err) { if (err) {
console.log("Couldn't set username"); console.log("Couldn't set username");
console.error(err); console.error(err);
return; return;
} }
Cryptpad.changeDisplayName(newName, true); //Cryptpad.changeDisplayName(newName, true); Already done?
});
}); });
}); });
//});
}); });
Cryptpad.onDisplayNameChanged(function () { Cryptpad.onDisplayNameChanged(function () {
window.setTimeout(function () { window.setTimeout(function () {

@ -487,6 +487,16 @@ define([
var $rightside = toolbar.$rightside; var $rightside = toolbar.$rightside;
var src = 'less!/customize/src/less/toolbar.less';
require([
src
], function () {
var $html = $bar.closest('html');
$html
.find('head style[data-original-src="' + src.replace(/less!/, '') + '"]')
.appendTo($html.find('head'));
});
$bar.find('#cke_1_toolbar_collapser').hide(); $bar.find('#cke_1_toolbar_collapser').hide();
if (!readOnly) { if (!readOnly) {
// Expand / collapse the toolbar // Expand / collapse the toolbar
@ -549,7 +559,7 @@ define([
}; };
toolbar = info.realtime.toolbar = Toolbar.create(configTb); toolbar = info.realtime.toolbar = Toolbar.create(configTb);
*/ */
var src = 'less!/customize/src/less/toolbar.less'; /*var src = 'less!/customize/src/less/toolbar.less';
require([ require([
src src
], function () { ], function () {
@ -557,7 +567,7 @@ define([
$html $html
.find('head style[data-original-src="' + src.replace(/less!/, '') + '"]') .find('head style[data-original-src="' + src.replace(/less!/, '') + '"]')
.appendTo($html.find('head')); .appendTo($html.find('head'));
}); });*/
//Title.setToolbar(toolbar); //Title.setToolbar(toolbar);

Loading…
Cancel
Save