refactor: account edit logic and template, closes #9364

v1.18.x
Julian Lam 4 years ago
parent f6fa94a8ce
commit 98bf4064e7

@ -92,9 +92,9 @@
"nodebb-plugin-spam-be-gone": "0.7.8", "nodebb-plugin-spam-be-gone": "0.7.8",
"nodebb-rewards-essentials": "0.1.4", "nodebb-rewards-essentials": "0.1.4",
"nodebb-theme-lavender": "5.2.1", "nodebb-theme-lavender": "5.2.1",
"nodebb-theme-persona": "10.5.17", "nodebb-theme-persona": "11.0.1",
"nodebb-theme-slick": "1.4.3", "nodebb-theme-slick": "1.4.3",
"nodebb-theme-vanilla": "11.4.5", "nodebb-theme-vanilla": "12.0.1",
"nodebb-widget-essentials": "5.0.3", "nodebb-widget-essentials": "5.0.3",
"nodemailer": "^6.5.0", "nodemailer": "^6.5.0",
"nprogress": "0.2.0", "nprogress": "0.2.0",

@ -5,7 +5,8 @@ define('forum/account/edit', [
'accounts/picture', 'accounts/picture',
'translator', 'translator',
'api', 'api',
], function (header, picture, translator, api) { 'hooks',
], function (header, picture, translator, api, hooks) {
var AccountEdit = {}; var AccountEdit = {};
AccountEdit.init = function () { AccountEdit.init = function () {
@ -31,22 +32,13 @@ define('forum/account/edit', [
}; };
function updateProfile() { function updateProfile() {
var userData = { const userData = $('form[component="profile/edit/form"]').serializeObject();
uid: $('#inputUID').val(), userData.uid = ajaxify.data.uid;
fullname: $('#inputFullname').val(),
website: $('#inputWebsite').val(),
birthday: $('#inputBirthday').val(),
location: $('#inputLocation').val(),
groupTitle: $('#groupTitle').val(),
signature: $('#inputSignature').val(),
aboutme: $('#inputAboutMe').val(),
};
userData.groupTitle = JSON.stringify( userData.groupTitle = JSON.stringify(
Array.isArray(userData.groupTitle) ? userData.groupTitle : [userData.groupTitle] Array.isArray(userData.groupTitle) ? userData.groupTitle : [userData.groupTitle]
); );
$(window).trigger('action:profile.update', userData); hooks.fire('action:profile.update', userData);
api.put('/users/' + userData.uid, userData).then((res) => { api.put('/users/' + userData.uid, userData).then((res) => {
app.alertSuccess('[[user:profile_update_success]]'); app.alertSuccess('[[user:profile_update_success]]');
@ -128,7 +120,7 @@ define('forum/account/edit', [
} }
function updateSignature() { function updateSignature() {
var el = $('#inputSignature'); var el = $('#signature');
$('#signatureCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumSignatureLength)); $('#signatureCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumSignatureLength));
el.on('keyup change', function () { el.on('keyup change', function () {
@ -137,7 +129,7 @@ define('forum/account/edit', [
} }
function updateAboutMe() { function updateAboutMe() {
var el = $('#inputAboutMe'); var el = $('#aboutme');
$('#aboutMeCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumAboutMeLength)); $('#aboutMeCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumAboutMeLength));
el.on('keyup change', function () { el.on('keyup change', function () {

Loading…
Cancel
Save