diff --git a/html/src/app.js b/html/src/app.js index 7137a656..58eb16dc 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -7054,6 +7054,56 @@ speechSynthesis.getVoices(); }); }; + $app.methods.promptRenameAvatar = function (avatar) { + this.$prompt('Enter avatar name', 'Rename Avatar', { + distinguishCancelAndClose: true, + confirmButtonText: 'OK', + cancelButtonText: 'Cancel', + inputValue: avatar.ref.name, + inputErrorMessage: 'Valid name is required', + callback: (action, instance) => { + if (action === 'confirm' && + instance.inputValue !== avatar.ref.name) { + API.saveAvatar({ + id: avatar.id, + name: instance.inputValue + }).then((args) => { + this.$message({ + message: 'Avatar renamed', + type: 'success' + }); + return args; + }); + } + } + }); + }; + + $app.methods.promptChangeDescription = function (avatar) { + this.$prompt('Enter avatar description', 'Change Description', { + distinguishCancelAndClose: true, + confirmButtonText: 'OK', + cancelButtonText: 'Cancel', + inputValue: avatar.ref.description, + inputErrorMessage: 'Valid description is required', + callback: (action, instance) => { + if (action === 'confirm' && + instance.inputValue !== avatar.ref.description) { + API.saveAvatar({ + id: avatar.id, + description: instance.inputValue + }).then((args) => { + this.$message({ + message: 'Avatar description changed', + type: 'success' + }); + return args; + }); + } + } + }); + }; + // App: Dialog var adjustDialogZ = (el) => { @@ -8126,12 +8176,20 @@ speechSynthesis.getVoices(); if (D.visible === false) { return; } - if (command === 'Add Favorite') { - this.showFavoriteDialog('avatar', D.id); - } else { - this.$confirm(`Continue? ${command}`, 'Confirm', { - confirmButtonText: 'Confirm', - cancelButtonText: 'Cancel', + switch (command) { + case 'Rename': + this.promptRenameAvatar(D); + break; + case 'Change Description': + this.promptChangeDescription(D); + break; + case 'Add Favorite': + this.showFavoriteDialog('avatar', D.id); + break; + default: + this.$confirm(`Continue? ${command}`, 'Confirm', { + confirmButtonText: 'Confirm', + cancelButtonText: 'Cancel', type: 'info', callback: (action) => { if (action !== 'confirm') { @@ -8180,9 +8238,10 @@ speechSynthesis.getVoices(); break; default: break; + } } - } - }); + }); + break; } }; diff --git a/html/src/index.pug b/html/src/index.pug index 5b38b6b5..0eaa55ff 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -1151,6 +1151,8 @@ html template(v-if="avatarDialog.ref.authorId === API.currentUser.id") el-dropdown-item(v-if="avatarDialog.ref.releaseStatus === 'public'" icon="el-icon-user-solid" command="Make Private" divided) Make Private el-dropdown-item(v-else icon="el-icon-user" command="Make Public" divided) Make Public + el-dropdown-item(icon="el-icon-edit" command="Rename") Rename + el-dropdown-item(icon="el-icon-edit" command="Change Description") Change Description el-tabs el-tab-pane(label="Info") .x-friend-list